summaryrefslogtreecommitdiffstats
path: root/gst/switch/gstswitch.c
diff options
context:
space:
mode:
authorJulien Moutte <julien@moutte.net>2004-01-25 12:28:05 +0000
committerJulien Moutte <julien@moutte.net>2004-01-25 12:28:05 +0000
commita77fcb5d88102e0674add81df2d1a999b107a715 (patch)
treee3d5c9d394a8e6a379dca23b757aefe918887f78 /gst/switch/gstswitch.c
parent1f4616059c73850ea00c9703162446fb98ff2313 (diff)
downloadgst-plugins-bad-a77fcb5d88102e0674add81df2d1a999b107a715.tar.gz
gst-plugins-bad-a77fcb5d88102e0674add81df2d1a999b107a715.tar.bz2
gst-plugins-bad-a77fcb5d88102e0674add81df2d1a999b107a715.zip
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 <julien@moutte.net> * 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.
Diffstat (limited to 'gst/switch/gstswitch.c')
-rw-r--r--gst/switch/gstswitch.c71
1 files changed, 57 insertions, 14 deletions
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;
}
/* ============================================================= */