Remove redundant flush() calls from AudioProcessors

flush() is guaranteed to be called in all these cases anyway.

Also clarify documentation for AudioProcessor-specific methods that can
change the 'active' flag.

Issue: #6601
PiperOrigin-RevId: 282515255
This commit is contained in:
andrewlewis 2019-11-26 09:09:40 +00:00 committed by Oliver Woodman
parent 10f142b3ff
commit 4799993d3b
2 changed files with 12 additions and 12 deletions

View File

@ -98,14 +98,14 @@ public final class SilenceSkippingAudioProcessor extends BaseAudioProcessor {
} }
/** /**
* Sets whether to skip silence in the input. Calling this method will discard any data buffered * Sets whether to skip silence in the input. This method may only be called after draining data
* within the processor, and may update the value returned by {@link #isActive()}. * through the processor. The value returned by {@link #isActive()} may change, and the processor
* must be {@link #flush() flushed} before queueing more data.
* *
* @param enabled Whether to skip silence in the input. * @param enabled Whether to skip silence in the input.
*/ */
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
this.enabled = enabled; this.enabled = enabled;
flush();
} }
/** /**

View File

@ -92,8 +92,9 @@ public final class SonicAudioProcessor implements AudioProcessor {
} }
/** /**
* Sets the playback speed. Calling this method will discard any data buffered within the * Sets the playback speed. This method may only be called after draining data through the
* processor, and may update the value returned by {@link #isActive()}. * processor. The value returned by {@link #isActive()} may change, and the processor must be
* {@link #flush() flushed} before queueing more data.
* *
* @param speed The requested new playback speed. * @param speed The requested new playback speed.
* @return The actual new playback speed. * @return The actual new playback speed.
@ -104,13 +105,13 @@ public final class SonicAudioProcessor implements AudioProcessor {
this.speed = speed; this.speed = speed;
pendingSonicRecreation = true; pendingSonicRecreation = true;
} }
flush();
return speed; return speed;
} }
/** /**
* Sets the playback pitch. Calling this method will discard any data buffered within the * Sets the playback pitch. This method may only be called after draining data through the
* processor, and may update the value returned by {@link #isActive()}. * processor. The value returned by {@link #isActive()} may change, and the processor must be
* {@link #flush() flushed} before queueing more data.
* *
* @param pitch The requested new pitch. * @param pitch The requested new pitch.
* @return The actual new pitch. * @return The actual new pitch.
@ -121,16 +122,15 @@ public final class SonicAudioProcessor implements AudioProcessor {
this.pitch = pitch; this.pitch = pitch;
pendingSonicRecreation = true; pendingSonicRecreation = true;
} }
flush();
return pitch; return pitch;
} }
/** /**
* Sets the sample rate for output audio, in hertz. Pass {@link #SAMPLE_RATE_NO_CHANGE} to output * Sets the sample rate for output audio, in Hertz. Pass {@link #SAMPLE_RATE_NO_CHANGE} to output
* audio at the same sample rate as the input. After calling this method, call {@link * audio at the same sample rate as the input. After calling this method, call {@link
* #configure(AudioFormat)} to start using the new sample rate. * #configure(AudioFormat)} to configure the processor with the new sample rate.
* *
* @param sampleRateHz The sample rate for output audio, in hertz. * @param sampleRateHz The sample rate for output audio, in Hertz.
* @see #configure(AudioFormat) * @see #configure(AudioFormat)
*/ */
public void setOutputSampleRateHz(int sampleRateHz) { public void setOutputSampleRateHz(int sampleRateHz) {