avauddec: Ensure drain even if codec has not delay capabilities

There are decoders that need to be drained if they work on multi-threads,
even if AV_CODEC_CAP_DELAY is not set.
This commit is contained in:
Yeongjin Jeong 2019-04-29 15:22:52 +09:00
parent 93e2466115
commit 472f2ef104

View file

@ -597,29 +597,20 @@ no_codec:
static void
gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec)
{
GstFFMpegAudDecClass *oclass;
gboolean got_any_frames = FALSE;
gboolean got_frame;
oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
if (avcodec_send_packet (ffmpegdec->context, NULL))
goto send_packet_failed;
if (oclass->in_plugin->capabilities & AV_CODEC_CAP_DELAY) {
gboolean got_frame;
do {
GstFlowReturn ret;
GST_LOG_OBJECT (ffmpegdec,
"codec has delay capabilities, calling until libav has drained everything");
if (avcodec_send_packet (ffmpegdec->context, NULL))
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);
}
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);