From a7bfa12eecb42cbdd13bd7e612603a4d400ebda4 Mon Sep 17 00:00:00 2001 From: samrobinson Date: Mon, 24 Oct 2022 16:27:18 +0000 Subject: [PATCH] Add CanIgnoreReturnValue to AudioProcessor#configure + implementations Although it can be useful to check the output format, it's not required or needed. For some AudioProcessor implementations, it is stated/obvious that the output format will match the input, in which case there is no a need to check the return value. #cleanup PiperOrigin-RevId: 483403679 --- .../com/google/android/exoplayer2/audio/AudioProcessor.java | 2 ++ .../google/android/exoplayer2/audio/BaseAudioProcessor.java | 3 +++ .../android/exoplayer2/audio/ChannelMappingAudioProcessor.java | 2 ++ .../exoplayer2/audio/FloatResamplingAudioProcessor.java | 2 ++ .../android/exoplayer2/audio/ResamplingAudioProcessor.java | 2 ++ .../exoplayer2/audio/SilenceSkippingAudioProcessor.java | 2 ++ .../google/android/exoplayer2/audio/SonicAudioProcessor.java | 2 ++ .../exoplayer2/transformer/SpeedChangingAudioProcessor.java | 2 ++ 8 files changed, 17 insertions(+) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java index f7b9e41b16..b7cf2fb026 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java @@ -18,6 +18,7 @@ package com.google.android.exoplayer2.audio; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -96,6 +97,7 @@ public interface AudioProcessor { * @return The configured output audio format if this instance is {@link #isActive() active}. * @throws UnhandledAudioFormatException Thrown if the specified format can't be handled as input. */ + @CanIgnoreReturnValue AudioFormat configure(AudioFormat inputAudioFormat) throws UnhandledAudioFormatException; /** Returns whether the processor is configured and will process input buffers. */ diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/BaseAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/BaseAudioProcessor.java index ff17be48e9..b42d5f0767 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/BaseAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/BaseAudioProcessor.java @@ -16,6 +16,7 @@ package com.google.android.exoplayer2.audio; import androidx.annotation.CallSuper; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -47,6 +48,7 @@ public abstract class BaseAudioProcessor implements AudioProcessor { } @Override + @CanIgnoreReturnValue public final AudioFormat configure(AudioFormat inputAudioFormat) throws UnhandledAudioFormatException { pendingInputAudioFormat = inputAudioFormat; @@ -121,6 +123,7 @@ public abstract class BaseAudioProcessor implements AudioProcessor { } /** Called when the processor is configured for a new input format. */ + @CanIgnoreReturnValue protected AudioFormat onConfigure(AudioFormat inputAudioFormat) throws UnhandledAudioFormatException { return AudioFormat.NOT_SET; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java index 29b6896e18..503f07a2c3 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java @@ -19,6 +19,7 @@ import androidx.annotation.Nullable; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.util.Assertions; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.nio.ByteBuffer; /** @@ -44,6 +45,7 @@ import java.nio.ByteBuffer; } @Override + @CanIgnoreReturnValue public AudioFormat onConfigure(AudioFormat inputAudioFormat) throws UnhandledAudioFormatException { @Nullable int[] outputChannels = pendingOutputChannels; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/FloatResamplingAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/FloatResamplingAudioProcessor.java index ca6b4f3f13..ca2a54d572 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/FloatResamplingAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/FloatResamplingAudioProcessor.java @@ -18,6 +18,7 @@ package com.google.android.exoplayer2.audio; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.nio.ByteBuffer; /** @@ -36,6 +37,7 @@ import java.nio.ByteBuffer; private static final double PCM_32_BIT_INT_TO_PCM_32_BIT_FLOAT_FACTOR = 1.0 / 0x7FFFFFFF; @Override + @CanIgnoreReturnValue public AudioFormat onConfigure(AudioFormat inputAudioFormat) throws UnhandledAudioFormatException { @C.PcmEncoding int encoding = inputAudioFormat.encoding; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java index 14ba4788e3..e75c7d9d8b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java @@ -18,6 +18,7 @@ package com.google.android.exoplayer2.audio; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.nio.ByteBuffer; /** @@ -36,6 +37,7 @@ import java.nio.ByteBuffer; /* package */ final class ResamplingAudioProcessor extends BaseAudioProcessor { @Override + @CanIgnoreReturnValue public AudioFormat onConfigure(AudioFormat inputAudioFormat) throws UnhandledAudioFormatException { @C.PcmEncoding int encoding = inputAudioFormat.encoding; 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 2ad3308b6b..2a6f4b5908 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 @@ -22,6 +22,7 @@ import androidx.annotation.IntDef; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -143,6 +144,7 @@ public final class SilenceSkippingAudioProcessor extends BaseAudioProcessor { // AudioProcessor implementation. @Override + @CanIgnoreReturnValue public AudioFormat onConfigure(AudioFormat inputAudioFormat) throws UnhandledAudioFormatException { if (inputAudioFormat.encoding != C.ENCODING_PCM_16BIT) { 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 b7d14667be..ccb0091f21 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 @@ -21,6 +21,7 @@ import androidx.annotation.Nullable; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.ShortBuffer; @@ -140,6 +141,7 @@ public final class SonicAudioProcessor implements AudioProcessor { } @Override + @CanIgnoreReturnValue public AudioFormat configure(AudioFormat inputAudioFormat) throws UnhandledAudioFormatException { if (inputAudioFormat.encoding != C.ENCODING_PCM_16BIT) { throw new UnhandledAudioFormatException(inputAudioFormat); diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SpeedChangingAudioProcessor.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SpeedChangingAudioProcessor.java index e4f1123c70..62bdc36636 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SpeedChangingAudioProcessor.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/SpeedChangingAudioProcessor.java @@ -23,6 +23,7 @@ import com.google.android.exoplayer2.audio.AudioProcessor; import com.google.android.exoplayer2.audio.BaseAudioProcessor; import com.google.android.exoplayer2.audio.SonicAudioProcessor; import com.google.android.exoplayer2.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.nio.ByteBuffer; /** @@ -52,6 +53,7 @@ import java.nio.ByteBuffer; } @Override + @CanIgnoreReturnValue public AudioFormat onConfigure(AudioFormat inputAudioFormat) throws UnhandledAudioFormatException { return sonicAudioProcessor.configure(inputAudioFormat);