mirror of
https://github.com/androidx/media.git
synced 2025-05-07 15:40:37 +08:00
Force external surround sound flag if requested by device
Some FireOS6 devices ask to force the external surround global
flag and ignore any signals from the HDMI connection.
This is the equivalent change of e341944d1e
PiperOrigin-RevId: 614634499
(cherry picked from commit 410c0492cc9c7888df7a5283c5ebf8d99bf9c0cc)
This commit is contained in:
parent
a85d9e251c
commit
fffbf9ac4e
@ -20,6 +20,7 @@ import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||
import static java.lang.Math.max;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@ -90,6 +91,13 @@ public final class AudioCapabilities {
|
||||
/** Global settings key for devices that can specify external surround sound. */
|
||||
private static final String EXTERNAL_SURROUND_SOUND_KEY = "external_surround_sound_enabled";
|
||||
|
||||
/**
|
||||
* Global setting key for devices that want to force the usage of {@link
|
||||
* #EXTERNAL_SURROUND_SOUND_KEY} over other signals like HDMI.
|
||||
*/
|
||||
private static final String FORCE_EXTERNAL_SURROUND_SOUND_KEY =
|
||||
"use_external_surround_sound_flag";
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getCapabilities(Context, AudioAttributes, AudioDeviceInfo)} instead.
|
||||
*/
|
||||
@ -168,12 +176,17 @@ public final class AudioCapabilities {
|
||||
getAudioProfiles(Ints.toArray(supportedEncodings.build()), DEFAULT_MAX_CHANNEL_COUNT));
|
||||
}
|
||||
|
||||
if (deviceMaySetExternalSurroundSoundGlobalSetting()
|
||||
&& Global.getInt(context.getContentResolver(), EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) {
|
||||
ContentResolver contentResolver = context.getContentResolver();
|
||||
boolean forceExternalSurroundSoundSetting =
|
||||
Global.getInt(contentResolver, FORCE_EXTERNAL_SURROUND_SOUND_KEY, 0) == 1;
|
||||
if ((forceExternalSurroundSoundSetting || deviceMaySetExternalSurroundSoundGlobalSetting())
|
||||
&& Global.getInt(contentResolver, EXTERNAL_SURROUND_SOUND_KEY, 0) == 1) {
|
||||
supportedEncodings.addAll(EXTERNAL_SURROUND_SOUND_ENCODINGS);
|
||||
}
|
||||
|
||||
if (intent != null && intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 1) {
|
||||
if (intent != null
|
||||
&& !forceExternalSurroundSoundSetting
|
||||
&& intent.getIntExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, 0) == 1) {
|
||||
@Nullable int[] encodingsFromExtra = intent.getIntArrayExtra(AudioManager.EXTRA_ENCODINGS);
|
||||
if (encodingsFromExtra != null) {
|
||||
supportedEncodings.addAll(Ints.asList(encodingsFromExtra));
|
||||
|
Loading…
x
Reference in New Issue
Block a user