[media.vlc] Fixed a non-easily reproducible deadlock.

The VLC event callback handler shouldn't try and access the media and/or
the MRL while processing a `MediaPlayerTitleChanged` event.

It seems that in some particular streaming cases (mostly reproducible
with Jellyfin media URLs) this may result in deadlocks - probably
because the media metadata is being handled within the HTTP request, and
the callback handler runs within the same context.
This commit is contained in:
Fabio Manganiello 2024-10-21 21:09:21 +02:00
parent 8fa2080652
commit 89bcdbe1ac
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -205,7 +205,14 @@ class MediaVlcPlugin(MediaPlugin):
self.logger.debug('Received VLC event: %s', event.type) self.logger.debug('Received VLC event: %s', event.type)
playing_url = None playing_url = None
if self._player: if (
self._player
and
# Avoid a weird deadlock when trying to get the media URL and
# we are processing a MediaPlayerTitleChanged event (probably
# because the media metadata is being updated)
event.type != EventType.MediaPlayerTitleChanged # type: ignore
):
media = self._player.get_media() media = self._player.get_media()
playing_url = media.get_mrl() if media else None playing_url = media.get_mrl() if media else None