Ffmpeg extension: Wait for channel count and sample rate
When playing TrueHD streams, it's possible that the first decoded buffer is empty, and that the channel count and sample rate are still unknown. To correct for this, defer determining the format until a buffer that will actually be output from the decoder has been obtained, and only then query the channel count and sample rate. Issue: #8616 #minor-release PiperOrigin-RevId: 366246245
This commit is contained in:
parent
3d3c90b89d
commit
1315e11bfd
@ -138,6 +138,9 @@
|
|||||||
([#8447](https://github.com/google/ExoPlayer/issues/8447)).
|
([#8447](https://github.com/google/ExoPlayer/issues/8447)).
|
||||||
* Update instructions and publishing configuration for releasing to Google's
|
* Update instructions and publishing configuration for releasing to Google's
|
||||||
Maven repository instead of bintray/JCenter.
|
Maven repository instead of bintray/JCenter.
|
||||||
|
* FFmpeg extension: Fix playback failure when switching to TrueHD tracks
|
||||||
|
during playback
|
||||||
|
([#8616](https://github.com/google/ExoPlayer/issues/8616)).
|
||||||
|
|
||||||
### 2.13.2 (2021-02-25)
|
### 2.13.2 (2021-02-25)
|
||||||
|
|
||||||
|
@ -110,14 +110,18 @@ import java.util.List;
|
|||||||
int inputSize = inputData.limit();
|
int inputSize = inputData.limit();
|
||||||
ByteBuffer outputData = outputBuffer.init(inputBuffer.timeUs, outputBufferSize);
|
ByteBuffer outputData = outputBuffer.init(inputBuffer.timeUs, outputBufferSize);
|
||||||
int result = ffmpegDecode(nativeContext, inputData, inputSize, outputData, outputBufferSize);
|
int result = ffmpegDecode(nativeContext, inputData, inputSize, outputData, outputBufferSize);
|
||||||
if (result == AUDIO_DECODER_ERROR_INVALID_DATA) {
|
if (result == AUDIO_DECODER_ERROR_OTHER) {
|
||||||
|
return new FfmpegDecoderException("Error decoding (see logcat).");
|
||||||
|
} else if (result == AUDIO_DECODER_ERROR_INVALID_DATA) {
|
||||||
// Treat invalid data errors as non-fatal to match the behavior of MediaCodec. No output will
|
// Treat invalid data errors as non-fatal to match the behavior of MediaCodec. No output will
|
||||||
// be produced for this buffer, so mark it as decode-only to ensure that the audio sink's
|
// be produced for this buffer, so mark it as decode-only to ensure that the audio sink's
|
||||||
// position is reset when more audio is produced.
|
// position is reset when more audio is produced.
|
||||||
outputBuffer.setFlags(C.BUFFER_FLAG_DECODE_ONLY);
|
outputBuffer.setFlags(C.BUFFER_FLAG_DECODE_ONLY);
|
||||||
return null;
|
return null;
|
||||||
} else if (result == AUDIO_DECODER_ERROR_OTHER) {
|
} else if (result == 0) {
|
||||||
return new FfmpegDecoderException("Error decoding (see logcat).");
|
// There's no need to output empty buffers.
|
||||||
|
outputBuffer.setFlags(C.BUFFER_FLAG_DECODE_ONLY);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
if (!hasOutputFormat) {
|
if (!hasOutputFormat) {
|
||||||
channelCount = ffmpegGetChannelCount(nativeContext);
|
channelCount = ffmpegGetChannelCount(nativeContext);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user