From 809d9af8960f1ce49e7ab8c69da79b7645298939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 21 Nov 2025 18:18:49 +0100 Subject: [PATCH] clapper: Post playlist message before setting next URI Fixes a problem where error message from unplayable URI content (e.g. non-existing file) arrives on pipeline bus before resolved playlist which contains that URI. With this change, a playlist can be resolved into individual items which are put into queue even if first item of it is unplayable. --- src/lib/clapper/gst/clapper-playlist-demux.c | 26 +++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/lib/clapper/gst/clapper-playlist-demux.c b/src/lib/clapper/gst/clapper-playlist-demux.c index fb123240..dc83b161 100644 --- a/src/lib/clapper/gst/clapper-playlist-demux.c +++ b/src/lib/clapper/gst/clapper-playlist-demux.c @@ -309,16 +309,32 @@ _filter_playlistables (ClapperPlaylistDemux *self, GstCaps *caps, ClapperEnhance static inline gboolean _handle_playlist (ClapperPlaylistDemux *self, GListStore *playlist, GCancellable *cancellable) { - ClapperMediaItem *item = g_list_model_get_item (G_LIST_MODEL (playlist), 0); + ClapperMediaItem *item; + GstStructure *structure; const gchar *uri; gboolean success; + if (g_cancellable_is_cancelled (cancellable)) { + GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ, + ("Playlist parsing was cancelled"), (NULL)); + return FALSE; + } + + item = g_list_model_get_item (G_LIST_MODEL (playlist), 0); + if (G_UNLIKELY (item == NULL)) { GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ, ("This playlist appears to be empty"), (NULL)); return FALSE; } + /* Post playlist before setting an URI, so it arrives + * before eventual error (e.g. non-existing file) */ + structure = gst_structure_new ("ClapperPlaylistParsed", + "playlist", G_TYPE_LIST_STORE, playlist, NULL); + gst_element_post_message (GST_ELEMENT_CAST (self), + gst_message_new_element (GST_OBJECT_CAST (self), structure)); + uri = clapper_media_item_get_uri (item); success = clapper_uri_base_demux_set_uri (CLAPPER_URI_BASE_DEMUX_CAST (self), uri, NULL); gst_object_unref (item); @@ -329,14 +345,6 @@ _handle_playlist (ClapperPlaylistDemux *self, GListStore *playlist, GCancellable return FALSE; } - if (!g_cancellable_is_cancelled (cancellable)) { - GstStructure *structure = gst_structure_new ("ClapperPlaylistParsed", - "playlist", G_TYPE_LIST_STORE, playlist, NULL); - - gst_element_post_message (GST_ELEMENT_CAST (self), - gst_message_new_element (GST_OBJECT_CAST (self), structure)); - } - return TRUE; }