Fix buffer lost when flushing AudioGraphInput

Before this CL, currentInputBufferBeingOutput was set to null without
adding the buffer to the queue of available buffers, which was making
this buffer unusable. After multiple seeks, playback was stuck because
the AudioGraphInput had no input buffer left.

PiperOrigin-RevId: 624943271
This commit is contained in:
kimvde 2024-04-15 06:46:47 -07:00 committed by Copybara-Service
parent 0a741cad36
commit 00e3753d62

View File

@ -235,12 +235,16 @@ import java.util.concurrent.atomic.AtomicReference;
// queueing it. // queueing it.
clearAndAddToAvailableBuffers(availableInputBuffers.remove()); clearAndAddToAvailableBuffers(availableInputBuffers.remove());
} }
if (currentInputBufferBeingOutput != null) {
clearAndAddToAvailableBuffers(currentInputBufferBeingOutput);
currentInputBufferBeingOutput = null;
}
while (!pendingInputBuffers.isEmpty()) { while (!pendingInputBuffers.isEmpty()) {
clearAndAddToAvailableBuffers(pendingInputBuffers.remove()); clearAndAddToAvailableBuffers(pendingInputBuffers.remove());
} }
checkState(availableInputBuffers.size() == MAX_INPUT_BUFFER_COUNT);
silentAudioGenerator.flush(); silentAudioGenerator.flush();
audioProcessingPipeline.flush(); audioProcessingPipeline.flush();
currentInputBufferBeingOutput = null;
receivedEndOfStreamFromInput = false; receivedEndOfStreamFromInput = false;
queueEndOfStreamAfterSilence = false; queueEndOfStreamAfterSilence = false;
startTimeUs = C.TIME_UNSET; startTimeUs = C.TIME_UNSET;