From 2d57bec92047feef06c317733e375c4bffbbb74b Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 18 Dec 2023 09:23:14 +0100 Subject: [PATCH] decodebin3: Don't send sticky events to unlinked decoder This causes a lot of nasty side effects (like decoders assuming they are actually linked downstream). The reason why this was done was to check whether a decoder could handle the actual caps, but this is the wrong way to do it. The proper way to query whether a decoder can handle certain caps is via `GST_QUERY_ACCEPT_CAPS` which is already done just before. Partially reverts !4677 and partially fixes #3160 Part-of: --- .../gst/playback/gstdecodebin3.c | 45 +------------------ 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c b/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c index 396a1aeabf..974180b8bd 100644 --- a/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c +++ b/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c @@ -899,37 +899,6 @@ decode_pad_set_target (GstGhostPad * pad, GstPad * target) return res; } -typedef struct -{ - gboolean ret; - GstPad *peer; -} SendStickyEventsData; - -static gboolean -send_sticky_event (GstPad * pad, GstEvent ** event, gpointer user_data) -{ - SendStickyEventsData *data = user_data; - - data->ret &= gst_pad_send_event (data->peer, gst_event_ref (*event)); - - return data->ret; -} - -static gboolean -send_sticky_events (GstDecodebin3 * dbin, GstPad * pad) -{ - SendStickyEventsData data; - - data.ret = TRUE; - data.peer = gst_pad_get_peer (pad); - - gst_pad_sticky_events_foreach (pad, send_sticky_event, &data); - - gst_object_unref (data.peer); - - return data.ret; -} - static CandidateDecoder * add_candidate_decoder (GstDecodebin3 * dbin, GstElement * element) { @@ -3008,24 +2977,14 @@ reconfigure_output_stream (DecodebinOutputStream * output, goto try_next; } - /* First lock element's sinkpad stream lock so no data reaches - * the possible new element added when caps are sent by element - * while we're still sending sticky events */ - GST_PAD_STREAM_LOCK (output->decoder_sink); - if (gst_element_set_state (output->decoder, - GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE || - !send_sticky_events (dbin, slot->src_pad)) { - - GST_PAD_STREAM_UNLOCK (output->decoder_sink); - GST_WARNING_OBJECT (dbin, - "Decoder '%s' failed to reach PAUSED state", + GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) { + GST_WARNING_OBJECT (dbin, "Decoder '%s' failed to reach PAUSED state", GST_ELEMENT_NAME (output->decoder)); decoder_failed = TRUE; goto try_next; } else { /* Everything went well */ - GST_PAD_STREAM_UNLOCK (output->decoder_sink); output->linked = TRUE; GST_DEBUG ("created decoder %" GST_PTR_FORMAT, output->decoder);