Change AudioGraph #release to #reset, resetting internal state.

PiperOrigin-RevId: 589113634
This commit is contained in:
samrobinson 2023-12-08 06:34:18 -08:00 committed by Copybara-Service
parent c5c8e988e8
commit 1471528176
3 changed files with 9 additions and 3 deletions

View File

@ -124,13 +124,17 @@ import java.util.Objects;
return currentOutput;
}
/** Releases underlying resources, including clearing the inputs. */
public void release() {
/** Resets the graph to an unconfigured state, releasing any underlying resources. */
public void reset() {
for (int i = 0; i < inputs.size(); i++) {
inputs.valueAt(i).release();
}
inputs.clear();
mixer.reset();
finishedInputs = 0;
currentOutput = EMPTY_BUFFER;
outputAudioFormat = AudioFormat.NOT_SET;
}
/** Returns whether the input has ended and all queued data has been output. */

View File

@ -151,7 +151,9 @@ import java.util.concurrent.atomic.AtomicReference;
return true;
}
/** Releases any underlying resources. */
public void release() {
// TODO(b/303029174): Impl flush(), reset() & decide if a separate release() is still needed.
audioProcessingPipeline.reset();
}

View File

@ -112,7 +112,7 @@ import org.checkerframework.dataflow.qual.Pure;
@Override
public void release() {
audioGraph.release();
audioGraph.reset();
encoder.release();
}