1From 77af65033203b49b23640f856df964e7a6b5868b Mon Sep 17 00:00:00 2001 2From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= <scerveau@collabora.com> 3Date: Mon, 9 Aug 2021 15:38:08 +0200 4Subject: [PATCH 02/11] playbin2: send one about-to-finish per group 5 6To avoid multiple about-to-finish signal, 7driving the app to drop uris, a group should 8signal "about-to-finish" and setup a next uri 9only one time. 10 11Fixes #930 12--- 13 gst/playback/gstplaybin2.c | 11 +++++++++++ 14 1 file changed, 11 insertions(+) 15 16diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c 17index bcbfc20..3a441af 100644 18--- a/gst/playback/gstplaybin2.c 19+++ b/gst/playback/gstplaybin2.c 20@@ -319,6 +319,9 @@ struct _GstSourceGroup 21 GstElement *video_sink; 22 GstElement *text_sink; 23 24+ /* Avoid multiple about to finish handling */ 25+ gboolean pending_about_to_finish; 26+ 27 /* uridecodebins for uri and subtitle uri */ 28 GstElement *uridecodebin; 29 GstElement *suburidecodebin; 30@@ -3933,6 +3936,12 @@ drained_cb (GstElement * decodebin, GstSourceGroup * group) 31 32 GST_DEBUG_OBJECT (playbin, "about to finish in group %p", group); 33 34+ if (group->pending_about_to_finish) { 35+ GST_DEBUG_OBJECT (playbin, 36+ "Pending about to finish for group uri %s, do not handle.", group->uri); 37+ return; 38+ } 39+ 40 /* after this call, we should have a next group to activate or we EOS */ 41 g_signal_emit (G_OBJECT (playbin), 42 gst_play_bin_signals[SIGNAL_ABOUT_TO_FINISH], 0, NULL); 43@@ -3940,6 +3949,7 @@ drained_cb (GstElement * decodebin, GstSourceGroup * group) 44 /* now activate the next group. If the app did not set a uri, this will 45 * fail and we can do EOS */ 46 setup_next_source (playbin, GST_STATE_PAUSED); 47+ group->pending_about_to_finish = TRUE; 48 } 49 50 /* Like gst_element_factory_can_sink_any_caps() but doesn't 51@@ -5515,6 +5525,7 @@ activate_group (GstPlayBin * playbin, GstSourceGroup * group, GstState target) 52 /* allow state changes of the playbin affect the group elements now */ 53 group_set_locked_state_unlocked (playbin, group, FALSE); 54 group->active = TRUE; 55+ group->pending_about_to_finish = FALSE; 56 GST_SOURCE_GROUP_UNLOCK (group); 57 58 return state_ret; 59-- 602.20.1 61 62