package defpackage;

import android.content.Context;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.Spatializer;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import j$.util.Objects;
import java.util.List;

/* renamed from: ˋʝʽ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C1434 {

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final Handler f5831;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final Spatializer f5832;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final boolean f5833;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final C0079 f5834;

    public C1434(Context context, Runnable runnable, Boolean bool) {
        AudioManager audioManagerM9787 = context == null ? null : AbstractC4618.m9787(context);
        if (audioManagerM9787 == null || (bool != null && bool.booleanValue())) {
            this.f5832 = null;
            this.f5833 = false;
            this.f5831 = null;
            this.f5834 = null;
            return;
        }
        Spatializer spatializer = audioManagerM9787.getSpatializer();
        this.f5832 = spatializer;
        this.f5833 = spatializer.getImmersiveAudioLevel() != 0;
        Looper looperMyLooper = Looper.myLooper();
        looperMyLooper.getClass();
        Handler handler = new Handler(looperMyLooper);
        this.f5831 = handler;
        C0079 c0079 = new C0079(runnable);
        this.f5834 = c0079;
        spatializer.addOnSpatializerStateChangedListener(new ExecutorC4219(0, handler), c0079);
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void m4335() {
        C0079 c0079;
        Handler handler;
        Spatializer spatializer = this.f5832;
        if (spatializer == null || (c0079 = this.f5834) == null || (handler = this.f5831) == null) {
            return;
        }
        spatializer.removeOnSpatializerStateChangedListener(c0079);
        handler.removeCallbacksAndMessages(null);
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final boolean m4336() {
        Spatializer spatializer = this.f5832;
        return spatializer != null && spatializer.isAvailable();
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final boolean m4337(C1028 c1028, C3446 c3446) throws IllegalArgumentException {
        if (this.f5832 == null || !this.f5833 || !m4336() || !m4339()) {
            return false;
        }
        String str = c3446.f12929;
        int i = c3446.f12923;
        if (Objects.equals(str, "audio/eac3-joc")) {
            if (i == 16) {
                i = 12;
            }
        } else if (Objects.equals(str, "audio/iamf")) {
            if (i == -1) {
                i = 6;
            }
        } else if (Objects.equals(str, "audio/ac4") && (i == 18 || i == 21)) {
            i = 24;
        }
        int iM8141 = AbstractC3558.m8141(i);
        if (iM8141 == 0) {
            return false;
        }
        AudioFormat.Builder channelMask = new AudioFormat.Builder().setEncoding(2).setChannelMask(iM8141);
        int i2 = c3446.f12936;
        if (i2 != -1) {
            channelMask.setSampleRate(i2);
        }
        Spatializer spatializer = this.f5832;
        spatializer.getClass();
        return spatializer.canBeSpatialized(c1028.m3392(), channelMask.build());
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final List m4338() {
        if (this.f5832 == null || !this.f5833 || !m4336() || !m4339()) {
            C4421 c4421 = AbstractC2692.f10429;
            return C4471.f16684;
        }
        if (Build.VERSION.SDK_INT < 36) {
            return AbstractC2692.m6702(252);
        }
        Spatializer spatializer = this.f5832;
        spatializer.getClass();
        return spatializer.getSpatializedChannelMasks();
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final boolean m4339() {
        Spatializer spatializer = this.f5832;
        return spatializer != null && spatializer.isEnabled();
    }
}
