From 15d50d0bf0ffed037d2b865b70974672904f543d Mon Sep 17 00:00:00 2001 From: ibaker Date: Fri, 4 Feb 2022 16:16:46 +0000 Subject: [PATCH] Remove @C.AudioManagerOffloadMode IntDef This is only used in DefaultAudioSink, so we could move it there and make it private - but at that point we might as well refer to the underlying AudioManager constants instead. #minor-release PiperOrigin-RevId: 426407661 --- .../java/com/google/android/exoplayer2/C.java | 20 ------------------- .../exoplayer2/audio/DefaultAudioSink.java | 16 +++++++-------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/C.java b/library/common/src/main/java/com/google/android/exoplayer2/C.java index c94f251c58..44a546486f 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/C.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/C.java @@ -499,26 +499,6 @@ public final class C { public static final int AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE = AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE; - /** - * Playback offload mode. One of {@link #PLAYBACK_OFFLOAD_NOT_SUPPORTED},{@link - * #PLAYBACK_OFFLOAD_SUPPORTED} or {@link #PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED}. - */ - @IntDef({ - PLAYBACK_OFFLOAD_NOT_SUPPORTED, - PLAYBACK_OFFLOAD_SUPPORTED, - PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AudioManagerOffloadMode {} - /** See AudioManager#PLAYBACK_OFFLOAD_NOT_SUPPORTED */ - public static final int PLAYBACK_OFFLOAD_NOT_SUPPORTED = - AudioManager.PLAYBACK_OFFLOAD_NOT_SUPPORTED; - /** See AudioManager#PLAYBACK_OFFLOAD_SUPPORTED */ - public static final int PLAYBACK_OFFLOAD_SUPPORTED = AudioManager.PLAYBACK_OFFLOAD_SUPPORTED; - /** See AudioManager#PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED */ - public static final int PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED = - AudioManager.PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED; - /** * Flags which can apply to a buffer containing a media sample. Possible flag values are {@link * #BUFFER_FLAG_KEY_FRAME}, {@link #BUFFER_FLAG_END_OF_STREAM}, {@link #BUFFER_FLAG_LAST_SAMPLE}, diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java index 74d5b5c0da..3e6c7d1c7b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java @@ -1815,13 +1815,13 @@ public final class DefaultAudioSink implements AudioSink { AudioFormat audioFormat = getAudioFormat(format.sampleRate, channelConfig, encoding); switch (getOffloadedPlaybackSupport(audioFormat, audioAttributes.getAudioAttributesV21())) { - case C.PLAYBACK_OFFLOAD_NOT_SUPPORTED: + case AudioManager.PLAYBACK_OFFLOAD_NOT_SUPPORTED: return false; - case C.PLAYBACK_OFFLOAD_SUPPORTED: + case AudioManager.PLAYBACK_OFFLOAD_SUPPORTED: boolean isGapless = format.encoderDelay != 0 || format.encoderPadding != 0; boolean gaplessSupportRequired = offloadMode == OFFLOAD_MODE_ENABLED_GAPLESS_REQUIRED; return !isGapless || !gaplessSupportRequired; - case C.PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED: + case AudioManager.PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED: return true; default: throw new IllegalStateException(); @@ -1829,22 +1829,20 @@ public final class DefaultAudioSink implements AudioSink { } @RequiresApi(29) - // Return values of AudioManager.getPlaybackOffloadSupport are equal to C.AudioManagerOffloadMode. - @SuppressLint("WrongConstant") - @C.AudioManagerOffloadMode + @SuppressLint("InlinedApi") private int getOffloadedPlaybackSupport( AudioFormat audioFormat, android.media.AudioAttributes audioAttributes) { if (Util.SDK_INT >= 31) { return AudioManager.getPlaybackOffloadSupport(audioFormat, audioAttributes); } if (!AudioManager.isOffloadedPlaybackSupported(audioFormat, audioAttributes)) { - return C.PLAYBACK_OFFLOAD_NOT_SUPPORTED; + return AudioManager.PLAYBACK_OFFLOAD_NOT_SUPPORTED; } // Manual testing has shown that Pixels on Android 11 support gapless offload. if (Util.SDK_INT == 30 && Util.MODEL.startsWith("Pixel")) { - return C.PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED; + return AudioManager.PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED; } - return C.PLAYBACK_OFFLOAD_SUPPORTED; + return AudioManager.PLAYBACK_OFFLOAD_SUPPORTED; } private static boolean isOffloadedPlayback(AudioTrack audioTrack) {