From d33d2be0ed160ffe7bf369b85e924c0adf8d5bc6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 16 Oct 2007 16:48:38 +0000 Subject: [PATCH] gst/playback/gstdecodebin.c: Make the window for a race in typefind and shutting down smaller until we figure out the... 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 | 15 +++++++++++++++ gst/playback/gstdecodebin.c | 18 ++++++++++++++++-- gst/playback/gstdecodebin2.c | 4 +--- gst/playback/gstplaybin.c | 1 + 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 286a14a..e50b4ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2007-10-16 Wim Taymans + * 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 + * 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 diff --git a/gst/playback/gstdecodebin.c b/gst/playback/gstdecodebin.c index 68228db..b3f4bee 100644 --- a/gst/playback/gstdecodebin.c +++ b/gst/playback/gstdecodebin.c @@ -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 diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index c403f41..f66eb74 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -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"); diff --git a/gst/playback/gstplaybin.c b/gst/playback/gstplaybin.c index 794c406..209bec9 100644 --- a/gst/playback/gstplaybin.c +++ b/gst/playback/gstplaybin.c @@ -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 */ -- 2.7.4