mirror of
https://github.com/samsonjs/media.git
synced 2026-04-01 10:35:48 +00:00
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
This commit is contained in:
parent
5da9fd83e9
commit
2e5e1e7c0f
1 changed files with 6 additions and 2 deletions
|
|
@ -305,11 +305,15 @@ public final class SilenceMediaSource extends BaseMediaSource {
|
|||
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);
|
||||
buffer.ensureSpaceForWrite(bytesToWrite);
|
||||
buffer.data.put(SILENCE_SAMPLE, /* offset= */ 0, bytesToWrite);
|
||||
buffer.timeUs = getAudioPositionUs(positionBytes);
|
||||
buffer.addFlag(C.BUFFER_FLAG_KEY_FRAME);
|
||||
positionBytes += bytesToWrite;
|
||||
return C.RESULT_BUFFER_READ;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue