decodebin: guard against the decode chain going while a pad is added

https://bugzilla.gnome.org/show_bug.cgi?id=741355
This commit is contained in:
Vincent Penquerc'h 2015-02-04 11:46:09 +00:00
parent 9036dc8594
commit a848ac7abe

View File

@ -1800,9 +1800,11 @@ discarded_type:
/* Try to expose anything */ /* Try to expose anything */
EXPOSE_LOCK (dbin); EXPOSE_LOCK (dbin);
if (dbin->decode_chain) {
if (gst_decode_chain_is_complete (dbin->decode_chain)) { if (gst_decode_chain_is_complete (dbin->decode_chain)) {
gst_decode_bin_expose (dbin); gst_decode_bin_expose (dbin);
} }
}
EXPOSE_UNLOCK (dbin); EXPOSE_UNLOCK (dbin);
do_async_done (dbin); do_async_done (dbin);
@ -1826,9 +1828,11 @@ unknown_type:
/* Try to expose anything */ /* Try to expose anything */
EXPOSE_LOCK (dbin); EXPOSE_LOCK (dbin);
if (dbin->decode_chain) {
if (gst_decode_chain_is_complete (dbin->decode_chain)) { if (gst_decode_chain_is_complete (dbin->decode_chain)) {
gst_decode_bin_expose (dbin); gst_decode_bin_expose (dbin);
} }
}
EXPOSE_UNLOCK (dbin); EXPOSE_UNLOCK (dbin);
if (src == dbin->typefind) { if (src == dbin->typefind) {
@ -2686,9 +2690,11 @@ expose_pad (GstDecodeBin * dbin, GstElement * src, GstDecodePad * dpad,
chain->endcaps = gst_caps_ref (caps); chain->endcaps = gst_caps_ref (caps);
EXPOSE_LOCK (dbin); EXPOSE_LOCK (dbin);
if (dbin->decode_chain) {
if (gst_decode_chain_is_complete (dbin->decode_chain)) { if (gst_decode_chain_is_complete (dbin->decode_chain)) {
gst_decode_bin_expose (dbin); gst_decode_bin_expose (dbin);
} }
}
EXPOSE_UNLOCK (dbin); EXPOSE_UNLOCK (dbin);
if (mqpad) if (mqpad)
@ -2802,6 +2808,7 @@ pad_event_cb (GstPad * pad, GstPadProbeInfo * info, gpointer data)
/* we don't set the endcaps because NULL endcaps means early EOS */ /* we don't set the endcaps because NULL endcaps means early EOS */
EXPOSE_LOCK (dbin); EXPOSE_LOCK (dbin);
if (dbin->decode_chain)
if (gst_decode_chain_is_complete (dbin->decode_chain)) if (gst_decode_chain_is_complete (dbin->decode_chain))
gst_decode_bin_expose (dbin); gst_decode_bin_expose (dbin);
EXPOSE_UNLOCK (dbin); EXPOSE_UNLOCK (dbin);
@ -2828,12 +2835,16 @@ pad_added_cb (GstElement * element, GstPad * pad, GstDecodeChain * chain)
gst_caps_unref (caps); gst_caps_unref (caps);
EXPOSE_LOCK (dbin); EXPOSE_LOCK (dbin);
if (dbin->decode_chain) {
if (gst_decode_chain_is_complete (dbin->decode_chain)) { if (gst_decode_chain_is_complete (dbin->decode_chain)) {
GST_LOG_OBJECT (dbin, GST_LOG_OBJECT (dbin,
"That was the last dynamic object, now attempting to expose the group"); "That was the last dynamic object, now attempting to expose the group");
if (!gst_decode_bin_expose (dbin)) if (!gst_decode_bin_expose (dbin))
GST_WARNING_OBJECT (dbin, "Couldn't expose group"); GST_WARNING_OBJECT (dbin, "Couldn't expose group");
} }
} else {
GST_DEBUG_OBJECT (dbin, "No decode chain, new pad ignored");
}
EXPOSE_UNLOCK (dbin); EXPOSE_UNLOCK (dbin);
} }
@ -2910,9 +2921,11 @@ no_more_pads_cb (GstElement * element, GstDecodeChain * chain)
CHAIN_MUTEX_UNLOCK (chain); CHAIN_MUTEX_UNLOCK (chain);
EXPOSE_LOCK (chain->dbin); EXPOSE_LOCK (chain->dbin);
if (chain->dbin->decode_chain) {
if (gst_decode_chain_is_complete (chain->dbin->decode_chain)) { if (gst_decode_chain_is_complete (chain->dbin->decode_chain)) {
gst_decode_bin_expose (chain->dbin); gst_decode_bin_expose (chain->dbin);
} }
}
EXPOSE_UNLOCK (chain->dbin); EXPOSE_UNLOCK (chain->dbin);
} }
@ -3047,10 +3060,14 @@ gst_decode_bin_reset_buffering (GstDecodeBin * dbin)
return; return;
GST_DEBUG_OBJECT (dbin, "Reseting multiqueues buffering"); GST_DEBUG_OBJECT (dbin, "Reseting multiqueues buffering");
EXPOSE_LOCK (dbin);
if (dbin->decode_chain) {
CHAIN_MUTEX_LOCK (dbin->decode_chain); CHAIN_MUTEX_LOCK (dbin->decode_chain);
gst_decode_chain_reset_buffering (dbin->decode_chain); gst_decode_chain_reset_buffering (dbin->decode_chain);
CHAIN_MUTEX_UNLOCK (dbin->decode_chain); CHAIN_MUTEX_UNLOCK (dbin->decode_chain);
} }
EXPOSE_UNLOCK (dbin);
}
/**** /****
* GstDecodeChain functions * GstDecodeChain functions
@ -3336,10 +3353,12 @@ multi_queue_overrun_cb (GstElement * queue, GstDecodeGroup * group)
*/ */
EXPOSE_LOCK (dbin); EXPOSE_LOCK (dbin);
if (dbin->decode_chain) {
if (gst_decode_chain_is_complete (dbin->decode_chain)) { if (gst_decode_chain_is_complete (dbin->decode_chain)) {
if (!gst_decode_bin_expose (dbin)) if (!gst_decode_bin_expose (dbin))
GST_WARNING_OBJECT (dbin, "Couldn't expose group"); GST_WARNING_OBJECT (dbin, "Couldn't expose group");
} }
}
EXPOSE_UNLOCK (dbin); EXPOSE_UNLOCK (dbin);
} }
@ -3872,16 +3891,18 @@ gst_decode_pad_handle_eos (GstDecodePad * pad)
GstDecodeBin *dbin = chain->dbin; GstDecodeBin *dbin = chain->dbin;
GST_LOG_OBJECT (dbin, "pad %p", pad); GST_LOG_OBJECT (dbin, "pad %p", pad);
EXPOSE_LOCK (dbin);
drain_and_switch_chains (dbin->decode_chain, pad, &last_group, &drained, drain_and_switch_chains (dbin->decode_chain, pad, &last_group, &drained,
&switched); &switched);
if (switched) { if (switched) {
/* If we resulted in a group switch, expose what's needed */ /* If we resulted in a group switch, expose what's needed */
EXPOSE_LOCK (dbin); if (dbin->decode_chain) {
if (gst_decode_chain_is_complete (dbin->decode_chain)) if (gst_decode_chain_is_complete (dbin->decode_chain))
gst_decode_bin_expose (dbin); gst_decode_bin_expose (dbin);
EXPOSE_UNLOCK (dbin);
} }
}
EXPOSE_UNLOCK (dbin);
return last_group; return last_group;
} }
@ -4562,10 +4583,12 @@ source_pad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
dpad->blocked = TRUE; dpad->blocked = TRUE;
EXPOSE_LOCK (dbin); EXPOSE_LOCK (dbin);
if (dbin->decode_chain) {
if (gst_decode_chain_is_complete (dbin->decode_chain)) { if (gst_decode_chain_is_complete (dbin->decode_chain)) {
if (!gst_decode_bin_expose (dbin)) if (!gst_decode_bin_expose (dbin))
GST_WARNING_OBJECT (dbin, "Couldn't expose group"); GST_WARNING_OBJECT (dbin, "Couldn't expose group");
} }
}
EXPOSE_UNLOCK (dbin); EXPOSE_UNLOCK (dbin);
done: done: