Commit b88012f5 by Oliver Woodman

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

Issue: #417
parent a175ecbf
...@@ -835,22 +835,31 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer { ...@@ -835,22 +835,31 @@ 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);
boolean isEndOfStream = (outputBufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0;
boolean processedOutputBuffer;
if (isEndOfStream && outputBufferInfo.size == 0) {
// Empty buffer indicating the end of the stream.
codec.releaseOutputBuffer(outputIndex, false);
processedOutputBuffer = true;
} else {
processedOutputBuffer = processOutputBuffer(positionUs, elapsedRealtimeUs, codec,
outputBuffers[outputIndex], outputBufferInfo, outputIndex, decodeOnlyIndex != -1);
}
if (processedOutputBuffer) {
if (decodeOnlyIndex != -1) {
decodeOnlyPresentationTimestamps.remove(decodeOnlyIndex);
}
if (isEndOfStream) {
if (codecReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM) { if (codecReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM) {
// We're waiting to re-initialize the codec, and have now received all final output buffers. // We're waiting to re-initialize the codec, and have now processed all final buffers.
releaseCodec(); releaseCodec();
maybeInitCodec(); maybeInitCodec();
} else { } else {
outputStreamEnded = true; outputStreamEnded = true;
} }
return false;
}
int decodeOnlyIndex = getDecodeOnlyIndex(outputBufferInfo.presentationTimeUs);
if (processOutputBuffer(positionUs, elapsedRealtimeUs, codec, outputBuffers[outputIndex],
outputBufferInfo, outputIndex, decodeOnlyIndex != -1)) {
if (decodeOnlyIndex != -1) {
decodeOnlyPresentationTimestamps.remove(decodeOnlyIndex);
} }
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