[media.vlc] Prevent deadlock on media.vlc.quit.

`_on_stop_event` may be set by the callback, but then cleared again when
`_reset_state` is called.

This can result in the `_on_stop_event.wait` call in `quit` to time out.

Instead, `_on_stop_event` should be cleared only when the player goes
into `playing` or `paused` mode. It's only then that we know for sure
that the state isn't `stopped`, and only in that case it makes sense to
wait for a stop.
This commit is contained in:
Fabio Manganiello 2024-08-19 02:02:21 +02:00
parent 6e27c9b8e4
commit 2b48edfabc
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -126,7 +126,6 @@ class MediaVlcPlugin(MediaPlugin):
def _reset_state(self):
self._latest_seek = None
self._on_stop_event.clear()
if self._latest_resource:
self.logger.debug('Closing latest resource')
@ -175,8 +174,10 @@ class MediaVlcPlugin(MediaPlugin):
self.logger.debug('Received VLC event: %s', event.type)
if event.type == EventType.MediaPlayerPlaying: # type: ignore
self._on_stop_event.clear()
self._post_event(MediaPlayEvent, resource=self._get_current_resource())
elif event.type == EventType.MediaPlayerPaused: # type: ignore
self._on_stop_event.clear()
self._post_event(MediaPauseEvent)
elif event.type in (
EventType.MediaPlayerStopped, # type: ignore