hc
2023-10-25 6c2073b7aa40e29d0eca7d571dd7bc590c7ecaa7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 60e9aef80e6b45de663884fc0f70902a21a73e87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= <scerveau@collabora.com>
Date: Mon, 9 Aug 2021 15:38:08 +0200
Subject: [PATCH 02/11] 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 bcbfc2045..3a441afa0 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;
@@ -3933,6 +3936,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);
@@ -3940,6 +3949,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
@@ -5515,6 +5525,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