diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2020-09-14 14:30:35 +0300 |
---|---|---|
committer | Seungha Yang <seungha@centricular.com> | 2020-10-14 17:37:40 +0900 |
commit | 9a12dcacff0a524e26c2656783f9c9d34443f73e (patch) | |
tree | f32651906d4b8a80363622ecc4bc7a78770fc239 | |
parent | e8a6aec213a1417fde6ced7679ff21b1b7d38bae (diff) | |
download | gst-libav-9a12dcacff0a524e26c2656783f9c9d34443f73e.tar.gz |
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: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/94>
-rw-r--r-- | ext/libav/gstavauddec.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/ext/libav/gstavauddec.c b/ext/libav/gstavauddec.c index ea27d31..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,19 +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); + +done: + return ret; send_packet_failed: GST_WARNING_OBJECT (ffmpegdec, "send packet failed, could not drain decoder"); + goto done; } static void @@ -649,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); |