From ad438461a603a81623d0f89b6cb94852e8879f05 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Thu, 20 Oct 2011 08:57:57 +0200 Subject: [PATCH] pad: not only describe conditions in the docs, also check them in the code When blocking pads, check if the pad is in the rigt direction. Log some info for the developer and return FALSE, instead of just locking up. --- gst/gstpad.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gst/gstpad.c b/gst/gstpad.c index a0040f8..01937e6 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1038,7 +1038,7 @@ gst_pad_is_active (GstPad * pad) * and sink pads in pull mode. * * - * Returns: TRUE if the pad could be blocked. This function can fail if the + * Returns: %TRUE if the pad could be blocked. This function can fail if the * wrong parameters were passed or the pad was already in the requested state. * * MT safe. @@ -1061,6 +1061,15 @@ gst_pad_set_blocked_async_full (GstPad * pad, gboolean blocked, if (G_UNLIKELY (was_blocked == blocked)) goto had_right_state; + if (G_UNLIKELY ( + (GST_PAD_ACTIVATE_MODE (pad) == GST_ACTIVATE_PUSH) && + (GST_PAD_DIRECTION (pad) != GST_PAD_SRC))) + goto wrong_direction; + if (G_UNLIKELY ( + (GST_PAD_ACTIVATE_MODE (pad) == GST_ACTIVATE_PULL) && + (GST_PAD_DIRECTION (pad) != GST_PAD_SINK))) + goto wrong_direction; + if (blocked) { GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "blocking pad"); @@ -1104,6 +1113,8 @@ gst_pad_set_blocked_async_full (GstPad * pad, gboolean blocked, return TRUE; +/* Errors */ + had_right_state: { GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, @@ -1112,6 +1123,14 @@ had_right_state: return FALSE; } +wrong_direction: + { + GST_CAT_INFO_OBJECT (GST_CAT_SCHEDULING, pad, "pad block on the wrong pad, " + "block src pads in push mode and sink pads in pull mode."); + GST_OBJECT_UNLOCK (pad); + + return FALSE; + } } /** -- 2.7.4