From 0c72d0acdf2e4413288cf5e205b9ed2d9cc39363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 6 Apr 2015 19:20:00 -0700 Subject: [PATCH] {audio,video}decoder: Forward SEGMENT_DONE events immediately and drain decoders Otherwise we're going to wait with draining until the next data comes, which is a bit suboptimal and might take a long time... or maybe never happens. --- gst-libs/gst/audio/gstaudiodecoder.c | 12 ++++++++++++ gst-libs/gst/video/gstvideodecoder.c | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c index 36ba2a82c5..ba2ee47118 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.c +++ b/gst-libs/gst/audio/gstaudiodecoder.c @@ -2156,6 +2156,18 @@ gst_audio_decoder_sink_eventfunc (GstAudioDecoder * dec, GstEvent * event) ret = gst_audio_decoder_push_event (dec, event); break; + case GST_EVENT_SEGMENT_DONE: + GST_AUDIO_DECODER_STREAM_LOCK (dec); + gst_audio_decoder_drain (dec); + GST_AUDIO_DECODER_STREAM_UNLOCK (dec); + + /* Forward SEGMENT_DONE because no buffer or serialized event might come after + * SEGMENT_DONE and nothing could trigger another _finish_frame() call. */ + if (dec->priv->pending_events) + send_pending_events (dec); + ret = gst_audio_decoder_push_event (dec, event); + break; + case GST_EVENT_EOS: GST_AUDIO_DECODER_STREAM_LOCK (dec); gst_audio_decoder_drain (dec); diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index 3f30656079..05a57cb837 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -1071,6 +1071,25 @@ gst_video_decoder_sink_event_default (GstVideoDecoder * decoder, event = NULL; break; } + case GST_EVENT_SEGMENT_DONE: + { + GstFlowReturn flow_ret = GST_FLOW_OK; + + flow_ret = gst_video_decoder_drain_out (decoder, TRUE); + ret = (flow_ret == GST_FLOW_OK); + + /* Forward SEGMENT_DONE immediately. This is required + * because no buffer or serialized event might come + * after SEGMENT_DONE and nothing could trigger another + * _finish_frame() call. + * + * The subclass can override this behaviour by overriding + * the ::sink_event() vfunc and not chaining up to the + * parent class' ::sink_event() until a later time. + */ + forward_immediate = TRUE; + break; + } case GST_EVENT_EOS: { GstFlowReturn flow_ret = GST_FLOW_OK;