mirror of
https://github.com/androidx/media.git
synced 2025-05-13 18:50:02 +08:00
Some no-op cleanup to bypass mode
PiperOrigin-RevId: 348795995
This commit is contained in:
parent
5f3d1c1bc8
commit
3abdec17ca
@ -2133,54 +2133,59 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||||||
*/
|
*/
|
||||||
private boolean bypassRender(long positionUs, long elapsedRealtimeUs)
|
private boolean bypassRender(long positionUs, long elapsedRealtimeUs)
|
||||||
throws ExoPlaybackException {
|
throws ExoPlaybackException {
|
||||||
BatchBuffer batchBuffer = bypassBatchBuffer;
|
|
||||||
|
|
||||||
// Process any data in the batch buffer.
|
// Process any data in the batch buffer.
|
||||||
checkState(!outputStreamEnded);
|
checkState(!outputStreamEnded);
|
||||||
if (!batchBuffer.isEmpty()) { // Optimisation: Do not process buffer if empty.
|
if (!bypassBatchBuffer.isEmpty()) {
|
||||||
if (processOutputBuffer(
|
if (processOutputBuffer(
|
||||||
positionUs,
|
positionUs,
|
||||||
elapsedRealtimeUs,
|
elapsedRealtimeUs,
|
||||||
/* codec= */ null,
|
/* codec= */ null,
|
||||||
batchBuffer.data,
|
bypassBatchBuffer.data,
|
||||||
outputIndex,
|
outputIndex,
|
||||||
/* bufferFlags= */ 0,
|
/* bufferFlags= */ 0,
|
||||||
batchBuffer.getAccessUnitCount(),
|
bypassBatchBuffer.getAccessUnitCount(),
|
||||||
batchBuffer.getFirstAccessUnitTimeUs(),
|
bypassBatchBuffer.getFirstAccessUnitTimeUs(),
|
||||||
batchBuffer.isDecodeOnly(),
|
bypassBatchBuffer.isDecodeOnly(),
|
||||||
batchBuffer.isEndOfStream(),
|
bypassBatchBuffer.isEndOfStream(),
|
||||||
outputFormat)) {
|
outputFormat)) {
|
||||||
onProcessedOutputBuffer(batchBuffer.getLastAccessUnitTimeUs());
|
onProcessedOutputBuffer(bypassBatchBuffer.getLastAccessUnitTimeUs());
|
||||||
} else {
|
} else {
|
||||||
// Could not process the whole buffer. Try again later.
|
// Could not process the whole buffer. Try again later.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Process the end of stream, if it has been reached.
|
// Process end of stream, if reached.
|
||||||
if (batchBuffer.isEndOfStream()) {
|
if (bypassBatchBuffer.isEndOfStream()) {
|
||||||
outputStreamEnded = true;
|
outputStreamEnded = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
batchBuffer.batchWasConsumed();
|
|
||||||
|
bypassBatchBuffer.batchWasConsumed();
|
||||||
|
|
||||||
if (bypassDrainAndReinitialize) {
|
if (bypassDrainAndReinitialize) {
|
||||||
if (!batchBuffer.isEmpty()) {
|
if (!bypassBatchBuffer.isEmpty()) {
|
||||||
return true; // Drain the batch buffer before propagating the format change.
|
// The bypassBatchBuffer.batchWasConsumed() call above caused a pending access unit to be
|
||||||
|
// made available inside the batch buffer, meaning it's once again non-empty. We need to
|
||||||
|
// process this data before we can re-initialize.
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
disableBypass(); // The new format might require a codec.
|
// The new format might require using a codec rather than bypass.
|
||||||
|
disableBypass();
|
||||||
bypassDrainAndReinitialize = false;
|
bypassDrainAndReinitialize = false;
|
||||||
maybeInitCodecOrBypass();
|
maybeInitCodecOrBypass();
|
||||||
if (!bypassEnabled) {
|
if (!bypassEnabled) {
|
||||||
return false; // The new format is not supported in codec bypass.
|
// We're no longer in bypass mode.
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now refill the empty buffer for the next iteration.
|
// Fill the batch buffer for the next iteration.
|
||||||
checkState(!inputStreamEnded);
|
checkState(!inputStreamEnded);
|
||||||
FormatHolder formatHolder = getFormatHolder();
|
FormatHolder formatHolder = getFormatHolder();
|
||||||
boolean formatChange = readBatchFromSource(formatHolder, batchBuffer);
|
boolean formatChange = readBatchFromSource(formatHolder, bypassBatchBuffer);
|
||||||
|
|
||||||
if (!batchBuffer.isEmpty() && waitingForFirstSampleInFormat) {
|
if (!bypassBatchBuffer.isEmpty() && waitingForFirstSampleInFormat) {
|
||||||
// This is the first buffer in a new format, the output format must be updated.
|
// This is the first buffer in a new format, the output format must be updated.
|
||||||
outputFormat = checkNotNull(inputFormat);
|
outputFormat = checkNotNull(inputFormat);
|
||||||
onOutputFormatChanged(outputFormat, /* mediaFormat= */ null);
|
onOutputFormatChanged(outputFormat, /* mediaFormat= */ null);
|
||||||
@ -2192,12 +2197,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean haveDataToProcess = false;
|
boolean haveDataToProcess = false;
|
||||||
if (batchBuffer.isEndOfStream()) {
|
if (bypassBatchBuffer.isEndOfStream()) {
|
||||||
inputStreamEnded = true;
|
inputStreamEnded = true;
|
||||||
haveDataToProcess = true;
|
haveDataToProcess = true;
|
||||||
}
|
}
|
||||||
if (!batchBuffer.isEmpty()) {
|
if (!bypassBatchBuffer.isEmpty()) {
|
||||||
batchBuffer.flip();
|
bypassBatchBuffer.flip();
|
||||||
haveDataToProcess = true;
|
haveDataToProcess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user