From b1aa8fef181a00cc6dc6fa38654ceb937cec3898 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Tue, 13 Feb 2007 16:01:29 +0000 Subject: Re-factor the gconfaudiosink into a "GstSwitchSink" base class and a child that implements the GConf key monitoring. ... Original commit message from CVS: * ext/gconf/Makefile.am: * ext/gconf/gconf.c: (gst_gconf_get_string), (gst_gconf_get_key_for_sink_profile), (gst_gconf_set_string), (gst_gconf_render_bin_with_default): * ext/gconf/gconf.h: * ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_base_init), (gst_gconf_audio_sink_reset), (gst_gconf_audio_sink_init), (gst_gconf_audio_sink_dispose), (do_change_child), (gst_gconf_switch_profile), (gst_gconf_audio_sink_set_property), (cb_change_child), (gst_gconf_audio_sink_change_state): * ext/gconf/gstgconfaudiosink.h: * ext/gconf/gstswitchsink.c: (gst_switch_sink_base_init), (gst_switch_sink_class_init), (gst_switch_sink_reset), (gst_switch_sink_init), (gst_switch_sink_dispose), (gst_switch_commit_new_kid), (gst_switch_sink_set_child), (gst_switch_sink_set_property), (gst_switch_sink_handle_event), (gst_switch_sink_get_property), (gst_switch_sink_change_state): * ext/gconf/gstswitchsink.h: * gst/autodetect/gstautoaudiosink.c: (gst_auto_audio_sink_class_init), (gst_auto_audio_sink_dispose), (gst_auto_audio_sink_clear_kid), (gst_auto_audio_sink_reset), (gst_auto_audio_sink_detect): * gst/autodetect/gstautovideosink.c: (gst_auto_video_sink_class_init), (gst_auto_video_sink_dispose), (gst_auto_video_sink_clear_kid), (gst_auto_video_sink_reset), (gst_auto_video_sink_detect): Re-factor the gconfaudiosink into a "GstSwitchSink" base class and a child that implements the GConf key monitoring. The end goal of this is an audio sink that can be changed on the fly, but at the moment it still only changes on the next READY transition. --- gst/autodetect/gstautoaudiosink.c | 40 ++++++++++++++++++++++++++++---------- gst/autodetect/gstautovideosink.c | 41 +++++++++++++++++++++++++++++---------- 2 files changed, 61 insertions(+), 20 deletions(-) (limited to 'gst/autodetect') diff --git a/gst/autodetect/gstautoaudiosink.c b/gst/autodetect/gstautoaudiosink.c index ccaa413a..379113af 100644 --- a/gst/autodetect/gstautoaudiosink.c +++ b/gst/autodetect/gstautoaudiosink.c @@ -1,5 +1,6 @@ /* GStreamer * (c) 2005 Ronald S. Bultje + * (c) 2006 Jan Schmidt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -49,6 +50,8 @@ static GstStateChangeReturn gst_auto_audio_sink_change_state (GstElement * element, GstStateChange transition); +static void gst_auto_audio_sink_dispose (GstAutoAudioSink * sink); +static void gst_auto_audio_sink_clear_kid (GstAutoAudioSink * sink); GST_BOILERPLATE (GstAutoAudioSink, gst_auto_audio_sink, GstBin, GST_TYPE_BIN); @@ -56,7 +59,8 @@ static const GstElementDetails gst_auto_audio_sink_details = GST_ELEMENT_DETAILS ("Auto audio sink", "Sink/Audio", "Wrapper audio sink for automatically detected audio sink", - "Ronald Bultje "); + "Ronald Bultje \n" + "Jan Schmidt dispose = + (GObjectFinalizeFunc) GST_DEBUG_FUNCPTR (gst_auto_audio_sink_dispose); eklass->change_state = GST_DEBUG_FUNCPTR (gst_auto_audio_sink_change_state); } +static void +gst_auto_audio_sink_dispose (GstAutoAudioSink * sink) +{ + gst_auto_audio_sink_clear_kid (sink); + + G_OBJECT_CLASS (parent_class)->dispose ((GObject *) sink); +} + +static void +gst_auto_audio_sink_clear_kid (GstAutoAudioSink * sink) +{ + if (sink->kid) { + gst_element_set_state (sink->kid, GST_STATE_NULL); + gst_bin_remove (GST_BIN (sink), sink->kid); + sink->kid = NULL; + } +} + /* * Hack to make initial linking work; ideally, this'd work even when * no target has been assigned to the ghostpad yet. @@ -94,11 +120,9 @@ gst_auto_audio_sink_reset (GstAutoAudioSink * sink) { GstPad *targetpad; + gst_auto_audio_sink_clear_kid (sink); + /* fakesink placeholder */ - if (sink->kid) { - gst_element_set_state (sink->kid, GST_STATE_NULL); - gst_bin_remove (GST_BIN (sink), sink->kid); - } sink->kid = gst_element_factory_make ("fakesink", "tempsink"); gst_bin_add (GST_BIN (sink), sink->kid); @@ -258,11 +282,7 @@ gst_auto_audio_sink_detect (GstAutoAudioSink * sink) GstElement *esink; GstPad *targetpad; - if (sink->kid) { - gst_element_set_state (sink->kid, GST_STATE_NULL); - gst_bin_remove (GST_BIN (sink), sink->kid); - sink->kid = NULL; - } + gst_auto_audio_sink_clear_kid (sink); /* find element */ GST_DEBUG_OBJECT (sink, "Creating new kid"); diff --git a/gst/autodetect/gstautovideosink.c b/gst/autodetect/gstautovideosink.c index 085dea1b..0e0bc7ec 100644 --- a/gst/autodetect/gstautovideosink.c +++ b/gst/autodetect/gstautovideosink.c @@ -1,5 +1,6 @@ /* GStreamer * (c) 2005 Ronald S. Bultje + * (c) 2006 Jan Schmidt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -49,6 +50,8 @@ static GstStateChangeReturn gst_auto_video_sink_change_state (GstElement * element, GstStateChange transition); +static void gst_auto_video_sink_dispose (GstAutoVideoSink * sink); +static void gst_auto_video_sink_clear_kid (GstAutoVideoSink * sink); GST_BOILERPLATE (GstAutoVideoSink, gst_auto_video_sink, GstBin, GST_TYPE_BIN); @@ -56,7 +59,8 @@ static const GstElementDetails gst_auto_video_sink_details = GST_ELEMENT_DETAILS ("Auto video sink", "Sink/Video", "Wrapper video sink for automatically detected video sink", - "Ronald Bultje "); + "Ronald Bultje \n" + "Jan Schmidt dispose = + (GObjectFinalizeFunc) GST_DEBUG_FUNCPTR (gst_auto_video_sink_dispose); eklass->change_state = GST_DEBUG_FUNCPTR (gst_auto_video_sink_change_state); } +static void +gst_auto_video_sink_dispose (GstAutoVideoSink * sink) +{ + gst_auto_video_sink_clear_kid (sink); + + G_OBJECT_CLASS (parent_class)->dispose ((GObject *) sink); +} + +static void +gst_auto_video_sink_clear_kid (GstAutoVideoSink * sink) +{ + if (sink->kid) { + gst_element_set_state (sink->kid, GST_STATE_NULL); + gst_bin_remove (GST_BIN (sink), sink->kid); + sink->kid = NULL; + } +} + /* * Hack to make initial linking work; ideally, this'd work even when * no target has been assigned to the ghostpad yet. @@ -91,11 +117,10 @@ gst_auto_video_sink_reset (GstAutoVideoSink * sink) { GstPad *targetpad; + /* Remove any existing element */ + gst_auto_video_sink_clear_kid (sink); + /* fakesink placeholder */ - if (sink->kid) { - gst_element_set_state (sink->kid, GST_STATE_NULL); - gst_bin_remove (GST_BIN (sink), sink->kid); - } sink->kid = gst_element_factory_make ("fakesink", "tempsink"); gst_bin_add (GST_BIN (sink), sink->kid); @@ -204,11 +229,7 @@ gst_auto_video_sink_detect (GstAutoVideoSink * sink) GstElement *esink; GstPad *targetpad; - if (sink->kid) { - gst_element_set_state (sink->kid, GST_STATE_NULL); - gst_bin_remove (GST_BIN (sink), sink->kid); - sink->kid = NULL; - } + gst_auto_video_sink_clear_kid (sink); /* find element */ GST_DEBUG_OBJECT (sink, "Creating new kid"); -- cgit