From f5a7369700483aa741cdc62807d5ae3050016113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Mon, 9 Aug 2021 15:38:08 +0200 Subject: [PATCH 02/14] playbin2: send one about-to-finish per group To avoid multiple about-to-finish signal, driving the app to drop uris, a group should signal "about-to-finish" and setup a next uri only one time. Fixes #930 --- gst/playback/gstplaybin2.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index d6aff0c..51751ff 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -319,6 +319,9 @@ struct _GstSourceGroup GstElement *video_sink; GstElement *text_sink; + /* Avoid multiple about to finish handling */ + gboolean pending_about_to_finish; + /* uridecodebins for uri and subtitle uri */ GstElement *uridecodebin; GstElement *suburidecodebin; @@ -3913,6 +3916,12 @@ drained_cb (GstElement * decodebin, GstSourceGroup * group) GST_DEBUG_OBJECT (playbin, "about to finish in group %p", group); + if (group->pending_about_to_finish) { + GST_DEBUG_OBJECT (playbin, + "Pending about to finish for group uri %s, do not handle.", group->uri); + return; + } + /* after this call, we should have a next group to activate or we EOS */ g_signal_emit (G_OBJECT (playbin), gst_play_bin_signals[SIGNAL_ABOUT_TO_FINISH], 0, NULL); @@ -3920,6 +3929,7 @@ drained_cb (GstElement * decodebin, GstSourceGroup * group) /* now activate the next group. If the app did not set a uri, this will * fail and we can do EOS */ setup_next_source (playbin, GST_STATE_PAUSED); + group->pending_about_to_finish = TRUE; } /* Like gst_element_factory_can_sink_any_caps() but doesn't @@ -5495,6 +5505,7 @@ activate_group (GstPlayBin * playbin, GstSourceGroup * group, GstState target) /* allow state changes of the playbin affect the group elements now */ group_set_locked_state_unlocked (playbin, group, FALSE); group->active = TRUE; + group->pending_about_to_finish = FALSE; GST_SOURCE_GROUP_UNLOCK (group); return state_ret; -- 2.20.1