From 6ea6f1545bd2322bc102fec4e72aee4d3ed06b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 14 Sep 2020 14:30:35 +0300 Subject: avauddec: Forward flow returns from draining instead of assuming OK It might be useful for upstream to know that draining/finishing didn't succeed, and why. Part-of: --- ext/libav/gstavauddec.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/ext/libav/gstavauddec.c b/ext/libav/gstavauddec.c index f43bfad..60d0c44 100644 --- a/ext/libav/gstavauddec.c +++ b/ext/libav/gstavauddec.c @@ -57,7 +57,7 @@ static GstFlowReturn gst_ffmpegauddec_handle_frame (GstAudioDecoder * decoder, static gboolean gst_ffmpegauddec_negotiate (GstFFMpegAudDec * ffmpegdec, AVCodecContext * context, AVFrame * frame, gboolean force); -static void gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec); +static GstFlowReturn gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec); #define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("avdec-params") @@ -594,9 +594,10 @@ no_codec: } } -static void +static GstFlowReturn gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec) { + GstFlowReturn ret = GST_FLOW_OK; gboolean got_any_frames = FALSE; gboolean got_frame; @@ -604,21 +605,22 @@ gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec) goto send_packet_failed; do { - GstFlowReturn ret; - got_frame = gst_ffmpegauddec_frame (ffmpegdec, &ret); if (got_frame) got_any_frames = TRUE; } while (got_frame); avcodec_flush_buffers (ffmpegdec->context); - if (got_any_frames) - gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), NULL, 1); + if (got_any_frames && ret == GST_FLOW_OK) + ret = + gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), NULL, 1); - return; +done: + return ret; send_packet_failed: GST_WARNING_OBJECT (ffmpegdec, "send packet failed, could not drain decoder"); + goto done; } static void @@ -651,8 +653,7 @@ gst_ffmpegauddec_handle_frame (GstAudioDecoder * decoder, GstBuffer * inbuf) goto not_negotiated; if (inbuf == NULL) { - gst_ffmpegauddec_drain (ffmpegdec); - return GST_FLOW_OK; + return gst_ffmpegauddec_drain (ffmpegdec); } inbuf = gst_buffer_ref (inbuf); -- cgit v1.2.1