summaryrefslogtreecommitdiff
path: root/gst/adder
diff options
context:
space:
mode:
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2011-12-16 17:32:41 +0000
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2011-12-16 20:12:01 +0000
commit85c10b0b24a58c1b5ec9aa05ea4ffa98ba99ed76 (patch)
tree7e2363dae62626a3384bb276b7ea464b650600c0 /gst/adder
parent1da30adc1aeafd36b15b8d083fe2178524619479 (diff)
adder: do not send too many flush-stop events
GstCollectPads2 now allows us to override the event function, so we can withhold flush stop events if none are to be sent. https://bugzilla.gnome.org/show_bug.cgi?id=666379
Diffstat (limited to 'gst/adder')
-rw-r--r--gst/adder/gstadder.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c
index 2661febe0..356cb5a0f 100644
--- a/gst/adder/gstadder.c
+++ b/gst/adder/gstadder.c
@@ -141,6 +141,8 @@ static GstFlowReturn gst_adder_do_clip (GstCollectPads2 * pads,
gpointer user_data);
static GstFlowReturn gst_adder_collected (GstCollectPads2 * pads,
gpointer user_data);
+static gboolean gst_adder_event (GstCollectPads2 * pads, GstCollectData2 * pad,
+ GstEvent * event, gpointer user_data);
/* non-clipping versions (for float) */
#define MAKE_FUNC_NC(name,type) \
@@ -750,16 +752,14 @@ gst_adder_sink_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_STOP:
- /* we received a flush-stop. The collect_event function will push the
- * event past our element. We simply forward all flush-stop events, even
- * when no flush-stop was pending, this is required because collectpads2
- * does not provide an API to handle-but-not-forward the flush-stop.
- * We unset the pending flush-stop flag so that we don't send anymore
- * flush-stop from the collect function later.
+ /* we received a flush-stop. The collect_event function will call the
+ * gst_adder_event function we have set on the GstCollectPads2, so we
+ * have control over whether the event is sent past our element.
+ * We will only forward it when flush_stop_pending is set, and we will
+ * unset it then.
*/
GST_COLLECT_PADS2_STREAM_LOCK (adder->collect);
g_atomic_int_set (&adder->new_segment_pending, TRUE);
- g_atomic_int_set (&adder->flush_stop_pending, FALSE);
/* Clear pending tags */
if (adder->pending_events) {
g_list_foreach (adder->pending_events, (GFunc) gst_event_unref, NULL);
@@ -868,6 +868,8 @@ gst_adder_init (GstAdder * adder, GstAdderClass * klass)
GST_DEBUG_FUNCPTR (gst_adder_collected), adder);
gst_collect_pads2_set_clip_function (adder->collect,
GST_DEBUG_FUNCPTR (gst_adder_do_clip), adder);
+ gst_collect_pads2_set_event_function (adder->collect,
+ GST_DEBUG_FUNCPTR (gst_adder_event), adder);
}
static void
@@ -1270,6 +1272,24 @@ eos:
}
}
+static gboolean
+gst_adder_event (GstCollectPads2 * pads, GstCollectData2 * pad,
+ GstEvent * event, gpointer user_data)
+{
+ GstAdder *adder = GST_ADDER (user_data);
+ if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP) {
+ if (g_atomic_int_compare_and_exchange (&adder->flush_stop_pending,
+ TRUE, FALSE)) {
+ return FALSE;
+ } else {
+ gst_event_unref (event);
+ return TRUE;
+ }
+ } else {
+ return FALSE;
+ }
+}
+
static GstStateChangeReturn
gst_adder_change_state (GstElement * element, GstStateChange transition)
{