Flip input buffer even if the end of stream is reached.

Sometimes the empty end of stream buffer has a non-zero
data limit. Calling flip first, resets the limit to the
position which is zero in these cases.

PiperOrigin-RevId: 413156455
This commit is contained in:
hschlueter 2021-11-30 16:28:34 +00:00 committed by tonihei
parent 1b25e2f93d
commit 8105394ac2
2 changed files with 1 additions and 7 deletions

View File

@ -298,12 +298,6 @@ sample:
size = 1193
isKeyFrame = false
presentationTimeUs = 734083
sample:
trackIndex = 0
dataHashCode = 820561200
size = 1252
isKeyFrame = true
presentationTimeUs = 201521
sample:
trackIndex = 1
dataHashCode = -1554795381

View File

@ -197,13 +197,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
int result = readSource(getFormatHolder(), samplePipelineInputBuffer, /* readFlags= */ 0);
switch (result) {
case C.RESULT_BUFFER_READ:
samplePipelineInputBuffer.flip();
if (samplePipelineInputBuffer.isEndOfStream()) {
samplePipeline.queueInputBuffer();
return false;
}
mediaClock.updateTimeForTrackType(getTrackType(), samplePipelineInputBuffer.timeUs);
samplePipelineInputBuffer.timeUs -= streamOffsetUs;
samplePipelineInputBuffer.flip();
checkStateNotNull(samplePipelineInputBuffer.data);
maybeQueueSampleToPipeline(samplePipelineInputBuffer);
return true;