Bug 1364870: [ffmpeg] only check format if frame has been decoded. r?gerald
The format member isn't set when an audio frame hasn't been decoded yet.
MozReview-Commit-ID: IgUj6bjVzdF
--- a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp
@@ -148,30 +148,30 @@ FFmpegAudioDecoder<LIBAV_VER>::ProcessDe
if (bytesConsumed < 0) {
NS_WARNING("FFmpeg audio decoder error.");
return DecodePromise::CreateAndReject(
MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
RESULT_DETAIL("FFmpeg audio error:%d", bytesConsumed)),
__func__);
}
- if (mFrame->format != AV_SAMPLE_FMT_FLT &&
- mFrame->format != AV_SAMPLE_FMT_FLTP &&
- mFrame->format != AV_SAMPLE_FMT_S16 &&
- mFrame->format != AV_SAMPLE_FMT_S16P &&
- mFrame->format != AV_SAMPLE_FMT_S32 &&
- mFrame->format != AV_SAMPLE_FMT_S32P) {
- return DecodePromise::CreateAndReject(
- MediaResult(
- NS_ERROR_DOM_MEDIA_DECODE_ERR,
- RESULT_DETAIL("FFmpeg audio decoder outputs unsupported audio format")),
- __func__);
- }
-
if (decoded) {
+ if (mFrame->format != AV_SAMPLE_FMT_FLT &&
+ mFrame->format != AV_SAMPLE_FMT_FLTP &&
+ mFrame->format != AV_SAMPLE_FMT_S16 &&
+ mFrame->format != AV_SAMPLE_FMT_S16P &&
+ mFrame->format != AV_SAMPLE_FMT_S32 &&
+ mFrame->format != AV_SAMPLE_FMT_S32P) {
+ return DecodePromise::CreateAndReject(
+ MediaResult(
+ NS_ERROR_DOM_MEDIA_DECODE_ERR,
+ RESULT_DETAIL(
+ "FFmpeg audio decoder outputs unsupported audio format")),
+ __func__);
+ }
uint32_t numChannels = mCodecContext->channels;
AudioConfig::ChannelLayout layout(numChannels);
if (!layout.IsValid()) {
return DecodePromise::CreateAndReject(
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
RESULT_DETAIL("Unsupported channel layout:%u", numChannels)),
__func__);
}