From a77fcb5d88102e0674add81df2d1a999b107a715 Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Sun, 25 Jan 2004 12:28:05 +0000 Subject: gst-libs/gst/play/gstplay.c: Another try in visualization implementation. Still have an issue with switch blocking wh... Original commit message from CVS: 2004-01-25 Julien MOUTTE * gst-libs/gst/play/gstplay.c: (gst_play_pipeline_setup), (gst_play_identity_handoff), (gst_play_set_location), (gst_play_set_visualization), (gst_play_connect_visualization): Another try in visualization implementation. Still have an issue with switch blocking when pulling from video_queue and only audio comes out of spider. * gst/switch/gstswitch.c: (gst_switch_release_pad), (gst_switch_poll_sinkpads), (gst_switch_class_init): Implementing pad release method. And check if the pad is usable before pulling. --- gst/switch/gstswitch.c | 71 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 14 deletions(-) (limited to 'gst/switch') diff --git a/gst/switch/gstswitch.c b/gst/switch/gstswitch.c index e68647cc..1c7feba6 100644 --- a/gst/switch/gstswitch.c +++ b/gst/switch/gstswitch.c @@ -54,6 +54,44 @@ static GstElementClass *parent_class = NULL; /* */ /* ============================================================= */ +static void +gst_switch_release_pad (GstElement *element, GstPad *pad) +{ + GList *sinkpads = NULL; + GstSwitch *gstswitch = NULL; + GstSwitchPad *switchpad = NULL; + + g_return_if_fail (GST_IS_SWITCH (element)); + + gstswitch = GST_SWITCH (element); + + sinkpads = gstswitch->sinkpads; + + /* Walking through our pad list searching for the pad we want to release */ + while (sinkpads) { + switchpad = sinkpads->data; + + if (switchpad && switchpad->sinkpad == pad) + break; + else + switchpad = NULL; + + sinkpads = g_list_next (sinkpads); + } + + /* Releasing the found pad */ + if (switchpad) { + if (!switchpad->forwarded && switchpad->data) + gst_data_unref (switchpad->data); + gst_element_remove_pad (element, pad); + gstswitch->sinkpads = g_list_remove (gstswitch->sinkpads, switchpad); + gstswitch->nb_sinkpads--; + if (gstswitch->active_sinkpad >= gstswitch->nb_sinkpads) + gstswitch->active_sinkpad = 0; + g_free (switchpad); + } +} + static GstPad* gst_switch_request_new_pad (GstElement *element, GstPadTemplate *templ, @@ -120,24 +158,28 @@ gst_switch_poll_sinkpads (GstSwitch *gstswitch) while (pads) { GstSwitchPad *switchpad = pads->data; - GstData *data = gst_pad_pull (switchpad->sinkpad); - if (GST_IS_EVENT (data) && - (GST_EVENT_TYPE (GST_EVENT (data)) == GST_EVENT_EOS)) { - /* If that data was not forwarded we unref it */ - if (!switchpad->forwarded && switchpad->data) { + GstData *data = NULL; + + /* If that data was not forwarded we unref it */ + if (!switchpad->forwarded && switchpad->data) { gst_data_unref (switchpad->data); switchpad->data = NULL; } - gst_event_unref (GST_EVENT (data)); - } - else { - /* If that data was not forwarded we unref it */ - if (!switchpad->forwarded && switchpad->data) { - gst_data_unref (switchpad->data); - switchpad->data = NULL; + + if (GST_PAD_IS_USABLE (switchpad->sinkpad)) { + data = gst_pad_pull (switchpad->sinkpad); + + if (GST_IS_EVENT (data) && + (GST_EVENT_TYPE (GST_EVENT (data)) == GST_EVENT_EOS)) { + gst_event_unref (GST_EVENT (data)); + } + else { + switchpad->data = data; + switchpad->forwarded = FALSE; } - switchpad->data = data; - switchpad->forwarded = FALSE; + } + else { + g_message ("not pulling from pad %s", gst_pad_get_name (switchpad->sinkpad)); } pads = g_list_next (pads); } @@ -298,6 +340,7 @@ gst_switch_class_init (GstSwitchClass *klass) gobject_class->get_property = gst_switch_get_property; gstelement_class->request_new_pad = gst_switch_request_new_pad; + gstelement_class->release_pad = gst_switch_release_pad; } /* ============================================================= */ -- cgit v1.2.1