summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Yang <seungha@centricular.com>2020-09-15 02:12:23 +0900
committerSeungha Yang <seungha@centricular.com>2020-10-14 17:37:58 +0900
commitde93710ef36f05fe427049d953cc807567e185fe (patch)
tree00f6b4636e8e6ff5e763fdcaef41564dce57d324
parent9a12dcacff0a524e26c2656783f9c9d34443f73e (diff)
downloadgst-libav-de93710ef36f05fe427049d953cc807567e185fe.tar.gz
avauddec: Ensure finish_subframe() and finish_frame() are paired
audiodecoder baseclass implementation is expecting that finish_subframe() is followed by finish_frame() in order clear its internal state related to subframe. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/94>
-rw-r--r--ext/libav/gstavauddec.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/ext/libav/gstavauddec.c b/ext/libav/gstavauddec.c
index 60d0c44..ceaee12 100644
--- a/ext/libav/gstavauddec.c
+++ b/ext/libav/gstavauddec.c
@@ -611,10 +611,14 @@ gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec)
} while (got_frame);
avcodec_flush_buffers (ffmpegdec->context);
- if (got_any_frames && ret == GST_FLOW_OK)
- ret =
+ if (got_any_frames) {
+ GstFlowReturn new_ret =
gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), NULL, 1);
+ if (ret == GST_FLOW_OK)
+ ret = new_ret;
+ }
+
done:
return ret;
@@ -723,12 +727,19 @@ gst_ffmpegauddec_handle_frame (GstAudioDecoder * decoder, GstBuffer * inbuf)
}
} while (got_frame);
- /* Only override the flow return value if previously did have a GST_FLOW_OK.
- * Failure to do this would result in skipping downstream issues caught in
- * earlier steps. */
- if (ret == GST_FLOW_OK && (is_header || got_any_frames)) {
- ret =
+ if (is_header || got_any_frames) {
+ /* Even if previous return wasn't GST_FLOW_OK, we need to call
+ * _finish_frame() since baseclass is expecting that _finish_frame()
+ * is followed by _finish_subframe()
+ */
+ GstFlowReturn new_ret =
gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), NULL, 1);
+
+ /* Only override the flow return value if previously did have a GST_FLOW_OK.
+ * Failure to do this would result in skipping downstream issues caught in
+ * earlier steps. */
+ if (ret == GST_FLOW_OK)
+ ret = new_ret;
}
unmap: