gst/autodetect/: Set state of elements to NULL before removing from bins.
authorMichael Smith <msmith@xiph.org>
Tue, 4 Oct 2005 17:58:40 +0000 (17:58 +0000)
committerMichael Smith <msmith@xiph.org>
Tue, 4 Oct 2005 17:58:40 +0000 (17:58 +0000)
Original commit message from CVS:
* gst/autodetect/gstautoaudiosink.c: (gst_auto_audio_sink_reset),
(gst_auto_audio_sink_find_best), (gst_auto_audio_sink_detect):
* gst/autodetect/gstautovideosink.c: (gst_auto_video_sink_reset),
(gst_auto_video_sink_find_best), (gst_auto_video_sink_detect):
Set state of elements to NULL before removing from bins.
Set state of test element to NULL if we failed to move it to READY

ChangeLog
gst/autodetect/gstautoaudiosink.c
gst/autodetect/gstautovideosink.c

index 65b8319..4159fd8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-10-04  Michael Smith <msmith@fluendo.com>
+
+       * gst/autodetect/gstautoaudiosink.c: (gst_auto_audio_sink_reset),
+       (gst_auto_audio_sink_find_best), (gst_auto_audio_sink_detect):
+       * gst/autodetect/gstautovideosink.c: (gst_auto_video_sink_reset),
+       (gst_auto_video_sink_find_best), (gst_auto_video_sink_detect):
+         Set state of elements to NULL before removing from bins.
+         Set state of test element to NULL if we failed to move it to READY
+
 2005-10-04  Edward Hervey  <edward@fluendo.com>
 
        * ext/dv/Makefile.am:
index a7b522a..0bbf63a 100644 (file)
@@ -72,6 +72,7 @@ gst_auto_audio_sink_reset (GstAutoAudioSink * 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");
@@ -179,6 +180,8 @@ gst_auto_audio_sink_find_best (GstAutoAudioSink * sink)
             GST_LOG ("This worked!");
             choice = el;
             goto done;
+          } else {
+            gst_element_set_state (el, GST_STATE_NULL);
           }
         }
 
@@ -205,6 +208,7 @@ gst_auto_audio_sink_detect (GstAutoAudioSink * sink)
   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;
   }
index ad355b5..3df9009 100644 (file)
@@ -72,6 +72,7 @@ gst_auto_video_sink_reset (GstAutoVideoSink * 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");
@@ -145,13 +146,22 @@ gst_auto_video_sink_find_best (GstAutoVideoSink * sink)
 
     GST_DEBUG_OBJECT (sink, "Trying %s", GST_PLUGIN_FEATURE (f)->name);
     if ((el = gst_element_factory_create (f, "actual-sink"))) {
+      GstStateChangeReturn ret;
+
       GST_DEBUG_OBJECT (sink, "Changing state to READY");
-      if (gst_element_set_state (el,
-              GST_STATE_READY) == GST_STATE_CHANGE_SUCCESS) {
+
+      ret = gst_element_set_state (el, GST_STATE_READY);
+      if (ret == GST_STATE_CHANGE_SUCCESS) {
         GST_DEBUG_OBJECT (sink, "success");
         return el;
       }
 
+      GST_WARNING_OBJECT (sink, "Couldn't set READY: %d", ret);
+      ret = gst_element_set_state (el, GST_STATE_NULL);
+      if (ret != GST_STATE_CHANGE_SUCCESS)
+        GST_WARNING_OBJECT (sink,
+            "Couldn't set element to NULL prior to disposal.");
+
       gst_object_unref (GST_OBJECT (el));
     }
   }
@@ -166,6 +176,7 @@ gst_auto_video_sink_detect (GstAutoVideoSink * sink)
   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;
   }