From 82ceeb77d6df71f5ffb0474db66a36fd6eb8e51a Mon Sep 17 00:00:00 2001 From: Tolriq Date: Tue, 8 Nov 2022 14:03:54 +0100 Subject: [PATCH] Fix ffmpeg jni wrapper invalid result code returned This ensure that ffmpeg error code are properly translated to values that the ExoPlayer decoder understand. The main gain is that it allows the decoder to properly ignore more cases of invalid data and recover. The second gain is that the other errors are now proper ExoPlayer errors and no more obscure buffer ones. --- extensions/ffmpeg/src/main/jni/ffmpeg_jni.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/ffmpeg/src/main/jni/ffmpeg_jni.cc b/extensions/ffmpeg/src/main/jni/ffmpeg_jni.cc index 947d535c7d3..c3514a8573d 100644 --- a/extensions/ffmpeg/src/main/jni/ffmpeg_jni.cc +++ b/extensions/ffmpeg/src/main/jni/ffmpeg_jni.cc @@ -283,7 +283,8 @@ int decodePacket(AVCodecContext *context, AVPacket *packet, break; } logError("avcodec_receive_frame", result); - return result; + return result == AVERROR_INVALIDDATA ? AUDIO_DECODER_ERROR_INVALID_DATA + : AUDIO_DECODER_ERROR_OTHER; } // Resample output. @@ -330,7 +331,8 @@ int decodePacket(AVCodecContext *context, AVPacket *packet, av_frame_free(&frame); if (result < 0) { logError("swr_convert", result); - return result; + return result == AVERROR_INVALIDDATA ? AUDIO_DECODER_ERROR_INVALID_DATA + : AUDIO_DECODER_ERROR_OTHER; } int available = swr_get_out_samples(resampleContext, 0); if (available != 0) {