Skip to content

Commit

Permalink
Fix ffmpeg jni wrapper invalid result code returned
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Tolriq committed Nov 8, 2022
1 parent 972e169 commit 82ceeb7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions extensions/ffmpeg/src/main/jni/ffmpeg_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 82ceeb7

Please sign in to comment.