diff options
Diffstat (limited to 'gst/autodetect/gstautovideosink.c')
-rw-r--r-- | gst/autodetect/gstautovideosink.c | 41 |
1 files changed, 31 insertions, 10 deletions
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 <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_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 <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, @@ -76,11 +80,33 @@ gst_auto_video_sink_base_init (gpointer klass) static void gst_auto_video_sink_class_init (GstAutoVideoSinkClass * klass) { + GObjectClass *gobject_class; GstElementClass *eklass = GST_ELEMENT_CLASS (klass); + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->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"); |