gst/gstpad.c: Some small cleanups. Improve debugging.

Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* gst/gstpad.c: (gst_pad_init), (pre_activate),
(gst_pad_set_blocked_async), (gst_pad_acceptcaps_default),
(gst_pad_accept_caps), (handle_pad_block), (gst_pad_push_event):
Some small cleanups. Improve debugging.
* gst/gstpad.h:
Signal all waiting threads with a broadcast instead of just one.
Fixes #369942.
This commit is contained in:
Mark Nauwelaerts 2006-11-03 13:57:28 +00:00 committed by Wim Taymans
parent 706d4bf73f
commit 6e0416787d
3 changed files with 43 additions and 14 deletions

View file

@ -1,3 +1,15 @@
2006-11-03 Wim Taymans <wim@fluendo.com>
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
* gst/gstpad.c: (gst_pad_init), (pre_activate),
(gst_pad_set_blocked_async), (gst_pad_acceptcaps_default),
(gst_pad_accept_caps), (handle_pad_block), (gst_pad_push_event):
Some small cleanups. Improve debugging.
* gst/gstpad.h:
Signal all waiting threads with a broadcast instead of just one.
Fixes #369942.
2006-11-03 Wim Taymans <wim@fluendo.com> 2006-11-03 Wim Taymans <wim@fluendo.com>
* plugins/elements/gstfdsrc.c: (gst_fd_src_update_fd), * plugins/elements/gstfdsrc.c: (gst_fd_src_update_fd),

View file

@ -352,8 +352,12 @@ gst_pad_init (GstPad * pad)
pad->do_buffer_signals = 0; pad->do_buffer_signals = 0;
pad->do_event_signals = 0; pad->do_event_signals = 0;
#if 0
GST_PAD_SET_FLUSHING (pad);
#else
/* FIXME, should be set flushing initially, see #339326 */ /* FIXME, should be set flushing initially, see #339326 */
GST_PAD_UNSET_FLUSHING (pad); GST_PAD_UNSET_FLUSHING (pad);
#endif
pad->preroll_lock = g_mutex_new (); pad->preroll_lock = g_mutex_new ();
pad->preroll_cond = g_cond_new (); pad->preroll_cond = g_cond_new ();
@ -578,7 +582,7 @@ pre_activate (GstPad * pad, GstActivateMode new_mode)
GST_DEBUG_OBJECT (pad, "setting ACTIVATE_MODE NONE, set flushing"); GST_DEBUG_OBJECT (pad, "setting ACTIVATE_MODE NONE, set flushing");
GST_PAD_SET_FLUSHING (pad); GST_PAD_SET_FLUSHING (pad);
/* unlock blocked pads so element can resume and stop */ /* unlock blocked pads so element can resume and stop */
GST_PAD_BLOCK_SIGNAL (pad); GST_PAD_BLOCK_BROADCAST (pad);
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
break; break;
} }
@ -977,10 +981,9 @@ gst_pad_set_blocked_async (GstPad * pad, gboolean blocked,
pad->block_callback = callback; pad->block_callback = callback;
pad->block_data = user_data; pad->block_data = user_data;
if (callback) { GST_PAD_BLOCK_BROADCAST (pad);
GST_PAD_BLOCK_SIGNAL (pad); if (!callback) {
} else { /* no callback, wait for the unblock to happen */
GST_PAD_BLOCK_SIGNAL (pad);
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "waiting for unblock"); GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "waiting for unblock");
GST_PAD_BLOCK_WAIT (pad); GST_PAD_BLOCK_WAIT (pad);
GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "unblocked"); GST_CAT_LOG_OBJECT (GST_CAT_SCHEDULING, pad, "unblocked");
@ -2169,16 +2172,26 @@ gst_pad_acceptcaps_default (GstPad * pad, GstCaps * caps)
gboolean result = FALSE; gboolean result = FALSE;
allowed = gst_pad_get_caps (pad); allowed = gst_pad_get_caps (pad);
if (allowed) { if (!allowed)
intersect = gst_caps_intersect (allowed, caps); goto nothing_allowed;
result = !gst_caps_is_empty (intersect); intersect = gst_caps_intersect (allowed, caps);
gst_caps_unref (allowed); result = !gst_caps_is_empty (intersect);
gst_caps_unref (intersect); if (!result)
} GST_DEBUG_OBJECT (pad, "intersection gave empty caps");
gst_caps_unref (allowed);
gst_caps_unref (intersect);
return result; return result;
/* ERRORS */
nothing_allowed:
{
GST_DEBUG_OBJECT (pad, "no caps allowed on the pad");
return FALSE;
}
} }
/** /**
@ -2217,14 +2230,17 @@ gst_pad_accept_caps (GstPad * pad, GstCaps * caps)
if (G_LIKELY (acceptfunc)) { if (G_LIKELY (acceptfunc)) {
/* we can call the function */ /* we can call the function */
result = acceptfunc (pad, caps); result = acceptfunc (pad, caps);
GST_DEBUG_OBJECT (pad, "acceptfunc returned %d", result);
} else { } else {
/* Only null if the element explicitly unset it */ /* Only null if the element explicitly unset it */
result = gst_pad_acceptcaps_default (pad, caps); result = gst_pad_acceptcaps_default (pad, caps);
GST_DEBUG_OBJECT (pad, "default acceptcaps returned %d", result);
} }
return result; return result;
is_same_caps: is_same_caps:
{ {
GST_DEBUG_OBJECT (pad, "pad had same caps");
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
return TRUE; return TRUE;
} }
@ -3252,7 +3268,7 @@ handle_pad_block (GstPad * pad)
} else { } else {
/* no callback, signal the thread that is doing a GCond wait /* no callback, signal the thread that is doing a GCond wait
* if any. */ * if any. */
GST_PAD_BLOCK_SIGNAL (pad); GST_PAD_BLOCK_BROADCAST (pad);
} }
/* OBJECT_LOCK could have been released when we did the callback, which /* OBJECT_LOCK could have been released when we did the callback, which
@ -3287,7 +3303,7 @@ handle_pad_block (GstPad * pad)
GST_OBJECT_LOCK (pad); GST_OBJECT_LOCK (pad);
} else { } else {
/* we need to signal the thread waiting on the GCond */ /* we need to signal the thread waiting on the GCond */
GST_PAD_BLOCK_SIGNAL (pad); GST_PAD_BLOCK_BROADCAST (pad);
} }
gst_object_unref (pad); gst_object_unref (pad);
@ -3879,7 +3895,7 @@ gst_pad_push_event (GstPad * pad, GstEvent * event)
* will typically unblock the STREAMING thread blocked on a pad. */ * will typically unblock the STREAMING thread blocked on a pad. */
GST_LOG_OBJECT (pad, "Pad is blocked, not forwarding flush-start, " GST_LOG_OBJECT (pad, "Pad is blocked, not forwarding flush-start, "
"doing block signal."); "doing block signal.");
GST_PAD_BLOCK_SIGNAL (pad); GST_PAD_BLOCK_BROADCAST (pad);
goto flushed; goto flushed;
} }
break; break;

View file

@ -730,6 +730,7 @@ struct _GstPadClass {
#define GST_PAD_BLOCK_GET_COND(pad) (GST_PAD_CAST(pad)->block_cond) #define GST_PAD_BLOCK_GET_COND(pad) (GST_PAD_CAST(pad)->block_cond)
#define GST_PAD_BLOCK_WAIT(pad) (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad))) #define GST_PAD_BLOCK_WAIT(pad) (g_cond_wait(GST_PAD_BLOCK_GET_COND (pad), GST_OBJECT_GET_LOCK (pad)))
#define GST_PAD_BLOCK_SIGNAL(pad) (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad))) #define GST_PAD_BLOCK_SIGNAL(pad) (g_cond_signal(GST_PAD_BLOCK_GET_COND (pad)))
#define GST_PAD_BLOCK_BROADCAST(pad) (g_cond_broadcast(GST_PAD_BLOCK_GET_COND (pad)))
/* FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h) */ /* FIXME: this awful circular dependency need to be resolved properly (see padtemplate.h) */
#include <gst/gstpadtemplate.h> #include <gst/gstpadtemplate.h>