mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
Fixed jukebox endpoint response not being in sync when skipping
This commit is contained in:
parent
0d40ede256
commit
4e69cd0551
@ -25,7 +25,7 @@ class Jukebox(object):
|
|||||||
def __init__(self, cmd):
|
def __init__(self, cmd):
|
||||||
self.__cmd = shlex.split(cmd)
|
self.__cmd = shlex.split(cmd)
|
||||||
self.__playlist = []
|
self.__playlist = []
|
||||||
self.__index = -1
|
self.__index = 0
|
||||||
|
|
||||||
self.__thread = None
|
self.__thread = None
|
||||||
self.__lock = RLock()
|
self.__lock = RLock()
|
||||||
@ -63,7 +63,7 @@ class Jukebox(object):
|
|||||||
raise IndexError()
|
raise IndexError()
|
||||||
|
|
||||||
with self.__lock:
|
with self.__lock:
|
||||||
self.__index = index - 1
|
self.__index = index
|
||||||
self.__skip.set()
|
self.__skip.set()
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ class Jukebox(object):
|
|||||||
def clear(self):
|
def clear(self):
|
||||||
with self.__lock:
|
with self.__lock:
|
||||||
self.__playlist.clear()
|
self.__playlist.clear()
|
||||||
self.__index = -1
|
self.__index = 0
|
||||||
|
|
||||||
def remove(self, index):
|
def remove(self, index):
|
||||||
try:
|
try:
|
||||||
@ -108,9 +108,13 @@ class Jukebox(object):
|
|||||||
if self.__skip.is_set():
|
if self.__skip.is_set():
|
||||||
proc.terminate()
|
proc.terminate()
|
||||||
proc.wait()
|
proc.wait()
|
||||||
|
proc = None
|
||||||
self.__skip.clear()
|
self.__skip.clear()
|
||||||
|
|
||||||
if proc is None or proc.poll() is not None:
|
if proc is None:
|
||||||
|
with self.__lock:
|
||||||
|
proc = self.__play_file()
|
||||||
|
elif proc.poll() is not None:
|
||||||
with self.__lock:
|
with self.__lock:
|
||||||
self.__index += 1
|
self.__index += 1
|
||||||
if self.__index >= len(self.__playlist):
|
if self.__index >= len(self.__playlist):
|
||||||
|
Loading…
Reference in New Issue
Block a user