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.
This commit is contained in:
Wim Taymans 2011-06-09 11:39:08 +02:00
parent 4a424c379f
commit d8212d941c
4 changed files with 18 additions and 53 deletions

View file

@ -3112,7 +3112,7 @@ no_iter:
typedef struct typedef struct
{ {
GstEvent *event; GstEvent *event;
gboolean res; gboolean result;
gboolean dispatched; gboolean dispatched;
} EventData; } 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", 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->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; data->dispatched = TRUE;
@ -3132,42 +3132,6 @@ event_forward_func (GstPad * pad, EventData * data)
return FALSE; return FALSE;
} }
/**
* 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: * gst_pad_event_default:
* @pad: a #GstPad to call the default event handler on. * @pad: a #GstPad to call the default event handler on.
@ -3188,7 +3152,8 @@ gst_pad_event_forward (GstPad * pad, GstEvent * event)
gboolean gboolean
gst_pad_event_default (GstPad * pad, GstEvent * event) 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 (GST_IS_PAD (pad), FALSE);
g_return_val_if_fail (event != NULL, FALSE); g_return_val_if_fail (event != NULL, FALSE);
@ -3202,19 +3167,23 @@ gst_pad_event_default (GstPad * pad, GstEvent * event)
gst_pad_pause_task (pad); gst_pad_pause_task (pad);
break; break;
} }
case GST_EVENT_CAPS:
{
/* don't forward by default */
forward = FALSE;
break;
}
default: default:
break; break;
} }
if (forward) data.event = event;
result = gst_pad_event_forward (pad, 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 else
result = TRUE;
gst_event_unref (event); gst_event_unref (event);
return result; return result;

View file

@ -892,7 +892,6 @@ GstFlowReturn gst_pad_pull_range (GstPad *pad, guint64 offset, guint size,
GstBuffer **buffer); GstBuffer **buffer);
gboolean gst_pad_push_event (GstPad *pad, GstEvent *event); gboolean gst_pad_push_event (GstPad *pad, GstEvent *event);
gboolean gst_pad_event_default (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 */ /* data passing functions on pad */
GstFlowReturn gst_pad_chain (GstPad *pad, GstBuffer *buffer); GstFlowReturn gst_pad_chain (GstPad *pad, GstBuffer *buffer);

View file

@ -538,7 +538,7 @@ gst_output_selector_handle_sink_event (GstPad * pad, GstEvent * event)
switch (sel->pad_negotiation_mode) { switch (sel->pad_negotiation_mode) {
case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL: case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL:
/* Send caps to all src pads */ /* Send caps to all src pads */
res = gst_pad_event_forward (pad, event); res = gst_pad_event_default (pad, event);
break; break;
case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE: case GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE:
gst_event_unref (event); gst_event_unref (event);

View file

@ -484,9 +484,6 @@ gst_tee_sink_event (GstPad * pad, GstEvent * event)
gboolean res; gboolean res;
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CAPS:
res = gst_pad_event_forward (pad, event);
break;
default: default:
res = gst_pad_event_default (pad, event); res = gst_pad_event_default (pad, event);
break; break;