summaryrefslogtreecommitdiff
path: root/gst/gstpad.c
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2014-08-06 10:32:39 +0100
committerTim-Philipp Müller <tim@centricular.com>2015-04-03 00:07:26 +0100
commit5deb4f658e1673c38364fc6277a4e26df5a60609 (patch)
tree35912c43625fa8917104be419cfae33ad929664f /gst/gstpad.c
parent518babf6cb6f71b2704a4b420804322cfa1dda54 (diff)
pad: allow probes to remove the data item whilst returning PROBE_OK
Use case: we want to block the source pad of a leaky queue and drop the buffer that causes the block. If we return PROBE_DROP then the buffer gets dropped, but we get called again. If we return PROBE_OK we can't easily drop the buffer. If we just replace the item into the GstPadProbeInfo structure with NULL, GStreamer will push a NULL buffer to the next element when we unblock the pad probe. This patch ensures it doesn't do that. https://bugzilla.gnome.org/show_bug.cgi?id=734342
Diffstat (limited to 'gst/gstpad.c')
-rw-r--r--gst/gstpad.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gst/gstpad.c b/gst/gstpad.c
index f0eea1490..f42a0f94f 100644
--- a/gst/gstpad.c
+++ b/gst/gstpad.c
@@ -3270,6 +3270,7 @@ probe_hook_marshal (GHook * hook, ProbeMarshall * data)
GstPadProbeType type, flags;
GstPadProbeCallback callback;
GstPadProbeReturn ret;
+ gpointer original_data;
/* if we have called this callback, do nothing */
if (PROBE_COOKIE (hook) == data->cookie) {
@@ -3283,6 +3284,7 @@ probe_hook_marshal (GHook * hook, ProbeMarshall * data)
flags = hook->flags >> G_HOOK_FLAG_USER_SHIFT;
type = info->type;
+ original_data = info->data;
/* one of the data types for non-idle probes */
if ((type & GST_PAD_PROBE_TYPE_IDLE) == 0
@@ -3321,6 +3323,12 @@ probe_hook_marshal (GHook * hook, ProbeMarshall * data)
GST_OBJECT_LOCK (pad);
+ if (original_data != NULL && info->data == NULL) {
+ GST_DEBUG_OBJECT (pad, "data item in pad probe info was dropped");
+ info->type = GST_PAD_PROBE_TYPE_INVALID;
+ data->dropped = TRUE;
+ }
+
switch (ret) {
case GST_PAD_PROBE_REMOVE:
/* remove the probe */
@@ -4265,7 +4273,8 @@ probe_stopped:
GST_OBJECT_UNLOCK (pad);
pad->ABI.abi.last_flowret =
ret == GST_FLOW_CUSTOM_SUCCESS ? GST_FLOW_OK : ret;
- gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
+ if (data != NULL)
+ gst_mini_object_unref (GST_MINI_OBJECT_CAST (data));
switch (ret) {
case GST_FLOW_CUSTOM_SUCCESS: