gst/playback/gstdecodebin.c: Make the window for a race in typefind and shutting...
authorWim Taymans <wim.taymans@gmail.com>
Tue, 16 Oct 2007 16:48:38 +0000 (16:48 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 16 Oct 2007 16:48:38 +0000 (16:48 +0000)
Original commit message from CVS:
* gst/playback/gstdecodebin.c: (new_pad), (type_found):
Make the window for a race in typefind and shutting down smaller until
we figure out the right locking here. Avoids #485753 usually.
* gst/playback/gstdecodebin2.c: (type_found), (pad_added_group_cb):
Remove unneeded lock causing a race in typefind and shutting down.
Fixes #485753.
* gst/playback/gstplaybin.c: (gst_play_bin_change_state):
Also remove sinks when going to NULL because we might not complete the
state change to PAUSED, causing the PAUSED->READY state change not to
happen.

ChangeLog
gst/playback/gstdecodebin.c
gst/playback/gstdecodebin2.c
gst/playback/gstplaybin.c

index 286a14a..e50b4ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2007-10-16  Wim Taymans  <wim.taymans@gmail.com>
 
+       * gst/playback/gstdecodebin.c: (new_pad), (type_found):
+       Make the window for a race in typefind and shutting down smaller until
+       we figure out the right locking here. Avoids #485753 usually.
+
+       * gst/playback/gstdecodebin2.c: (type_found), (pad_added_group_cb):
+       Remove unneeded lock causing a race in typefind and shutting down.
+       Fixes #485753.
+
+       * gst/playback/gstplaybin.c: (gst_play_bin_change_state):
+       Also remove sinks when going to NULL because we might not complete the
+       state change to PAUSED, causing the PAUSED->READY state change not to
+       happen.
+
+2007-10-16  Wim Taymans  <wim.taymans@gmail.com>
+
        * gst-libs/gst/audio/gstbaseaudiosink.c:
        (gst_base_audio_sink_drain), (gst_base_audio_sink_change_state):
        Also explicitly release the ringbuffer when going to NULL because it
index 68228db..b3f4bee 100644 (file)
@@ -1261,11 +1261,13 @@ new_pad (GstElement * element, GstPad * pad, GstDynamic * dynamic)
 
 shutting_down1:
   {
+    GST_DEBUG_OBJECT (decode_bin, "we are shutting down");
     GST_OBJECT_UNLOCK (decode_bin);
     return;
   }
 shutting_down2:
   {
+    GST_DEBUG_OBJECT (decode_bin, "we are shutting down");
     GST_STATE_UNLOCK (decode_bin);
     return;
   }
@@ -1537,6 +1539,13 @@ type_found (GstElement * typefind, guint probability, GstCaps * caps,
   gboolean dynamic;
   GstPad *pad;
 
+  GST_DEBUG_OBJECT (decode_bin, "typefind found caps %" GST_PTR_FORMAT, caps);
+
+  GST_OBJECT_LOCK (decode_bin);
+  if (decode_bin->shutting_down)
+    goto shutting_down;
+  GST_OBJECT_UNLOCK (decode_bin);
+
   GST_STATE_LOCK (decode_bin);
   if (decode_bin->shutting_down)
     goto exit;
@@ -1548,8 +1557,6 @@ type_found (GstElement * typefind, guint probability, GstCaps * caps,
 
   decode_bin->have_type = TRUE;
 
-  GST_DEBUG_OBJECT (decode_bin, "typefind found caps %" GST_PTR_FORMAT, caps);
-
   /* special-case text/plain: we only want to accept it as a raw type if it
    * comes from a subtitel parser element or a demuxer, but not if it is the
    * type of the entire stream, in which case we just want to error out */
@@ -1582,6 +1589,13 @@ type_found (GstElement * typefind, guint probability, GstCaps * caps,
 exit:
   GST_STATE_UNLOCK (decode_bin);
   return;
+
+shutting_down:
+  {
+    GST_DEBUG_OBJECT (decode_bin, "we are shutting down");
+    GST_OBJECT_UNLOCK (decode_bin);
+    return;
+  }
 }
 
 static void
index c403f41..f66eb74 100644 (file)
@@ -1143,8 +1143,6 @@ type_found (GstElement * typefind, guint probability,
 {
   GstPad *pad;
 
-  GST_STATE_LOCK (decode_bin);
-
   GST_DEBUG_OBJECT (decode_bin, "typefind found caps %" GST_PTR_FORMAT, caps);
 
   /* we can only deal with one type, we don't yet support dynamically changing
@@ -1161,7 +1159,6 @@ type_found (GstElement * typefind, guint probability,
   gst_object_unref (pad);
 
 exit:
-  GST_STATE_UNLOCK (decode_bin);
   return;
 }
 
@@ -1184,6 +1181,7 @@ pad_added_group_cb (GstElement * element, GstPad * pad, GstDecodeGroup * group)
   if (group->nbdynamic == 0)
     expose = TRUE;
   GROUP_MUTEX_UNLOCK (group);
+
   if (expose) {
     GST_LOG
         ("That was the last dynamic object, now attempting to expose the group");
index 794c406..209bec9 100644 (file)
@@ -1812,6 +1812,7 @@ gst_play_bin_change_state (GstElement * element, GstStateChange transition)
       /* FIXME Release audio device when we implement that */
       break;
     case GST_STATE_CHANGE_PAUSED_TO_READY:
+    case GST_STATE_CHANGE_READY_TO_NULL:
       /* remove sinks we added */
       remove_sinks (play_bin);
       /* and there might be a fakesink we need to clean up now */