mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 19:52:16 +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):
|
||||
self.__cmd = shlex.split(cmd)
|
||||
self.__playlist = []
|
||||
self.__index = -1
|
||||
self.__index = 0
|
||||
|
||||
self.__thread = None
|
||||
self.__lock = RLock()
|
||||
@ -63,7 +63,7 @@ class Jukebox(object):
|
||||
raise IndexError()
|
||||
|
||||
with self.__lock:
|
||||
self.__index = index - 1
|
||||
self.__index = index
|
||||
self.__skip.set()
|
||||
self.start()
|
||||
|
||||
@ -79,7 +79,7 @@ class Jukebox(object):
|
||||
def clear(self):
|
||||
with self.__lock:
|
||||
self.__playlist.clear()
|
||||
self.__index = -1
|
||||
self.__index = 0
|
||||
|
||||
def remove(self, index):
|
||||
try:
|
||||
@ -108,9 +108,13 @@ class Jukebox(object):
|
||||
if self.__skip.is_set():
|
||||
proc.terminate()
|
||||
proc.wait()
|
||||
proc = None
|
||||
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:
|
||||
self.__index += 1
|
||||
if self.__index >= len(self.__playlist):
|
||||
|
Loading…
Reference in New Issue
Block a user