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
This commit is contained in:
ibaker 2022-02-04 16:16:46 +00:00 committed by Ian Baker
parent 0bf21f2e20
commit 14f9d9c62c
2 changed files with 7 additions and 33 deletions

View File

@ -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},

View File

@ -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) {