Revert "Fix playqueue monitoring locking mechanism"

This reverts commit 1e43f1cc77.
- Should fix a racing condition if the playlist is cleared (picked up by both kodimonitor and playqueue monitor)
This commit is contained in:
croneter 2018-06-02 17:26:36 +02:00
parent 147d35ca24
commit 48810a227f

View file

@ -226,26 +226,20 @@ class PlayqueueMonitor(Thread):
if stopped(): if stopped():
break break
sleep(1000) sleep(1000)
work = [] for playqueue in PLAYQUEUES:
# Detect changed playqueues first, do the work afterwards kodi_pl = js.playlist_get_items(playqueue.playlistid)
with LOCK: if playqueue.old_kodi_pl != kodi_pl:
for playqueue in PLAYQUEUES: if playqueue.id is None and (not state.DIRECT_PATHS or
kodi_pl = js.playlist_get_items(playqueue.playlistid) state.CONTEXT_MENU_PLAY):
if playqueue.old_kodi_pl != kodi_pl: # Only initialize if directly fired up using direct
if playqueue.id is None and (not state.DIRECT_PATHS or # paths. Otherwise let default.py do its magic
state.CONTEXT_MENU_PLAY): LOG.debug('Not yet initiating playback')
# Only initialize if directly fired up using direct elif playqueue.pkc_edit:
# paths. Otherwise let default.py do its magic playqueue.pkc_edit = False
LOG.debug('Not yet initiating playback') LOG.debug('PKC just edited the playqueue - skipping')
elif playqueue.pkc_edit: else:
playqueue.pkc_edit = False # compare old and new playqueue
LOG.debug('PKC edited the playqueue - skipping') self._compare_playqueues(playqueue, kodi_pl)
else: playqueue.old_kodi_pl = list(kodi_pl)
# We do need to update our playqueues
work.append((playqueue, kodi_pl))
playqueue.old_kodi_pl = kodi_pl
# Now do the work - LOCK individual playqueue edits
for playqueue, kodi_pl in work:
self._compare_playqueues(playqueue, kodi_pl)
sleep(200) sleep(200)
LOG.info("----===## PlayqueueMonitor stopped ##===----") LOG.info("----===## PlayqueueMonitor stopped ##===----")