Commit b88012f5 by Oliver Woodman

Process final output buffer if it's non-empty.

Issue: #417
parent a175ecbf
...@@ -835,23 +835,32 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer { ...@@ -835,23 +835,32 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
return false; return false;
} }
if ((outputBufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) { int decodeOnlyIndex = getDecodeOnlyIndex(outputBufferInfo.presentationTimeUs);
if (codecReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM) { boolean isEndOfStream = (outputBufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0;
// We're waiting to re-initialize the codec, and have now received all final output buffers.
releaseCodec(); boolean processedOutputBuffer;
maybeInitCodec(); if (isEndOfStream && outputBufferInfo.size == 0) {
} else { // Empty buffer indicating the end of the stream.
outputStreamEnded = true; codec.releaseOutputBuffer(outputIndex, false);
} processedOutputBuffer = true;
return false; } else {
processedOutputBuffer = processOutputBuffer(positionUs, elapsedRealtimeUs, codec,
outputBuffers[outputIndex], outputBufferInfo, outputIndex, decodeOnlyIndex != -1);
} }
int decodeOnlyIndex = getDecodeOnlyIndex(outputBufferInfo.presentationTimeUs); if (processedOutputBuffer) {
if (processOutputBuffer(positionUs, elapsedRealtimeUs, codec, outputBuffers[outputIndex],
outputBufferInfo, outputIndex, decodeOnlyIndex != -1)) {
if (decodeOnlyIndex != -1) { if (decodeOnlyIndex != -1) {
decodeOnlyPresentationTimestamps.remove(decodeOnlyIndex); decodeOnlyPresentationTimestamps.remove(decodeOnlyIndex);
} }
if (isEndOfStream) {
if (codecReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM) {
// We're waiting to re-initialize the codec, and have now processed all final buffers.
releaseCodec();
maybeInitCodec();
} else {
outputStreamEnded = true;
}
}
outputIndex = -1; outputIndex = -1;
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment