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:
parent
9059e8835e
commit
15d50d0bf0
@ -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},
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user