Merge pull request #127 from Syncplay/1.4.x

Merge in 1.4.x changes
This commit is contained in:
Etoh 2017-01-06 11:45:31 +00:00 committed by GitHub
commit 52067c497f
3 changed files with 31 additions and 7 deletions

View File

@ -1,4 +1,4 @@
version = '1.5.0' version = '1.5.0'
milestone = 'Yoitsu' milestone = 'Yoitsu'
release_number = '37' release_number = '39'
projectURL = 'http://syncplay.pl/' projectURL = 'http://syncplay.pl/'

View File

@ -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 SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear on some media players
PLAYLIST_MAX_CHARACTERS = 10000 PLAYLIST_MAX_CHARACTERS = 10000
PLAYLIST_MAX_ITEMS = 250 PLAYLIST_MAX_ITEMS = 250
VLC_LISTEN_FOR_STDOUT = False # Changing to True this could break VLC 3 on Windows
# Maximum character lengths (for client and server) # Maximum character lengths (for client and server)
MAX_CHAT_MESSAGE_LENGTH = 50 # Number of displayed characters MAX_CHAT_MESSAGE_LENGTH = 50 # Number of displayed characters
@ -139,7 +138,7 @@ MPV_SENDMESSAGE_COOLDOWN_TIME = 0.05
MPV_MAX_NEWFILE_COOLDOWN_TIME = 3 MPV_MAX_NEWFILE_COOLDOWN_TIME = 3
STREAM_ADDITIONAL_IGNORE_TIME = 10 STREAM_ADDITIONAL_IGNORE_TIME = 10
MPV_LOCK_WAIT_TIME = 0.05 MPV_LOCK_WAIT_TIME = 0.05
VLC_OPEN_MAX_WAIT_TIME = 15 VLC_OPEN_MAX_WAIT_TIME = 20
VLC_MIN_PORT = 10000 VLC_MIN_PORT = 10000
VLC_MAX_PORT = 55000 VLC_MAX_PORT = 55000

View File

@ -302,6 +302,7 @@ class VlcPlayer(BasePlayer):
self.requestedVLCVersion = False self.requestedVLCVersion = False
self.vlcHasResponded = False self.vlcHasResponded = False
self.oldIntfVersion = None self.oldIntfVersion = None
self.timeVLCLaunched = None
call = [playerPath] call = [playerPath]
if filePath: if filePath:
if utils.isASCII(filePath): if utils.isASCII(filePath):
@ -362,9 +363,11 @@ class VlcPlayer(BasePlayer):
else: else:
self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE) self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
if constants.VLC_LISTEN_FOR_STDOUT: self.timeVLCLaunched = time.time()
if self._shouldListenForSTDOUT():
for line in iter(self.__process.stderr.readline, ''): for line in iter(self.__process.stderr.readline, ''):
self.vlcHasResponded = True self.vlcHasResponded = True
self.timeVLCLaunched = None
if "[syncplay]" in line: if "[syncplay]" in line:
if "Listening on host" in line: if "Listening on host" in line:
break break
@ -386,6 +389,12 @@ class VlcPlayer(BasePlayer):
self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self._sendingData = threading.Lock() 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): def initiate_send(self):
with self._sendingData: with self._sendingData:
asynchat.async_chat.initiate_send(self) asynchat.async_chat.initiate_send(self)
@ -398,15 +407,24 @@ class VlcPlayer(BasePlayer):
def handle_connect(self): def handle_connect(self):
asynchat.async_chat.handle_connect(self) asynchat.async_chat.handle_connect(self)
self._vlcready.set() self._vlcready.set()
self.timeVLCLaunched = None
def collect_incoming_data(self, data): def collect_incoming_data(self, data):
self._ibuffer.append(data) self._ibuffer.append(data)
def handle_close(self): def handle_close(self):
asynchat.async_chat.handle_close(self) if self.timeVLCLaunched and time.time() - self.timeVLCLaunched < constants.VLC_OPEN_MAX_WAIT_TIME:
if self.vlcHasResponded: try:
self.__playerController._client.ui.showDebugMessage("Failed to connect to VLC, but reconnecting as within max wait time")
except:
pass
self.run()
elif self.vlcHasResponded:
asynchat.async_chat.handle_close(self)
self.__playerController.drop() self.__playerController.drop()
else: else:
self.vlcHasResponded = True
asynchat.async_chat.handle_close(self)
self.__playerController.drop(getMessage("vlc-failed-connection").format(constants.VLC_MIN_VERSION)) self.__playerController.drop(getMessage("vlc-failed-connection").format(constants.VLC_MIN_VERSION))
def found_terminator(self): def found_terminator(self):
@ -421,8 +439,15 @@ class VlcPlayer(BasePlayer):
self.sendLine("get-vlc-version") self.sendLine("get-vlc-version")
try: try:
self.push(line + "\n") self.push(line + "\n")
self.__playerController._client.ui.showDebugMessage("player >> {}".format(line)) if self.__playerController._client and self.__playerController._client.ui:
self.__playerController._client.ui.showDebugMessage("player >> {}".format(line))
except: except:
pass pass
if line == "close-vlc": if line == "close-vlc":
self._vlcclosed.set() self._vlcclosed.set()
if not self.connected and not self.timeVLCLaunched:
# For circumstances where Syncplay is not connected to VLC and is not reconnecting
try:
self.__process.terminate()
except: # When VLC is already closed
pass