From 14f9d9c62ccd9d3d7b66f8279920b73037e7d630 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 --- .../main/java/androidx/media3/common/C.java | 24 ------------------- .../exoplayer/audio/DefaultAudioSink.java | 16 ++++++------- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/libraries/common/src/main/java/androidx/media3/common/C.java b/libraries/common/src/main/java/androidx/media3/common/C.java index 8eba741733..7bc08cb47a 100644 --- a/libraries/common/src/main/java/androidx/media3/common/C.java +++ b/libraries/common/src/main/java/androidx/media3/common/C.java @@ -508,30 +508,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}. - */ - @UnstableApi - @IntDef({ - PLAYBACK_OFFLOAD_NOT_SUPPORTED, - PLAYBACK_OFFLOAD_SUPPORTED, - PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED - }) - @Retention(RetentionPolicy.SOURCE) - public @interface AudioManagerOffloadMode {} - /** See AudioManager#PLAYBACK_OFFLOAD_NOT_SUPPORTED */ - @UnstableApi - public static final int PLAYBACK_OFFLOAD_NOT_SUPPORTED = - AudioManager.PLAYBACK_OFFLOAD_NOT_SUPPORTED; - /** See AudioManager#PLAYBACK_OFFLOAD_SUPPORTED */ - @UnstableApi - public static final int PLAYBACK_OFFLOAD_SUPPORTED = AudioManager.PLAYBACK_OFFLOAD_SUPPORTED; - /** See AudioManager#PLAYBACK_OFFLOAD_GAPLESS_SUPPORTED */ - @UnstableApi - 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/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java index f0c5db919d..bfdfb580b9 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java @@ -1824,13 +1824,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(); @@ -1838,22 +1838,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) {