Revert "Make sure that LOCK is released after adding one element"
This reverts commit c05b772e90
.
- Should fix a racing condition if the playlist is cleared (picked up by both kodimonitor and playqueue monitor)
This commit is contained in:
parent
48810a227f
commit
87b22f1588
1 changed files with 34 additions and 39 deletions
|
@ -179,42 +179,39 @@ 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)
|
|
||||||
else:
|
|
||||||
PL.add_item_to_PMS_playlist(playqueue,
|
|
||||||
i,
|
|
||||||
kodi_item=new_item)
|
|
||||||
except PL.PlaylistError:
|
|
||||||
# Could not add the element
|
|
||||||
pass
|
|
||||||
except IndexError:
|
|
||||||
# This is really a hack - happens when using Addon Paths
|
|
||||||
# and repeatedly starting the same element. Kodi will
|
|
||||||
# then not pass kodi id nor file path AND will also not
|
|
||||||
# start-up playback. Hence kodimonitor kicks off
|
|
||||||
# playback. Also see kodimonitor.py - _playlist_onadd()
|
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
for j in range(i, len(index)):
|
PL.add_item_to_PMS_playlist(playqueue,
|
||||||
index[j] += 1
|
i,
|
||||||
|
kodi_item=new_item)
|
||||||
|
except PL.PlaylistError:
|
||||||
|
# Could not add the element
|
||||||
|
pass
|
||||||
|
except IndexError:
|
||||||
|
# This is really a hack - happens when using Addon Paths
|
||||||
|
# and repeatedly starting the same element. Kodi will then
|
||||||
|
# not pass kodi id nor file path AND will also not
|
||||||
|
# start-up playback. Hence kodimonitor kicks off playback.
|
||||||
|
# Also see kodimonitor.py - _playlist_onadd()
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
for j in range(i, len(index)):
|
||||||
|
index[j] += 1
|
||||||
for i in reversed(index):
|
for i in reversed(index):
|
||||||
if self.stopped():
|
if self.stopped():
|
||||||
# Chances are that we got an empty Kodi playlist due to
|
# Chances are that we got an empty Kodi playlist due to
|
||||||
# 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')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -226,20 +223,18 @@ class PlayqueueMonitor(Thread):
|
||||||
if stopped():
|
if stopped():
|
||||||
break
|
break
|
||||||
sleep(1000)
|
sleep(1000)
|
||||||
for playqueue in PLAYQUEUES:
|
with LOCK:
|
||||||
kodi_pl = js.playlist_get_items(playqueue.playlistid)
|
for playqueue in PLAYQUEUES:
|
||||||
if playqueue.old_kodi_pl != kodi_pl:
|
kodi_pl = js.playlist_get_items(playqueue.playlistid)
|
||||||
if playqueue.id is None and (not state.DIRECT_PATHS or
|
if playqueue.old_kodi_pl != kodi_pl:
|
||||||
state.CONTEXT_MENU_PLAY):
|
if playqueue.id is None and (not state.DIRECT_PATHS or
|
||||||
# Only initialize if directly fired up using direct
|
state.CONTEXT_MENU_PLAY):
|
||||||
# paths. Otherwise let default.py do its magic
|
# Only initialize if directly fired up using direct
|
||||||
LOG.debug('Not yet initiating playback')
|
# paths. Otherwise let default.py do its magic
|
||||||
elif playqueue.pkc_edit:
|
LOG.debug('Not yet initiating playback')
|
||||||
playqueue.pkc_edit = False
|
else:
|
||||||
LOG.debug('PKC just edited the playqueue - skipping')
|
# compare old and new playqueue
|
||||||
else:
|
self._compare_playqueues(playqueue, kodi_pl)
|
||||||
# compare old and new playqueue
|
playqueue.old_kodi_pl = list(kodi_pl)
|
||||||
self._compare_playqueues(playqueue, kodi_pl)
|
|
||||||
playqueue.old_kodi_pl = list(kodi_pl)
|
|
||||||
sleep(200)
|
sleep(200)
|
||||||
LOG.info("----===## PlayqueueMonitor stopped ##===----")
|
LOG.info("----===## PlayqueueMonitor stopped ##===----")
|
||||||
|
|
Loading…
Reference in a new issue