gst_plugins_good/gst/autodetect/gstautoaudiosink.c
changeset 16 8e837d1bf446
parent 2 5505e8908944
--- a/gst_plugins_good/gst/autodetect/gstautoaudiosink.c	Wed Mar 24 17:58:42 2010 -0500
+++ b/gst_plugins_good/gst/autodetect/gstautoaudiosink.c	Wed Mar 24 18:04:17 2010 -0500
@@ -22,19 +22,16 @@
  * SECTION:element-autoaudiosink
  * @see_also: autovideosink, alsasink, osssink
  *
- * <refsect2>
- * <para>
  * 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 <quote>Sink</quote> and <quote>Audio</quote> in the class field
  * of their element information, and also have a non-zero autoplugging rank.
- * </para>
+ *
+ * <refsect2>
  * <title>Example launch line</title>
- * <para>
- * <programlisting>
+ * |[
  * gst-launch -v -m audiotestsrc ! audioconvert ! audioresample ! autoaudiosink
- * </programlisting>
- * </para>
+ * ]|
  * </refsect2>
  */
 
@@ -71,7 +68,7 @@
     "Sink/Audio",
     "Wrapper audio sink for automatically detected audio sink",
     "Ronald Bultje <rbultje@ronald.bitfreak.net>\n"
-    "Jan Schmidt <thaytan@noraisin.net");
+    "Jan Schmidt <thaytan@noraisin.net>");
 
 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