mirror of https://github.com/Syncplay/syncplay
Fixes VLC close issue on macOS (#83)
This commit is contained in:
parent
16dac94454
commit
2f24882426
|
@ -172,6 +172,7 @@ MPV_SLAVE_ARGS_NEW = ['--term-playing-msg=<SyncplayUpdateFile>\nANS_filename=${f
|
|||
MPV_NEW_VERSION = False
|
||||
VLC_SLAVE_ARGS = ['--extraintf=luaintf', '--lua-intf=syncplay', '--no-quiet', '--no-input-fast-seek',
|
||||
'--play-and-pause', '--start-time=0']
|
||||
VLC_SLAVE_OSX_ARGS = ['--verbose=2', '--no-file-logging']
|
||||
VLC_SLAVE_NONOSX_ARGS = ['--no-one-instance', '--no-one-instance-when-started-from-file']
|
||||
MPV_SUPERSEDE_IF_DUPLICATE_COMMANDS = ["no-osd set time-pos ", "loadfile "]
|
||||
MPV_REMOVE_BOTH_IF_DUPLICATE_COMMANDS = ["cycle pause"]
|
||||
|
|
|
@ -20,8 +20,10 @@ class VlcPlayer(BasePlayer):
|
|||
|
||||
RE_ANSWER = re.compile(constants.VLC_ANSWER_REGEX)
|
||||
SLAVE_ARGS = constants.VLC_SLAVE_ARGS
|
||||
if not sys.platform.startswith('darwin'):
|
||||
SLAVE_ARGS.extend(constants.VLC_SLAVE_NONOSX_ARGS)
|
||||
if sys.platform.startswith('darwin'):
|
||||
SLAVE_ARGS.extend(constants.VLC_SLAVE_OSX_ARGS)
|
||||
else:
|
||||
SLAVE_ARGS.extend(constants.VLC_SLAVE_NONOSX_ARGS)
|
||||
vlcport = random.randrange(constants.VLC_MIN_PORT, constants.VLC_MAX_PORT) if (constants.VLC_MIN_PORT < constants.VLC_MAX_PORT) else constants.VLC_MIN_PORT
|
||||
|
||||
def __init__(self, client, playerPath, filePath, args):
|
||||
|
@ -381,7 +383,12 @@ class VlcPlayer(BasePlayer):
|
|||
playerController._client.ui.showErrorMessage(
|
||||
getMessage("media-player-error").format(line), True)
|
||||
break
|
||||
self.__process.stderr = None
|
||||
if not sys.platform.startswith('darwin'):
|
||||
self.__process.stderr = None
|
||||
else:
|
||||
vlcoutputthread = threading.Thread(target = self.handle_vlcoutput, args=())
|
||||
vlcoutputthread.setDaemon(True)
|
||||
vlcoutputthread.start()
|
||||
threading.Thread.__init__(self, name="VLC Listener")
|
||||
asynchat.async_chat.__init__(self)
|
||||
self.set_terminator("\n")
|
||||
|
@ -427,6 +434,15 @@ class VlcPlayer(BasePlayer):
|
|||
asynchat.async_chat.handle_close(self)
|
||||
self.__playerController.drop(getMessage("vlc-failed-connection").format(constants.VLC_MIN_VERSION))
|
||||
|
||||
def handle_vlcoutput(self):
|
||||
out = self.__process.stderr
|
||||
for line in iter(out.readline, ''):
|
||||
if '[syncplay] core interface debug: removing module' in line:
|
||||
self.__playerController.drop()
|
||||
break
|
||||
out.close()
|
||||
|
||||
|
||||
def found_terminator(self):
|
||||
self.vlcHasResponded = True
|
||||
self.__playerController.lineReceived("".join(self._ibuffer))
|
||||
|
|
Loading…
Reference in New Issue