From fde8c05117aa4a82d816bb69f8292c103270dc6b Mon Sep 17 00:00:00 2001 From: Et0h Date: Fri, 30 Dec 2016 13:41:09 +0000 Subject: [PATCH] Wait for STDOUT in VLC for non-Windows systems (to resolve#125 reported by blaenk) --- syncplay/constants.py | 1 - syncplay/players/vlc.py | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/syncplay/constants.py b/syncplay/constants.py index 0ac95d5..cd04f45 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -54,7 +54,6 @@ DO_NOT_RESET_POSITION_THRESHOLD = 1.0 SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear on some media players PLAYLIST_MAX_CHARACTERS = 10000 PLAYLIST_MAX_ITEMS = 250 -VLC_LISTEN_FOR_STDOUT = False # Changing to True this could break VLC 3 on Windows # Options for the File Switch feature: FOLDER_SEARCH_FIRST_FILE_TIMEOUT = 15.0 # Secs - How long to wait to find the first file in folder search (to take account of HDD spin up) diff --git a/syncplay/players/vlc.py b/syncplay/players/vlc.py index b491c39..f818d58 100644 --- a/syncplay/players/vlc.py +++ b/syncplay/players/vlc.py @@ -362,7 +362,7 @@ class VlcPlayer(BasePlayer): else: self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE) - if constants.VLC_LISTEN_FOR_STDOUT: + if self._shouldListenForSTDOUT(): for line in iter(self.__process.stderr.readline, ''): self.vlcHasResponded = True if "[syncplay]" in line: @@ -386,6 +386,12 @@ class VlcPlayer(BasePlayer): self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self._sendingData = threading.Lock() + def _shouldListenForSTDOUT(self): + if sys.platform.startswith('win'): + return False # Due to VLC3 not using STDOUT/STDERR + else: + return True + def initiate_send(self): with self._sendingData: asynchat.async_chat.initiate_send(self)