diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2013-12-30 10:01:39 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2013-12-30 10:53:09 +0100 |
commit | 901cd5560c4e4b483376d60b29c6aba27759f4a1 (patch) | |
tree | fd86038eb181606af5aa387a3badb6d78ddb1e96 /gst/gstpad.c | |
parent | e5067fd9aa3b2d7c9682b608e2c658f159f1c9cc (diff) |
pad: Don't ignore probe callback return value when immediately calling IDLE probe
https://bugzilla.gnome.org/show_bug.cgi?id=721096
Diffstat (limited to 'gst/gstpad.c')
-rw-r--r-- | gst/gstpad.c | 76 |
1 files changed, 50 insertions, 26 deletions
diff --git a/gst/gstpad.c b/gst/gstpad.c index f4b05e31c..77bea63fd 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1180,6 +1180,31 @@ gst_pad_is_active (GstPad * pad) return result; } +static void +cleanup_hook (GstPad * pad, GHook * hook) +{ + GstPadProbeType type; + + if (!G_HOOK_IS_VALID (hook)) + return; + + type = (hook->flags) >> G_HOOK_FLAG_USER_SHIFT; + + if (type & GST_PAD_PROBE_TYPE_BLOCKING) { + /* unblock when we remove the last blocking probe */ + pad->num_blocked--; + GST_DEBUG_OBJECT (pad, "remove blocking probe, now %d left", + pad->num_blocked); + if (pad->num_blocked == 0) { + GST_DEBUG_OBJECT (pad, "last blocking probe removed, unblocking"); + GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_BLOCKED); + GST_PAD_BLOCK_BROADCAST (pad); + } + } + g_hook_destroy_link (&pad->probes, hook); + pad->num_probes--; +} + /** * gst_pad_add_probe: * @pad: the #GstPad to add the probe to @@ -1261,13 +1286,37 @@ gst_pad_add_probe (GstPad * pad, GstPadProbeType mask, GST_OBJECT_UNLOCK (pad); } else { GstPadProbeInfo info = { GST_PAD_PROBE_TYPE_IDLE, res, }; + GstPadProbeReturn ret; /* the pad is idle now, we can signal the idle callback now */ GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "pad is idle, trigger idle callback"); GST_OBJECT_UNLOCK (pad); - callback (pad, &info, user_data); + ret = callback (pad, &info, user_data); + + GST_OBJECT_LOCK (pad); + switch (ret) { + case GST_PAD_PROBE_REMOVE: + /* remove the probe */ + GST_DEBUG_OBJECT (pad, "asked to remove hook"); + cleanup_hook (pad, hook); + res = 0; + break; + case GST_PAD_PROBE_DROP: + GST_DEBUG_OBJECT (pad, "asked to drop item"); + break; + case GST_PAD_PROBE_PASS: + GST_DEBUG_OBJECT (pad, "asked to pass item"); + break; + case GST_PAD_PROBE_OK: + GST_DEBUG_OBJECT (pad, "probe returned OK"); + break; + default: + GST_DEBUG_OBJECT (pad, "probe returned %d", ret); + break; + } + GST_OBJECT_UNLOCK (pad); } } else { GST_OBJECT_UNLOCK (pad); @@ -1275,31 +1324,6 @@ gst_pad_add_probe (GstPad * pad, GstPadProbeType mask, return res; } -static void -cleanup_hook (GstPad * pad, GHook * hook) -{ - GstPadProbeType type; - - if (!G_HOOK_IS_VALID (hook)) - return; - - type = (hook->flags) >> G_HOOK_FLAG_USER_SHIFT; - - if (type & GST_PAD_PROBE_TYPE_BLOCKING) { - /* unblock when we remove the last blocking probe */ - pad->num_blocked--; - GST_DEBUG_OBJECT (pad, "remove blocking probe, now %d left", - pad->num_blocked); - if (pad->num_blocked == 0) { - GST_DEBUG_OBJECT (pad, "last blocking probe removed, unblocking"); - GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_BLOCKED); - GST_PAD_BLOCK_BROADCAST (pad); - } - } - g_hook_destroy_link (&pad->probes, hook); - pad->num_probes--; -} - /** * gst_pad_remove_probe: * @pad: the #GstPad with the probe |