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
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user