mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-30 11:02:31 -06:00
164 lines
7.6 KiB
Java
164 lines
7.6 KiB
Java
package androidx.media3.exoplayer.audio;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.ContentResolver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.IntentFilter;
|
|
import android.database.ContentObserver;
|
|
import android.media.AudioDeviceCallback;
|
|
import android.media.AudioDeviceInfo;
|
|
import android.media.AudioManager;
|
|
import android.net.Uri;
|
|
import android.os.Handler;
|
|
import androidx.media3.common.util.Assertions;
|
|
import androidx.media3.common.util.Util;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class AudioCapabilitiesReceiver {
|
|
AudioCapabilities audioCapabilities;
|
|
private final AudioDeviceCallbackV23 audioDeviceCallback;
|
|
private final Context context;
|
|
private final ExternalSurroundSoundSettingObserver externalSurroundSoundSettingObserver;
|
|
private final Handler handler;
|
|
private final BroadcastReceiver hdmiAudioPlugBroadcastReceiver;
|
|
private final Listener listener;
|
|
private boolean registered;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public interface Listener {
|
|
void onAudioCapabilitiesChanged(AudioCapabilities audioCapabilities);
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public AudioCapabilitiesReceiver(Context context, Listener listener) {
|
|
Context applicationContext = context.getApplicationContext();
|
|
this.context = applicationContext;
|
|
this.listener = (Listener) Assertions.checkNotNull(listener);
|
|
Handler createHandlerForCurrentOrMainLooper = Util.createHandlerForCurrentOrMainLooper();
|
|
this.handler = createHandlerForCurrentOrMainLooper;
|
|
Object[] objArr = 0;
|
|
this.audioDeviceCallback = Util.SDK_INT >= 23 ? new AudioDeviceCallbackV23() : null;
|
|
this.hdmiAudioPlugBroadcastReceiver = Util.SDK_INT >= 21 ? new HdmiAudioPlugBroadcastReceiver() : null;
|
|
Uri externalSurroundSoundGlobalSettingUri = AudioCapabilities.getExternalSurroundSoundGlobalSettingUri();
|
|
this.externalSurroundSoundSettingObserver = externalSurroundSoundGlobalSettingUri != null ? new ExternalSurroundSoundSettingObserver(createHandlerForCurrentOrMainLooper, applicationContext.getContentResolver(), externalSurroundSoundGlobalSettingUri) : null;
|
|
}
|
|
|
|
public AudioCapabilities register() {
|
|
AudioDeviceCallbackV23 audioDeviceCallbackV23;
|
|
if (this.registered) {
|
|
return (AudioCapabilities) Assertions.checkNotNull(this.audioCapabilities);
|
|
}
|
|
this.registered = true;
|
|
ExternalSurroundSoundSettingObserver externalSurroundSoundSettingObserver = this.externalSurroundSoundSettingObserver;
|
|
if (externalSurroundSoundSettingObserver != null) {
|
|
externalSurroundSoundSettingObserver.register();
|
|
}
|
|
if (Util.SDK_INT >= 23 && (audioDeviceCallbackV23 = this.audioDeviceCallback) != null) {
|
|
Api23.registerAudioDeviceCallback(this.context, audioDeviceCallbackV23, this.handler);
|
|
}
|
|
AudioCapabilities capabilities = AudioCapabilities.getCapabilities(this.context, this.hdmiAudioPlugBroadcastReceiver != null ? this.context.registerReceiver(this.hdmiAudioPlugBroadcastReceiver, new IntentFilter("android.media.action.HDMI_AUDIO_PLUG"), null, this.handler) : null);
|
|
this.audioCapabilities = capabilities;
|
|
return capabilities;
|
|
}
|
|
|
|
public void unregister() {
|
|
AudioDeviceCallbackV23 audioDeviceCallbackV23;
|
|
if (this.registered) {
|
|
this.audioCapabilities = null;
|
|
if (Util.SDK_INT >= 23 && (audioDeviceCallbackV23 = this.audioDeviceCallback) != null) {
|
|
Api23.unregisterAudioDeviceCallback(this.context, audioDeviceCallbackV23);
|
|
}
|
|
BroadcastReceiver broadcastReceiver = this.hdmiAudioPlugBroadcastReceiver;
|
|
if (broadcastReceiver != null) {
|
|
this.context.unregisterReceiver(broadcastReceiver);
|
|
}
|
|
ExternalSurroundSoundSettingObserver externalSurroundSoundSettingObserver = this.externalSurroundSoundSettingObserver;
|
|
if (externalSurroundSoundSettingObserver != null) {
|
|
externalSurroundSoundSettingObserver.unregister();
|
|
}
|
|
this.registered = false;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void onNewAudioCapabilities(AudioCapabilities audioCapabilities) {
|
|
if (!this.registered || audioCapabilities.equals(this.audioCapabilities)) {
|
|
return;
|
|
}
|
|
this.audioCapabilities = audioCapabilities;
|
|
this.listener.onAudioCapabilitiesChanged(audioCapabilities);
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
private final class HdmiAudioPlugBroadcastReceiver extends BroadcastReceiver {
|
|
private HdmiAudioPlugBroadcastReceiver() {
|
|
}
|
|
|
|
@Override // android.content.BroadcastReceiver
|
|
public void onReceive(Context context, Intent intent) {
|
|
if (isInitialStickyBroadcast()) {
|
|
return;
|
|
}
|
|
AudioCapabilitiesReceiver.this.onNewAudioCapabilities(AudioCapabilities.getCapabilities(context, intent));
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
private final class ExternalSurroundSoundSettingObserver extends ContentObserver {
|
|
private final ContentResolver resolver;
|
|
private final Uri settingUri;
|
|
|
|
public ExternalSurroundSoundSettingObserver(Handler handler, ContentResolver contentResolver, Uri uri) {
|
|
super(handler);
|
|
this.resolver = contentResolver;
|
|
this.settingUri = uri;
|
|
}
|
|
|
|
public void register() {
|
|
this.resolver.registerContentObserver(this.settingUri, false, this);
|
|
}
|
|
|
|
public void unregister() {
|
|
this.resolver.unregisterContentObserver(this);
|
|
}
|
|
|
|
@Override // android.database.ContentObserver
|
|
public void onChange(boolean z) {
|
|
AudioCapabilitiesReceiver audioCapabilitiesReceiver = AudioCapabilitiesReceiver.this;
|
|
audioCapabilitiesReceiver.onNewAudioCapabilities(AudioCapabilities.getCapabilities(audioCapabilitiesReceiver.context));
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
private final class AudioDeviceCallbackV23 extends AudioDeviceCallback {
|
|
private AudioDeviceCallbackV23() {
|
|
}
|
|
|
|
@Override // android.media.AudioDeviceCallback
|
|
public void onAudioDevicesAdded(AudioDeviceInfo[] audioDeviceInfoArr) {
|
|
AudioCapabilitiesReceiver audioCapabilitiesReceiver = AudioCapabilitiesReceiver.this;
|
|
audioCapabilitiesReceiver.onNewAudioCapabilities(AudioCapabilities.getCapabilities(audioCapabilitiesReceiver.context));
|
|
}
|
|
|
|
@Override // android.media.AudioDeviceCallback
|
|
public void onAudioDevicesRemoved(AudioDeviceInfo[] audioDeviceInfoArr) {
|
|
AudioCapabilitiesReceiver audioCapabilitiesReceiver = AudioCapabilitiesReceiver.this;
|
|
audioCapabilitiesReceiver.onNewAudioCapabilities(AudioCapabilities.getCapabilities(audioCapabilitiesReceiver.context));
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
private static final class Api23 {
|
|
public static void registerAudioDeviceCallback(Context context, AudioDeviceCallback audioDeviceCallback, Handler handler) {
|
|
((AudioManager) Assertions.checkNotNull((AudioManager) context.getSystemService("audio"))).registerAudioDeviceCallback(audioDeviceCallback, handler);
|
|
}
|
|
|
|
public static void unregisterAudioDeviceCallback(Context context, AudioDeviceCallback audioDeviceCallback) {
|
|
((AudioManager) Assertions.checkNotNull((AudioManager) context.getSystemService("audio"))).unregisterAudioDeviceCallback(audioDeviceCallback);
|
|
}
|
|
|
|
private Api23() {
|
|
}
|
|
}
|
|
}
|