Make sure that LOCK is released after adding one element
- Partially fixes #446
This commit is contained in:
parent
dcf2b9b4e4
commit
c05b772e90
1 changed files with 36 additions and 34 deletions
|
@ -179,12 +179,14 @@ class PlayqueueMonitor(Thread):
|
||||||
elif identical:
|
elif identical:
|
||||||
LOG.debug('Detected playqueue item %s moved to position %s',
|
LOG.debug('Detected playqueue item %s moved to position %s',
|
||||||
i + j, i)
|
i + j, i)
|
||||||
|
with LOCK:
|
||||||
PL.move_playlist_item(playqueue, i + j, i)
|
PL.move_playlist_item(playqueue, i + j, i)
|
||||||
del old[j], index[j]
|
del old[j], index[j]
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
LOG.debug('Detected new Kodi element at position %s: %s ',
|
LOG.debug('Detected new Kodi element at position %s: %s ',
|
||||||
i, new_item)
|
i, new_item)
|
||||||
|
with LOCK:
|
||||||
try:
|
try:
|
||||||
if playqueue.id is None:
|
if playqueue.id is None:
|
||||||
PL.init_Plex_playlist(playqueue, kodi_item=new_item)
|
PL.init_Plex_playlist(playqueue, kodi_item=new_item)
|
||||||
|
@ -197,10 +199,10 @@ class PlayqueueMonitor(Thread):
|
||||||
pass
|
pass
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# This is really a hack - happens when using Addon Paths
|
# This is really a hack - happens when using Addon Paths
|
||||||
# and repeatedly starting the same element. Kodi will then
|
# and repeatedly starting the same element. Kodi will
|
||||||
# not pass kodi id nor file path AND will also not
|
# then not pass kodi id nor file path AND will also not
|
||||||
# start-up playback. Hence kodimonitor kicks off playback.
|
# start-up playback. Hence kodimonitor kicks off
|
||||||
# Also see kodimonitor.py - _playlist_onadd()
|
# playback. Also see kodimonitor.py - _playlist_onadd()
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
for j in range(i, len(index)):
|
for j in range(i, len(index)):
|
||||||
|
@ -211,6 +213,7 @@ class PlayqueueMonitor(Thread):
|
||||||
# Kodi exit
|
# Kodi exit
|
||||||
return
|
return
|
||||||
LOG.debug('Detected deletion of playqueue element at pos %s', i)
|
LOG.debug('Detected deletion of playqueue element at pos %s', i)
|
||||||
|
with LOCK:
|
||||||
PL.delete_playlist_item_from_PMS(playqueue, i)
|
PL.delete_playlist_item_from_PMS(playqueue, i)
|
||||||
LOG.debug('Done comparing playqueues')
|
LOG.debug('Done comparing playqueues')
|
||||||
|
|
||||||
|
@ -223,7 +226,6 @@ class PlayqueueMonitor(Thread):
|
||||||
if stopped():
|
if stopped():
|
||||||
break
|
break
|
||||||
sleep(1000)
|
sleep(1000)
|
||||||
with LOCK:
|
|
||||||
for playqueue in PLAYQUEUES:
|
for playqueue in PLAYQUEUES:
|
||||||
kodi_pl = js.playlist_get_items(playqueue.playlistid)
|
kodi_pl = js.playlist_get_items(playqueue.playlistid)
|
||||||
if playqueue.old_kodi_pl != kodi_pl:
|
if playqueue.old_kodi_pl != kodi_pl:
|
||||||
|
|
Loading…
Reference in a new issue