From 3947bd0ae4fcd34719d041e0c3d08417e57857f8 Mon Sep 17 00:00:00 2001 From: Don Turner Date: Tue, 9 Jun 2020 12:27:55 +0100 Subject: [PATCH] Handle EAGAIN result from decoder --- samples/RhythmGame/src/main/cpp/audio/FFMpegExtractor.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/samples/RhythmGame/src/main/cpp/audio/FFMpegExtractor.cpp b/samples/RhythmGame/src/main/cpp/audio/FFMpegExtractor.cpp index f77b841be..79c1f9dea 100644 --- a/samples/RhythmGame/src/main/cpp/audio/FFMpegExtractor.cpp +++ b/samples/RhythmGame/src/main/cpp/audio/FFMpegExtractor.cpp @@ -252,7 +252,12 @@ int64_t FFMpegExtractor::decode( // Retrieve our raw data from the codec result = avcodec_receive_frame(codecContext.get(), decodedFrame); - if (result != 0) { + if (result == AVERROR(EAGAIN)) { + // The codec needs more data before it can decode + avPacket.size = 0; + avPacket.data = nullptr; + continue; + } else if (result != 0) { LOGE("avcodec_receive_frame error: %s", av_err2str(result)); goto cleanup; }