Bug 1765480 - "send" before "receive"-ing when decoding audio using ffmpeg. r=alwu

This is what the documentation says we should be doing (and it's clearly the
right thing to do). We miss decoding a packet otherwise.

Depends on D150974

Differential Revision: https://phabricator.services.mozilla.com/D150975
This commit is contained in:
Paul Adenot 2022-08-17 16:29:34 +00:00
Родитель c007418c08
Коммит 6b7edc6cf9
1 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -269,21 +269,7 @@ MediaResult FFmpegAudioDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample,
}
#else
# define AVRESULT_OK 0
int ret = mLib->avcodec_receive_frame(mCodecContext, mFrame);
switch (ret) {
case AVRESULT_OK:
decoded = true;
break;
case AVERROR(EAGAIN):
break;
case AVERROR_EOF: {
FFMPEG_LOG(" End of stream.");
return MediaResult(NS_ERROR_DOM_MEDIA_END_OF_STREAM,
RESULT_DETAIL("End of stream"));
}
}
ret = mLib->avcodec_send_packet(mCodecContext, &packet);
int ret = mLib->avcodec_send_packet(mCodecContext, &packet);
switch (ret) {
case AVRESULT_OK:
bytesConsumed = packet.size;
@ -299,6 +285,20 @@ MediaResult FFmpegAudioDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample,
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
RESULT_DETAIL("FFmpeg audio error"));
}
ret = mLib->avcodec_receive_frame(mCodecContext, mFrame);
switch (ret) {
case AVRESULT_OK:
decoded = true;
break;
case AVERROR(EAGAIN):
break;
case AVERROR_EOF: {
FFMPEG_LOG(" End of stream.");
return MediaResult(NS_ERROR_DOM_MEDIA_END_OF_STREAM,
RESULT_DETAIL("End of stream"));
}
}
#endif
if (decoded) {