gst/playback/gstplaybasebin.c: Don't hang forever if the subbin already fails to...
authorTim-Philipp Müller <tim@centricular.net>
Wed, 18 Oct 2006 09:31:49 +0000 (09:31 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Wed, 18 Oct 2006 09:31:49 +0000 (09:31 +0000)
Original commit message from CVS:
* gst/playback/gstplaybasebin.c: (setup_source):
Don't hang forever if the subbin already fails to start up in
the state change to PAUSED (#339366).

ChangeLog
gst/playback/gstplaybasebin.c

index 865ce3eff3856f01fe66260d5966e9afae531430..93f0edf07a32e61efc21215b70b909cdd74b4c32 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-10-18  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * gst/playback/gstplaybasebin.c: (setup_source):
+         Don't hang forever if the subbin already fails to start up in 
+         the state change to PAUSED (#339366).
+
 2006-10-17  Tim-Philipp Müller  <tim at centricular dot net>
 
        * gst-libs/gst/interfaces/tuner.c: (gst_tuner_list_channels),
index dcbb7f7c9eef2767586362bd3c17fb66a3a4f733..42bd66a7232fe8befe5bd047b61fd07ed6e1628a 100644 (file)
@@ -1835,6 +1835,8 @@ setup_source (GstPlayBaseBin * play_base_bin, gchar ** new_location)
     play_base_bin->pending++;
 
     if (!play_base_bin->is_stream) {
+      GstStateChangeReturn sret;
+
       /* either when the queues are filled or when the decoder element
        * has no more dynamic streams, the cond is unlocked. We can remove
        * the signal handlers then
@@ -1847,25 +1849,31 @@ setup_source (GstPlayBaseBin * play_base_bin, gchar ** new_location)
        * to commit the subtitle group using an extra flag. */
       play_base_bin->subtitle_done = FALSE;
 
-      gst_element_set_state (subbin, GST_STATE_PAUSED);
-
-      GROUP_LOCK (play_base_bin);
-      GST_DEBUG ("waiting for subtitle to complete...");
-      while (!play_base_bin->subtitle_done)
-        GROUP_WAIT (play_base_bin);
-      GST_DEBUG ("group done !");
-      GROUP_UNLOCK (play_base_bin);
-
-      if (!play_base_bin->building_group ||
-          play_base_bin->building_group->type[GST_STREAM_TYPE_TEXT - 1].npads ==
-          0) {
-
-        GST_DEBUG ("No subtitle found - ignoring");
+      sret = gst_element_set_state (subbin, GST_STATE_PAUSED);
+      if (sret != GST_STATE_CHANGE_FAILURE) {
+        GROUP_LOCK (play_base_bin);
+        GST_DEBUG ("waiting for subtitle to complete...");
+        while (!play_base_bin->subtitle_done)
+          GROUP_WAIT (play_base_bin);
+        GST_DEBUG ("group done !");
+        GROUP_UNLOCK (play_base_bin);
+
+        if (!play_base_bin->building_group ||
+            play_base_bin->building_group->type[GST_STREAM_TYPE_TEXT -
+                1].npads == 0) {
+
+          GST_DEBUG ("No subtitle found - ignoring");
+          gst_element_set_state (subbin, GST_STATE_NULL);
+          gst_object_unref (play_base_bin->subtitle);
+          play_base_bin->subtitle = NULL;
+        } else {
+          GST_DEBUG_OBJECT (play_base_bin, "Subtitle set-up successful");
+        }
+      } else {
+        GST_WARNING_OBJECT (play_base_bin, "Failed to start subtitle bin");
         gst_element_set_state (subbin, GST_STATE_NULL);
         gst_object_unref (play_base_bin->subtitle);
         play_base_bin->subtitle = NULL;
-      } else {
-        GST_DEBUG_OBJECT (play_base_bin, "Subtitle set-up successful");
       }
     }
   }