avaudenc: avoid using wrong number of samples

If audio_in is NULL, we'll send a NULL frame to libav, to flush
the codec. In that case, we won't know how many samples the codec
will have used, so we use -1 (for don't know) when letting the
base class know about the buffer.

Coverity 1195177
This commit is contained in:
Vincent Penquerc'h 2014-04-30 15:30:45 +01:00
parent 406d5ba04a
commit 17e2e9acd9

View file

@ -553,7 +553,7 @@ gst_ffmpegaudenc_encode_audio (GstFFMpegAudEnc * ffmpegaudenc,
pkt, gst_ffmpegaudenc_free_avpacket); pkt, gst_ffmpegaudenc_free_avpacket);
codec = ffmpegaudenc->context->codec; codec = ffmpegaudenc->context->codec;
if ((codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) { if ((codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) || !audio_in) {
ret = gst_audio_encoder_finish_frame (enc, outbuf, -1); ret = gst_audio_encoder_finish_frame (enc, outbuf, -1);
} else { } else {
ret = gst_audio_encoder_finish_frame (enc, outbuf, frame.nb_samples); ret = gst_audio_encoder_finish_frame (enc, outbuf, frame.nb_samples);