mirror of
https://github.com/samsonjs/media.git
synced 2026-03-28 09:55:48 +00: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 ofe341944d1ePiperOrigin-RevId: 614634499 (cherry picked from commit410c0492cc)
This commit is contained in:
parent
a85d9e251c
commit
fffbf9ac4e
1 changed files with 16 additions and 3 deletions
|
|
@ -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…
Reference in a new issue