From d8212d941c070bbd0c5d805ef1cf7b53d4ab3178 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 9 Jun 2011 11:39:08 +0200 Subject: [PATCH] pad: forward events by default Always forward all events in the default handler. Previously it used to not forward caps events by default. It makes more sense to forward the caps events, if the element is interested in the caps, it will implement an event handler to retrieve the caps and then it can decide to forward or not. If the element has no event handler, it probably just doesn't care about caps and it probably is also not going to modify the data in a way that needs a caps change. --- gst/gstpad.c | 65 ++++++++++-------------------------- gst/gstpad.h | 1 - plugins/elements/gstoutputselector.c | 2 +- plugins/elements/gsttee.c | 3 -- 4 files changed, 18 insertions(+), 53 deletions(-) diff --git a/gst/gstpad.c b/gst/gstpad.c index 0cea4be..c595101 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -3112,7 +3112,7 @@ no_iter: typedef struct { GstEvent *event; - gboolean res; + gboolean result; gboolean dispatched; } EventData; @@ -3124,7 +3124,7 @@ event_forward_func (GstPad * pad, EventData * data) GST_LOG_OBJECT (pad, "Reffing and pushing event %p (%s) to %s:%s", data->event, GST_EVENT_TYPE_NAME (data->event), GST_DEBUG_PAD_NAME (pad)); - data->res |= gst_pad_push_event (pad, gst_event_ref (data->event)); + data->result |= gst_pad_push_event (pad, gst_event_ref (data->event)); data->dispatched = TRUE; @@ -3133,42 +3133,6 @@ event_forward_func (GstPad * pad, EventData * data) } /** - * gst_pad_event_forward: - * @pad: a #GstPad - * @event: (transfer full): the #GstEvent to handle. - * - * Forward @event to all internally linked pads of @pad. This function takes - * ownership of @event. - * - * Returns: TRUE if the event was sent succesfully. - */ -gboolean -gst_pad_event_forward (GstPad * pad, GstEvent * event) -{ - gboolean res; - EventData data; - - g_return_val_if_fail (GST_IS_PAD (pad), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - data.event = event; - data.res = FALSE; - - gst_pad_forward (pad, (GstPadForwardFunction) event_forward_func, &data); - - gst_event_unref (event); - - /* for sinkpads without a parent element or without internal links, nothing - * will be dispatched but we still want to return TRUE. */ - if (data.dispatched) - res = data.res; - else - res = TRUE; - - return res; -} - -/** * gst_pad_event_default: * @pad: a #GstPad to call the default event handler on. * @event: (transfer full): the #GstEvent to handle. @@ -3188,7 +3152,8 @@ gst_pad_event_forward (GstPad * pad, GstEvent * event) gboolean gst_pad_event_default (GstPad * pad, GstEvent * event) { - gboolean result = TRUE, forward = TRUE; + gboolean result; + EventData data; g_return_val_if_fail (GST_IS_PAD (pad), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -3202,20 +3167,24 @@ gst_pad_event_default (GstPad * pad, GstEvent * event) gst_pad_pause_task (pad); break; } - case GST_EVENT_CAPS: - { - /* don't forward by default */ - forward = FALSE; - break; - } default: break; } - if (forward) - result = gst_pad_event_forward (pad, event); + data.event = event; + data.dispatched = FALSE; + data.result = FALSE; + + gst_pad_forward (pad, (GstPadForwardFunction) event_forward_func, &data); + + /* for sinkpads without a parent element or without internal links, nothing + * will be dispatched but we still want to return TRUE. */ + if (data.dispatched) + result = data.result; else - gst_event_unref (event); + result = TRUE; + + gst_event_unref (event); return result; } diff --git a/gst/gstpad.h b/gst/gstpad.h index 0225228..a4358db 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -892,7 +892,6 @@ GstFlowReturn gst_pad_pull_range (GstPad *pad, guint64 offset, guint size, GstBuffer **buffer); gboolean gst_pad_push_event (GstPad *pad, GstEvent *event); gboolean gst_pad_event_default (GstPad *pad, GstEvent *event); -gboolean gst_pad_event_forward (GstPad *pad, GstEvent *event); /* data passing functions on pad */ GstFlowReturn gst_pad_chain (GstPad *pad, GstBuffer *buffer); diff --git a/plugins/elements/gstoutputselector.c b/plugins/elements/gstoutputselector.c index e8536be..2db7660 100644 --- a/plugins/elements/gstoutputselector.c +++ b/plugins/elements/gstoutputselector.c @@ -538,7 +538,7 @@ gst_output_selector_handle_sink_event (GstPad * pad, GstEvent * event) switch (sel->pad_negotiation_mode) { case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL: /* Send caps to all src pads */ - res = gst_pad_event_forward (pad, event); + res = gst_pad_event_default (pad, event); break; case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE: gst_event_unref (event); diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index 3de6878..56a5613 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -484,9 +484,6 @@ gst_tee_sink_event (GstPad * pad, GstEvent * event) gboolean res; switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_CAPS: - res = gst_pad_event_forward (pad, event); - break; default: res = gst_pad_event_default (pad, event); break; -- 2.7.4