diff -r 71e347f905f2 -r 4a7fac7dd34a gst_plugins_good/gst/autodetect/gstautoaudiosink.c --- a/gst_plugins_good/gst/autodetect/gstautoaudiosink.c Fri Mar 19 09:35:09 2010 +0200 +++ b/gst_plugins_good/gst/autodetect/gstautoaudiosink.c Fri Apr 16 15:15:52 2010 +0300 @@ -22,19 +22,16 @@ * SECTION:element-autoaudiosink * @see_also: autovideosink, alsasink, osssink * - * - * * autoaudiosink is an audio sink that automatically detects an appropriate * audio sink to use. It does so by scanning the registry for all elements * that have Sink and Audio in the class field * of their element information, and also have a non-zero autoplugging rank. - * + * + * * Example launch line - * - * + * |[ * gst-launch -v -m audiotestsrc ! audioconvert ! audioresample ! autoaudiosink - * - * + * ]| * */ @@ -71,7 +68,7 @@ "Sink/Audio", "Wrapper audio sink for automatically detected audio sink", "Ronald Bultje \n" - "Jan Schmidt "); static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, @@ -161,7 +158,7 @@ gst_bin_add (GST_BIN (sink), sink->kid); /* pad */ - targetpad = gst_element_get_pad (sink->kid, "sink"); + targetpad = gst_element_get_static_pad (sink->kid, "sink"); gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad); gst_object_unref (targetpad); } @@ -349,9 +346,8 @@ /* find element */ GST_DEBUG_OBJECT (sink, "Creating new kid"); - if (!(esink = gst_auto_audio_sink_find_best (sink))) { - return FALSE; - } + if (!(esink = gst_auto_audio_sink_find_best (sink))) + goto no_sink; sink->kid = esink; /* Ensure the child is brought up to the right state to match the parent @@ -364,12 +360,29 @@ /* attach ghost pad */ GST_DEBUG_OBJECT (sink, "Re-assigning ghostpad"); - targetpad = gst_element_get_pad (sink->kid, "sink"); - gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad); + targetpad = gst_element_get_static_pad (sink->kid, "sink"); + if (!gst_ghost_pad_set_target (GST_GHOST_PAD (sink->pad), targetpad)) + goto target_failed; + gst_object_unref (targetpad); GST_DEBUG_OBJECT (sink, "done changing auto audio sink"); return TRUE; + + /* ERRORS */ +no_sink: + { + GST_ELEMENT_ERROR (sink, LIBRARY, INIT, (NULL), + ("Failed to find a supported audio sink")); + return FALSE; + } +target_failed: + { + GST_ELEMENT_ERROR (sink, LIBRARY, INIT, (NULL), + ("Failed to set target pad")); + gst_object_unref (targetpad); + return FALSE; + } } static GstStateChangeReturn