From 4799993d3bcf7bb7fd04bd24b7e675ce014f8eef Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Tue, 26 Nov 2019 09:09:40 +0000 Subject: [PATCH] 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 --- .../audio/SilenceSkippingAudioProcessor.java | 6 +++--- .../exoplayer2/audio/SonicAudioProcessor.java | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessor.java index 59feed9bd2..2a98d2fb25 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessor.java @@ -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 - * within the processor, and may update the value returned by {@link #isActive()}. + * Sets whether to skip silence in the input. This method may only be called after draining data + * 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. */ public void setEnabled(boolean enabled) { this.enabled = enabled; - flush(); } /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java index 4ebadab80c..c683f60e76 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java @@ -92,8 +92,9 @@ public final class SonicAudioProcessor implements AudioProcessor { } /** - * Sets the playback speed. Calling this method will discard any data buffered within the - * processor, and may update the value returned by {@link #isActive()}. + * Sets the playback speed. This method may only be called after draining data through the + * 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. * @return The actual new playback speed. @@ -104,13 +105,13 @@ public final class SonicAudioProcessor implements AudioProcessor { this.speed = speed; pendingSonicRecreation = true; } - flush(); return speed; } /** - * Sets the playback pitch. Calling this method will discard any data buffered within the - * processor, and may update the value returned by {@link #isActive()}. + * Sets the playback pitch. This method may only be called after draining data through the + * 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. * @return The actual new pitch. @@ -121,16 +122,15 @@ public final class SonicAudioProcessor implements AudioProcessor { this.pitch = pitch; pendingSonicRecreation = true; } - flush(); 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 - * #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) */ public void setOutputSampleRateHz(int sampleRateHz) {