diff options
author | Jan Schmidt <thaytan@mad.scientist.com> | 2007-02-13 16:01:29 +0000 |
---|---|---|
committer | Jan Schmidt <thaytan@mad.scientist.com> | 2007-02-13 16:01:29 +0000 |
commit | b1aa8fef181a00cc6dc6fa38654ceb937cec3898 (patch) | |
tree | 9e22511ad16ba44c88d8335cdbc1d46418bd5398 /gst/autodetect/gstautoaudiosink.c | |
parent | 5116ff603e735bf5045db60df8025e4b824acb81 (diff) | |
download | gstreamer-plugins-good-b1aa8fef181a00cc6dc6fa38654ceb937cec3898.tar.gz |
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.
Diffstat (limited to 'gst/autodetect/gstautoaudiosink.c')
-rw-r--r-- | gst/autodetect/gstautoaudiosink.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/gst/autodetect/gstautoaudiosink.c b/gst/autodetect/gstautoaudiosink.c index ccaa413a1..379113aff 100644 --- a/gst/autodetect/gstautoaudiosink.c +++ b/gst/autodetect/gstautoaudiosink.c @@ -1,5 +1,6 @@ /* GStreamer * (c) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net> + * (c) 2006 Jan Schmidt <thaytan@noraisin.net> * * 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 <rbultje@ronald.bitfreak.net>"); + "Ronald Bultje <rbultje@ronald.bitfreak.net>\n" + "Jan Schmidt <thaytan@noraisin.net"); static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, @@ -77,13 +81,35 @@ gst_auto_audio_sink_base_init (gpointer klass) static void gst_auto_audio_sink_class_init (GstAutoAudioSinkClass * klass) { + GObjectClass *gobject_class; GstElementClass *eklass; + gobject_class = G_OBJECT_CLASS (klass); eklass = GST_ELEMENT_CLASS (klass); + gobject_class->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"); |