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; return currentOutput;
} }
/** Releases underlying resources, including clearing the inputs. */ /** Resets the graph to an unconfigured state, releasing any underlying resources. */
public void release() { public void reset() {
for (int i = 0; i < inputs.size(); i++) { for (int i = 0; i < inputs.size(); i++) {
inputs.valueAt(i).release(); inputs.valueAt(i).release();
} }
inputs.clear(); inputs.clear();
mixer.reset(); mixer.reset();
finishedInputs = 0;
currentOutput = EMPTY_BUFFER;
outputAudioFormat = AudioFormat.NOT_SET;
} }
/** Returns whether the input has ended and all queued data has been output. */ /** 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; return true;
} }
/** Releases any underlying resources. */
public void release() { public void release() {
// TODO(b/303029174): Impl flush(), reset() & decide if a separate release() is still needed.
audioProcessingPipeline.reset(); audioProcessingPipeline.reset();
} }

View File

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