From b6fbeb8fedaabe8768ae390edcc0099ba7750514 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 4 Nov 2011 18:19:14 +0100 Subject: [PATCH] pad: make probes work on all pads fixes #644907 --- docs/design/part-probes.txt | 68 ++++++++++++++++++++----------------- gst/gstpad.c | 39 +++++++++++++++------ 2 files changed, 65 insertions(+), 42 deletions(-) diff --git a/docs/design/part-probes.txt b/docs/design/part-probes.txt index eb04e2d811..7e01176e69 100644 --- a/docs/design/part-probes.txt +++ b/docs/design/part-probes.txt @@ -174,6 +174,8 @@ The push dataflow probe behavior is the same for buffers and biderectional event O flushing? O O WRONG_STATE O O< - - - - - - - - - - - - - - -O + O O-> do BLOCK probes + O O O O-> do DATA probes O O O O---> chainfunc / @@ -204,36 +206,38 @@ was an error. It there is a valid DATA item, the DATA probes are called for the item. - srcpad sinkpad - | | - | | gst_pad_pull_range() - | O<--------------------- - | O - | O flushing? - | O WRONG_STATE - | O - - - - - - - - - - > - | do BLOCK probes <-O - | O no peer? - | O NOT_LINKED - | O - - - - - - - - - - > - | gst_pad_get_range() O - O<------------------------------O - O O - O flushing? O - O WRONG_STATE O - O- - - - - - - - - - - - - - - >O - getrangefunc <---O O - O flow error? O - O- - - - - - - - - - - - - - - >O - O O - do DATA probes <-O O - O- - - - - - - - - - - - - - - >O - | O - | do IDLE probes <-O - | O flow error? - | O - - - - - - - - - - > - | O - | do DATA probes <-O - | O - - - - - - - - - - > - | | + srcpad sinkpad + | | + | | gst_pad_pull_range() + | O<--------------------- + | O + | O flushing? + | O WRONG_STATE + | O - - - - - - - - - - > + | do BLOCK probes <-O + | O no peer? + | O NOT_LINKED + | O - - - - - - - - - - > + | gst_pad_get_range() O + O<------------------------------O + O O + O flushing? O + O WRONG_STATE O + O- - - - - - - - - - - - - - - >O + do BLOCK probes <-O O + O O + getrangefunc <---O O + O flow error? O + O- - - - - - - - - - - - - - - >O + O O + do DATA probes <-O O + O- - - - - - - - - - - - - - - >O + | O + | do IDLE probes <-O + | O flow error? + | O - - - - - - - - - - > + | O + | do DATA probes <-O + | O - - - - - - - - - - > + | | diff --git a/gst/gstpad.c b/gst/gstpad.c index ea5464ef45..0da7515c39 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -3615,7 +3615,9 @@ gst_pad_chain_data_unchecked (GstPad * pad, GstPadProbeType type, void *data) goto events_error; } - PROBE (pad, GST_PAD_PROBE_TYPE_PUSH | type, data, probe_stopped); + PROBE (pad, type | GST_PAD_PROBE_TYPE_BLOCK, data, probe_stopped); + + PROBE (pad, type, data, probe_stopped); GST_OBJECT_UNLOCK (pad); @@ -3741,7 +3743,8 @@ gst_pad_chain (GstPad * pad, GstBuffer * buffer) g_return_val_if_fail (GST_PAD_IS_SINK (pad), GST_FLOW_ERROR); g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR); - return gst_pad_chain_data_unchecked (pad, GST_PAD_PROBE_TYPE_BUFFER, buffer); + return gst_pad_chain_data_unchecked (pad, + GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_PUSH, buffer); } static GstFlowReturn @@ -3759,7 +3762,8 @@ gst_pad_chain_list_default (GstPad * pad, GstBufferList * list) for (i = 0; i < len; i++) { buffer = gst_buffer_list_get (list, i); ret = - gst_pad_chain_data_unchecked (pad, GST_PAD_PROBE_TYPE_BUFFER, + gst_pad_chain_data_unchecked (pad, + GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_PUSH, gst_buffer_ref (buffer)); if (ret != GST_FLOW_OK) break; @@ -3803,8 +3807,8 @@ gst_pad_chain_list (GstPad * pad, GstBufferList * list) g_return_val_if_fail (GST_PAD_IS_SINK (pad), GST_FLOW_ERROR); g_return_val_if_fail (GST_IS_BUFFER_LIST (list), GST_FLOW_ERROR); - return gst_pad_chain_data_unchecked (pad, GST_PAD_PROBE_TYPE_BUFFER_LIST, - list); + return gst_pad_chain_data_unchecked (pad, + GST_PAD_PROBE_TYPE_BUFFER_LIST | GST_PAD_PROBE_TYPE_PUSH, list); } static GstFlowReturn @@ -3817,8 +3821,6 @@ gst_pad_push_data (GstPad * pad, GstPadProbeType type, void *data) if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad))) goto flushing; - type |= GST_PAD_PROBE_TYPE_PUSH; - /* do block probes */ PROBE (pad, type | GST_PAD_PROBE_TYPE_BLOCK, data, probe_stopped); @@ -3913,7 +3915,8 @@ gst_pad_push (GstPad * pad, GstBuffer * buffer) g_return_val_if_fail (GST_PAD_IS_SRC (pad), GST_FLOW_ERROR); g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR); - return gst_pad_push_data (pad, GST_PAD_PROBE_TYPE_BUFFER, buffer); + return gst_pad_push_data (pad, + GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_PUSH, buffer); } /** @@ -3949,7 +3952,8 @@ gst_pad_push_list (GstPad * pad, GstBufferList * list) g_return_val_if_fail (GST_PAD_IS_SRC (pad), GST_FLOW_ERROR); g_return_val_if_fail (GST_IS_BUFFER_LIST (list), GST_FLOW_ERROR); - return gst_pad_push_data (pad, GST_PAD_PROBE_TYPE_BUFFER_LIST, list); + return gst_pad_push_data (pad, + GST_PAD_PROBE_TYPE_BUFFER_LIST | GST_PAD_PROBE_TYPE_PUSH, list); } static GstFlowReturn @@ -3964,6 +3968,9 @@ gst_pad_get_range_unchecked (GstPad * pad, guint64 offset, guint size, GST_OBJECT_LOCK (pad); if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad))) goto flushing; + + PROBE (pad, GST_PAD_PROBE_TYPE_PULL | GST_PAD_PROBE_TYPE_BLOCK, NULL, + probe_stopped); GST_OBJECT_UNLOCK (pad); if (G_UNLIKELY ((getrangefunc = GST_PAD_GETRANGEFUNC (pad)) == NULL)) @@ -3982,7 +3989,7 @@ gst_pad_get_range_unchecked (GstPad * pad, guint64 offset, guint size, /* can only fire the signal if we have a valid buffer */ GST_OBJECT_LOCK (pad); PROBE (pad, GST_PAD_PROBE_TYPE_PULL | GST_PAD_PROBE_TYPE_BUFFER, *buffer, - probe_stopped); + probe_stopped_unref); GST_OBJECT_UNLOCK (pad); GST_PAD_STREAM_UNLOCK (pad); @@ -4007,6 +4014,14 @@ no_function: return GST_FLOW_NOT_SUPPORTED; } probe_stopped: + { + GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, + "probe returned %s", gst_flow_get_name (ret)); + GST_OBJECT_UNLOCK (pad); + GST_PAD_STREAM_UNLOCK (pad); + return ret; + } +probe_stopped_unref: { GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "probe returned %s", gst_flow_get_name (ret)); @@ -4529,6 +4544,10 @@ gst_pad_send_event (GstPad * pad, GstEvent * event) if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad))) goto flushing; + PROBE (pad, + GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_EVENT | + GST_PAD_PROBE_TYPE_BLOCK, event, probe_stopped); + PROBE (pad, GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_EVENT, event, probe_stopped);