From 5d8d5eb81d5130239de964dd5de42be07bc424e6 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 17 Dec 2007 14:52:14 +0000 Subject: gst/switch/gstswitch.c (gst_stream_selector_block): Implement the block() signal. This implementation will be replace... Original commit message from CVS: 2007-12-17 Andy Wingo * gst/switch/gstswitch.c (gst_stream_selector_block): Implement the block() signal. This implementation will be replaced in future patches, however. Patch 4/12. --- ChangeLog | 4 ++++ gst/switch/gstswitch.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7d485efe..5310be6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2007-12-17 Andy Wingo + * gst/switch/gstswitch.c (gst_stream_selector_block): Implement + the block() signal. This implementation will be replaced in future + patches, however. Patch 4/12. + * gst/switch/gstswitch.h (struct _GstStreamSelectorClass): Fix vmethod prototypes. diff --git a/gst/switch/gstswitch.c b/gst/switch/gstswitch.c index 269ac91e..fefdebac 100644 --- a/gst/switch/gstswitch.c +++ b/gst/switch/gstswitch.c @@ -721,10 +721,58 @@ gst_stream_selector_release_pad (GstElement * element, GstPad * pad) gst_element_remove_pad (GST_ELEMENT (sel), pad); } +static void +block_func (GstPad * pad, gboolean blocked, gpointer user_data) +{ + GST_DEBUG_OBJECT (pad, "got blocked = %d", blocked ? 1 : 0); +} + +static void +foreach_set_blocking (GstPad * pad, gpointer user_data) +{ + gboolean block = GPOINTER_TO_INT (user_data); + + gst_pad_set_blocked_async (pad, block, block_func, NULL); +} + +static gboolean +block_all_pads (GstStreamSelector * self, gboolean block) +{ + GstIterator *iter; + GstIteratorResult res; + + iter = gst_element_iterate_sink_pads (GST_ELEMENT (self)); + + while (TRUE) { + res = gst_iterator_foreach (iter, (GFunc) foreach_set_blocking, + GINT_TO_POINTER (block)); + switch (res) { + case GST_ITERATOR_RESYNC: + gst_iterator_resync (iter); + break; + case GST_ITERATOR_DONE: + goto done; + default: + goto error; + } + } + +done: + GST_DEBUG_OBJECT (self, "block_all_pads(%d) succeeded", block); + gst_iterator_free (iter); + return TRUE; + +error: + GST_WARNING_OBJECT (self, "block(%d) signal error: %d", block, res); + gst_iterator_free (iter); + return FALSE; +} + + static void gst_stream_selector_block (GstStreamSelector * self) { - return; + block_all_pads (self, TRUE); } static void -- cgit v1.2.1