Commit 18a94aa7 by olly Committed by marcbaechinger

SilenceSampleStream.readData: Handle flags-only buffers

The SampleStream.readData contract is that when reading a sample
with a flags-only buffer, the buffer timestamp and flags should
be set and the read position should not be advanced.

#minor-release

PiperOrigin-RevId: 357842130
parent 625c830b
...@@ -305,11 +305,15 @@ public final class SilenceMediaSource extends BaseMediaSource { ...@@ -305,11 +305,15 @@ public final class SilenceMediaSource extends BaseMediaSource {
return C.RESULT_BUFFER_READ; return C.RESULT_BUFFER_READ;
} }
buffer.timeUs = getAudioPositionUs(positionBytes);
buffer.addFlag(C.BUFFER_FLAG_KEY_FRAME);
if (buffer.isFlagsOnly()) {
return C.RESULT_BUFFER_READ;
}
int bytesToWrite = (int) min(SILENCE_SAMPLE.length, bytesRemaining); int bytesToWrite = (int) min(SILENCE_SAMPLE.length, bytesRemaining);
buffer.ensureSpaceForWrite(bytesToWrite); buffer.ensureSpaceForWrite(bytesToWrite);
buffer.data.put(SILENCE_SAMPLE, /* offset= */ 0, bytesToWrite); buffer.data.put(SILENCE_SAMPLE, /* offset= */ 0, bytesToWrite);
buffer.timeUs = getAudioPositionUs(positionBytes);
buffer.addFlag(C.BUFFER_FLAG_KEY_FRAME);
positionBytes += bytesToWrite; positionBytes += bytesToWrite;
return C.RESULT_BUFFER_READ; return C.RESULT_BUFFER_READ;
} }
......
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