package defpackage;

import android.content.Context;
import android.media.AudioDeviceInfo;
import android.media.AudioTrack;
import android.media.PlaybackParams;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import androidx.media3.common.audio.AudioProcessor$UnhandledAudioFormatException;
import androidx.media3.exoplayer.audio.AudioOutput$WriteException;
import androidx.media3.exoplayer.audio.AudioOutputProvider$ConfigurationException;
import androidx.media3.exoplayer.audio.AudioOutputProvider$InitializationException;
import androidx.media3.exoplayer.audio.AudioSink$ConfigurationException;
import androidx.media3.exoplayer.audio.AudioSink$InitializationException;
import androidx.media3.exoplayer.audio.AudioSink$UnexpectedDiscontinuityException;
import androidx.media3.exoplayer.audio.AudioSink$WriteException;
import j$.util.Objects;
import java.math.RoundingMode;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayDeque;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: renamed from: ˆʔʕᵸ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C0784 implements InterfaceC2890 {

    /* JADX INFO: renamed from: ˋʿᐧ, reason: contains not printable characters */
    public static final AtomicInteger f3469 = new AtomicInteger();

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final ᵯᵨᵲ f3470;

    /* JADX INFO: renamed from: ʽᵡᵢᵾ, reason: contains not printable characters */
    public boolean f3471;

    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    public boolean f3472;

    /* JADX INFO: renamed from: ʿᵿʽᵞ, reason: contains not printable characters */
    public long f3473;

    /* JADX INFO: renamed from: ˀᵗ, reason: contains not printable characters */
    public boolean f3474;

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public int f3475;

    /* JADX INFO: renamed from: ˁʢᵛ, reason: contains not printable characters */
    public int f3476;

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public ByteBuffer f3477;

    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public long f3478;

    /* JADX INFO: renamed from: ˈⁱᵡ, reason: contains not printable characters */
    public int f3479;

    /* JADX INFO: renamed from: ˉᵲ, reason: contains not printable characters */
    public C1668 f3480;

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public float f3481;

    /* JADX INFO: renamed from: ˊˌˊ, reason: contains not printable characters */
    public AudioDeviceInfo f3482;

    /* JADX INFO: renamed from: ˊᵙᵾᵲ, reason: contains not printable characters */
    public InterfaceC4099 f3483;

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public boolean f3484;

    /* JADX INFO: renamed from: ˊᵨᵧ, reason: contains not printable characters */
    public C4683 f3485;

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final ArrayDeque f3486;

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public ByteBuffer f3487;

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public InterfaceC3982 f3488;

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public C5543 f3489;

    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    public long f3490;

    /* JADX INFO: renamed from: ˏːˆ, reason: contains not printable characters */
    public C4000 f3491;

    /* JADX INFO: renamed from: ˏᵩʨ, reason: contains not printable characters */
    public long f3492;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final C3125 f3493;

    /* JADX INFO: renamed from: ˑʢ, reason: contains not printable characters */
    public boolean f3494;

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public boolean f3495;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public C4688 f3496;

    /* JADX INFO: renamed from: ᵛˀˊ, reason: contains not printable characters */
    public boolean f3497;

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public boolean f3498;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public C5543 f3499;

    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public C2136 f3500;

    /* JADX INFO: renamed from: ᵞᵛᵘ, reason: contains not printable characters */
    public C0191 f3501;

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public C5540 f3502;

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public long f3503;

    /* JADX INFO: renamed from: ᵡᵶ, reason: contains not printable characters */
    public long f3504;

    /* JADX INFO: renamed from: ᵡᵶᵬʤ, reason: contains not printable characters */
    public Handler f3505;

    /* JADX INFO: renamed from: ᵨˈʼﹶ, reason: contains not printable characters */
    public boolean f3506;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final C3579 f3507;

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public boolean f3508;

    /* JADX INFO: renamed from: ᵪᵹᵥᵻ, reason: contains not printable characters */
    public C5540 f3509;

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public final C5021 f3510;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public long f3511;

    /* JADX INFO: renamed from: ᵱʡˏ, reason: contains not printable characters */
    public C1316 f3512;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public C1965 f3513;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final Context f3514;

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public boolean f3515;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final C2598 f3516;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public long f3517;

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public final C5021 f3518;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final C4990 f3519;

    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    public int f3520;

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public final int f3521;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final C1276 f3522;

    public C0784(ᵚʿᵴ r9) {
        int deviceId;
        Context context = (Context) r9.ʽˈˋ;
        this.f3514 = context == null ? null : context.getApplicationContext();
        this.f3485 = C4683.f17774;
        this.f3470 = (ᵯᵨᵲ) r9.ᵷᵺʾᵖ;
        this.f3521 = 0;
        this.f3483 = (C0453) r9.ᵻˈᵦʼ;
        C3125 c3125 = new C3125();
        this.f3493 = c3125;
        C4990 c4990 = new C4990();
        c4990.f18915 = AbstractC0956.f4216;
        this.f3519 = c4990;
        this.f3507 = new C3579();
        this.f3522 = new C1276();
        this.f3516 = AbstractC4509.m9557(c4990, c3125);
        this.f3481 = 1.0f;
        this.f3479 = 0;
        this.f3501 = new C0191();
        C4688 c4688 = C4688.f17810;
        this.f3499 = new C5543(c4688, 0L, 0L);
        this.f3496 = c4688;
        this.f3508 = false;
        this.f3486 = new ArrayDeque();
        this.f3518 = new C5021();
        this.f3510 = new C5021();
        int i = -1;
        if (Build.VERSION.SDK_INT >= 34 && context != null && (deviceId = context.getDeviceId()) != 0 && deviceId != -1) {
            i = deviceId;
        }
        this.f3476 = i;
    }

    /* JADX WARN: Removed duplicated region for block: B:48:0x00c0  */
    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static int m2799(int i, ByteBuffer byteBuffer) {
        int i2;
        int i3;
        byte b;
        int i4;
        byte b2;
        int i5;
        int i6;
        int i7;
        int i8;
        if (i == 20) {
            if ((byteBuffer.get(5) & 2) == 0) {
                i2 = 0;
            } else {
                byte b3 = byteBuffer.get(26);
                int i9 = 28;
                int i10 = 28;
                for (int i11 = 0; i11 < b3; i11++) {
                    i10 += byteBuffer.get(i11 + 27);
                }
                byte b4 = byteBuffer.get(i10 + 26);
                for (int i12 = 0; i12 < b4; i12++) {
                    i9 += byteBuffer.get(i10 + 27 + i12);
                }
                i2 = i10 + i9;
            }
            int i13 = byteBuffer.get(i2 + 26) + 27 + i2;
            return (int) ((ᵹˊᵫˋ.ᵪᵹᵥᵻ(byteBuffer.get(i13), byteBuffer.limit() - i13 > 1 ? byteBuffer.get(i13 + 1) : (byte) 0) * 48000) / 1000000);
        }
        if (i != 30) {
            switch (i) {
                case 5:
                case C5224.STRING_SET_FIELD_NUMBER /* 6 */:
                    break;
                case C5224.DOUBLE_FIELD_NUMBER /* 7 */:
                case C5224.BYTES_FIELD_NUMBER /* 8 */:
                    break;
                case 9:
                    int iPosition = byteBuffer.position();
                    String str = AbstractC0956.f4222;
                    int iReverseBytes = byteBuffer.getInt(iPosition);
                    if (byteBuffer.order() != ByteOrder.BIG_ENDIAN) {
                        iReverseBytes = Integer.reverseBytes(iReverseBytes);
                    }
                    if ((iReverseBytes & (-2097152)) != -2097152 || (i6 = (iReverseBytes >>> 19) & 3) == 1 || (i7 = (iReverseBytes >>> 17) & 3) == 0) {
                        i5 = -1;
                    } else {
                        int i14 = (iReverseBytes >>> 12) & 15;
                        int i15 = (iReverseBytes >>> 10) & 3;
                        if (i14 != 0 && i14 != 15 && i15 != 3) {
                            i5 = 1152;
                            if (i7 != 1) {
                                if (i7 != 2) {
                                    if (i7 != 3) {
                                        ᵷᵝˎ.ᵷᵺʾᵖ();
                                        return 0;
                                    }
                                    i5 = 384;
                                }
                            } else if (i6 != 3) {
                                i5 = 576;
                            }
                        }
                    }
                    if (i5 != -1) {
                        return i5;
                    }
                    ᵷᵝˎ.ᵷᵺʾᵖ();
                    return 0;
                case 10:
                    return 1024;
                case 11:
                case 12:
                    return 2048;
                default:
                    switch (i) {
                        case 14:
                            int iPosition2 = byteBuffer.position();
                            int iLimit = byteBuffer.limit() - 10;
                            int i16 = iPosition2;
                            while (true) {
                                if (i16 <= iLimit) {
                                    String str2 = AbstractC0956.f4222;
                                    int iReverseBytes2 = byteBuffer.getInt(i16 + 4);
                                    if (byteBuffer.order() != ByteOrder.BIG_ENDIAN) {
                                        iReverseBytes2 = Integer.reverseBytes(iReverseBytes2);
                                    }
                                    if ((iReverseBytes2 & (-2)) == -126718022) {
                                        i8 = i16 - iPosition2;
                                    } else {
                                        i16++;
                                    }
                                } else {
                                    i8 = -1;
                                }
                            }
                            if (i8 == -1) {
                                return 0;
                            }
                            return (40 << ((byteBuffer.get((byteBuffer.position() + i8) + (((byteBuffer.get((byteBuffer.position() + i8) + 7) & 255) == 187 ? (byte) 1 : (byte) 0) != 0 ? 9 : 8)) >> 4) & 7)) * 16;
                        case 15:
                            return 512;
                        case 16:
                            return 1024;
                        case 17:
                            byte[] bArr = new byte[16];
                            int iPosition3 = byteBuffer.position();
                            byteBuffer.get(bArr);
                            byteBuffer.position(iPosition3);
                            return ˑᵕʾ.ᵶˇᵱ(new C3180(16, bArr)).f19365;
                        case 18:
                            break;
                        default:
                            ᵕᵩʽᵲ.ᵪᵹᵥᵻ(AbstractC2704.m6517(i, "Unexpected audio encoding: "));
                            return 0;
                    }
                    break;
            }
            if (((byteBuffer.get(byteBuffer.position() + 5) & 248) >> 3) > 10) {
                return ᵷˆᵣ.ᵲᵶᵳˈ[((byteBuffer.get(byteBuffer.position() + 4) & 192) >> 6) != 3 ? (byteBuffer.get(byteBuffer.position() + 4) & 48) >> 4 : 3] * 256;
            }
            return 1536;
        }
        if (byteBuffer.getInt(0) == -233094848 || byteBuffer.getInt(0) == -398277519) {
            return 1024;
        }
        if (byteBuffer.getInt(0) == 622876772) {
            return 4096;
        }
        int iPosition4 = byteBuffer.position();
        byte b5 = byteBuffer.get(iPosition4);
        if (b5 != -2) {
            if (b5 == -1) {
                i3 = (byteBuffer.get(iPosition4 + 4) & 7) << 4;
                b2 = byteBuffer.get(iPosition4 + 7);
            } else if (b5 != 31) {
                i3 = (byteBuffer.get(iPosition4 + 4) & 1) << 6;
                b = byteBuffer.get(iPosition4 + 5);
            } else {
                i3 = (byteBuffer.get(iPosition4 + 5) & 7) << 4;
                b2 = byteBuffer.get(iPosition4 + 6);
            }
            i4 = b2 & 60;
            return (((i4 >> 2) | i3) + 1) * 32;
        }
        i3 = (byteBuffer.get(iPosition4 + 5) & 1) << 6;
        b = byteBuffer.get(iPosition4 + 4);
        i4 = b & 252;
        return (((i4 >> 2) | i3) + 1) * 32;
    }

    @Override // defpackage.InterfaceC2890
    public final void flush() {
        C2201 c2201;
        if (m2802()) {
            this.f3511 = 0L;
            this.f3517 = 0L;
            this.f3478 = 0L;
            this.f3490 = 0L;
            int i = 0;
            this.f3497 = false;
            this.f3520 = 0;
            this.f3499 = new C5543(this.f3496, 0L, 0L);
            this.f3503 = 0L;
            this.f3489 = null;
            this.f3486.clear();
            this.f3477 = null;
            this.f3475 = 0;
            this.f3487 = null;
            this.f3498 = false;
            this.f3484 = false;
            this.f3515 = false;
            this.f3519.f18916 = 0L;
            C1316 c1316 = (C1316) this.f3502.f20921;
            this.f3512 = c1316;
            c1316.m3837();
            this.f3513 = null;
            C5540 c5540 = this.f3509;
            if (c5540 != null) {
                this.f3502 = c5540;
                this.f3509 = null;
            }
            f3469.incrementAndGet();
            C4000 c4000 = this.f3491;
            if (c4000.f15329.f5687.getPlayState() == 3) {
                c4000.f15324.pause();
            }
            int i2 = Build.VERSION.SDK_INT;
            if (i2 >= 29 && c4000.m8777()) {
                C1704 c1704 = c4000.f15328;
                c1704.getClass();
                C1704.m4692(c1704);
            }
            if (i2 >= 24 && (c2201 = c4000.f15319) != null) {
                C2201.m5776(c2201);
                c4000.f15319 = null;
            }
            AudioTrack audioTrack = c4000.f15324;
            C3252 c3252 = c4000.f15323;
            Handler handlerM3260 = AbstractC0956.m3260(null);
            synchronized (C4000.f15310) {
                try {
                    if (C4000.f15308 == null) {
                        C4000.f15308 = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryC3502());
                    }
                    C4000.f15309++;
                    C4000.f15308.schedule(new RunnableC3304(audioTrack, handlerM3260, c3252, i), 20L, TimeUnit.MILLISECONDS);
                } catch (Throwable th) {
                    throw th;
                }
            }
            this.f3491 = null;
        }
        C5021 c5021 = this.f3510;
        c5021.f19027 = null;
        c5021.f19028 = -9223372036854775807L;
        c5021.f19026 = -9223372036854775807L;
        C5021 c50212 = this.f3518;
        c50212.f19027 = null;
        c50212.f19028 = -9223372036854775807L;
        c50212.f19026 = -9223372036854775807L;
        this.f3473 = 0L;
        this.f3504 = 0L;
        Handler handler = this.f3505;
        if (handler != null) {
            handler.removeCallbacksAndMessages(null);
        }
    }

    @Override // defpackage.InterfaceC2890
    public final void reset() {
        flush();
        C2822 c2822ListIterator = this.f3516.listIterator(0);
        while (c2822ListIterator.hasNext()) {
            ((InterfaceC2497) c2822ListIterator.next()).reset();
        }
        this.f3507.reset();
        this.f3522.reset();
        C1316 c1316 = this.f3512;
        if (c1316 != null) {
            AbstractC4509 abstractC4509 = c1316.f5484;
            for (int i = 0; i < abstractC4509.size(); i++) {
                InterfaceC2497 interfaceC2497 = (InterfaceC2497) abstractC4509.get(i);
                interfaceC2497.mo4911(C2995.f11537);
                interfaceC2497.reset();
            }
            c1316.f5482.clear();
            c1316.f5483 = new ByteBuffer[0];
            C2917 c2917 = C2917.f11219;
            c1316.f5485 = false;
        }
        this.f3494 = false;
    }

    @Override // defpackage.InterfaceC2890
    public final void setPreferredDevice(AudioDeviceInfo audioDeviceInfo) {
        this.f3482 = audioDeviceInfo;
        C4000 c4000 = this.f3491;
        if (c4000 != null) {
            c4000.f15324.setPreferredDevice(audioDeviceInfo);
        }
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final boolean mo2800() {
        if (m2802()) {
            return this.f3484 && !mo2838();
        }
        return true;
    }

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public final void m2801() {
        if (this.f3498) {
            return;
        }
        this.f3498 = true;
        if (this.f3491.m8777()) {
            this.f3515 = false;
        }
        C4000 c4000 = this.f3491;
        if (c4000.f15326) {
            return;
        }
        c4000.f15326 = true;
        C1371 c1371 = c4000.f15329;
        long jM8776 = c4000.m8776();
        c1371.f5673 = c1371.m3917();
        c1371.f5662.getClass();
        c1371.f5666 = AbstractC0956.m3214(SystemClock.elapsedRealtime());
        c1371.f5672 = jM8776;
        c4000.f15324.stop();
        c4000.f15318 = 0;
    }

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public final boolean m2802() {
        return this.f3491 != null;
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ˈᵲᵢ, reason: contains not printable characters */
    public final void mo2803(C2353 c2353) {
        ((C0453) this.f3483).f2472 = c2353;
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ˉᵲ, reason: contains not printable characters */
    public final void mo2804(InterfaceC3982 interfaceC3982) {
        this.f3488 = interfaceC3982;
    }

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public final boolean m2805() throws AudioSink$InitializationException {
        C4000 c4000M2815;
        C5021 c5021 = this.f3518;
        if (((Exception) c5021.f19027) != null && (f3469.get() > 0 || SystemClock.elapsedRealtime() < c5021.f19026)) {
            return false;
        }
        try {
            c4000M2815 = m2815((C2558) this.f3502.f20918);
        } catch (AudioSink$InitializationException e) {
            int i = ((C2558) this.f3502.f20918).f9900;
            while (true) {
                C5540 c5540 = this.f3502;
                if (i <= 1000000) {
                    boolean z = ((C2558) c5540.f20918).f9893;
                    throw e;
                }
                int i2 = i / 2;
                int i3 = c5540.f20916;
                if (i3 == -1) {
                    i3 = 1;
                }
                int i4 = i2 % i3;
                int i5 = i4 != 0 ? (i3 - i4) + i2 : i2;
                C1239 c1239M6287 = ((C2558) c5540.f20918).m6287();
                c1239M6287.f5229 = i5;
                C2558 c2558 = new C2558(c1239M6287);
                try {
                    c4000M2815 = m2815(c2558);
                    C5540 c55402 = this.f3502;
                    this.f3502 = new C5540((C5286) c55402.f20917, (C5286) c55402.f20920, c55402.f20919, c55402.f20916, c2558, (C1316) c55402.f20921);
                    break;
                } catch (AudioSink$InitializationException e2) {
                    e.addSuppressed(e2);
                    i = i5;
                }
            }
        }
        this.f3491 = c4000M2815;
        C1965 c1965 = new C1965(this, (C2558) this.f3502.f20918);
        this.f3513 = c1965;
        c4000M2815.f15323.m7413(c1965);
        if (this.f3491.m8777()) {
            C5540 c55403 = this.f3502;
            if (((C2558) c55403.f20918).f9897) {
                C4000 c4000 = this.f3491;
                C5286 c5286 = (C5286) c55403.f20917;
                c4000.m8781(c5286.f19961, c5286.f19971);
            }
        }
        C2136 c2136 = this.f3500;
        if (c2136 != null) {
            this.f3491.m8782(c2136);
        }
        if (m2802()) {
            this.f3491.f15324.setVolume(this.f3481);
        }
        this.f3501.getClass();
        AudioDeviceInfo audioDeviceInfo = this.f3482;
        if (audioDeviceInfo != null) {
            this.f3491.f15324.setPreferredDevice(audioDeviceInfo);
        }
        this.f3472 = true;
        int audioSessionId = this.f3491.f15324.getAudioSessionId();
        boolean z2 = audioSessionId != this.f3479;
        this.f3479 = audioSessionId;
        InterfaceC3982 interfaceC3982 = this.f3488;
        if (interfaceC3982 != null) {
            int i6 = ((C2558) this.f3502.f20918).f9895;
            interfaceC3982.m8750(new ˉᵠﹳᵘ(11));
            if (z2) {
                this.f3506 = true;
                C5540 c55404 = this.f3502;
                C1239 c1239M62872 = ((C2558) c55404.f20918).m6287();
                c1239M62872.f5220 = this.f3479;
                this.f3502 = new C5540((C5286) c55404.f20917, (C5286) c55404.f20920, c55404.f20919, c55404.f20916, new C2558(c1239M62872), (C1316) c55404.f20921);
                C5540 c55405 = this.f3509;
                if (c55405 != null) {
                    C1239 c1239M62873 = ((C2558) c55405.f20918).m6287();
                    c1239M62873.f5220 = this.f3479;
                    this.f3509 = new C5540((C5286) c55405.f20917, (C5286) c55405.f20920, c55405.f20919, c55405.f20916, new C2558(c1239M62873), (C1316) c55405.f20921);
                }
                this.f3488.m8749(this.f3479);
            }
        }
        return true;
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ˊᵙᵾᵲ, reason: contains not printable characters */
    public final void mo2806(C4683 c4683) {
        if (this.f3485.equals(c4683)) {
            return;
        }
        this.f3485 = c4683;
        if (this.f3474) {
            return;
        }
        m2807();
    }

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public final void m2807() {
        if (this.f3502 != null) {
            C5540 c5540 = this.f3509;
            if (c5540 != null) {
                this.f3502 = c5540;
                this.f3509 = null;
            }
            try {
                C2558 c2558M1885 = ((C0453) this.f3483).m1885(m2817((C5286) this.f3502.f20920));
                C5540 c55402 = this.f3502;
                this.f3502 = new C5540((C5286) c55402.f20917, (C5286) c55402.f20920, c55402.f20919, c55402.f20916, c2558M1885, (C1316) c55402.f20921);
            } catch (AudioOutputProvider$ConfigurationException e) {
                C1418.m4090(new AudioSink$ConfigurationException(e, (C5286) this.f3502.f20917));
                return;
            }
        }
        flush();
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ˊᵨᵧ, reason: contains not printable characters */
    public final void mo2808(float f) {
        if (this.f3481 != f) {
            this.f3481 = f;
            if (m2802()) {
                C4000 c4000 = this.f3491;
                c4000.f15324.setVolume(this.f3481);
            }
        }
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final void mo2809() {
        if (!this.f3484 && m2802() && m2837()) {
            m2801();
            this.f3484 = true;
        }
    }

    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    public final void m2810(long j) throws AudioSink$WriteException {
        ByteBuffer byteBuffer;
        m2813(j);
        if (this.f3487 != null) {
            return;
        }
        if (!this.f3512.m3838()) {
            ByteBuffer byteBuffer2 = this.f3477;
            if (byteBuffer2 != null) {
                m2832(byteBuffer2);
                m2813(j);
                return;
            }
            return;
        }
        while (!this.f3512.m3835()) {
            do {
                C1316 c1316 = this.f3512;
                if (c1316.m3838()) {
                    ByteBuffer byteBuffer3 = c1316.f5483[c1316.m3834()];
                    if (byteBuffer3.hasRemaining()) {
                        byteBuffer = byteBuffer3;
                    } else {
                        c1316.m3836(InterfaceC2497.f9685);
                        byteBuffer = c1316.f5483[c1316.m3834()];
                    }
                } else {
                    byteBuffer = InterfaceC2497.f9685;
                }
                if (byteBuffer.hasRemaining()) {
                    m2832(byteBuffer);
                    m2813(j);
                } else {
                    ByteBuffer byteBuffer4 = this.f3477;
                    if (byteBuffer4 == null || !byteBuffer4.hasRemaining()) {
                        return;
                    }
                    C1316 c13162 = this.f3512;
                    ByteBuffer byteBuffer5 = this.f3477;
                    if (c13162.m3838() && !c13162.f5485) {
                        c13162.m3836(byteBuffer5);
                    }
                }
            } while (this.f3487 == null);
            return;
        }
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public final int mo2811(C5286 c5286) {
        boolean z;
        if (!AbstractC0956.m3253(c5286.f19962) || c5286.f19962 == 2) {
            z = false;
        } else {
            C4753 c4753M10878 = c5286.m10878();
            c4753M10878.f18095 = 2;
            c5286 = new C5286(c4753M10878);
            z = true;
        }
        InterfaceC4099 interfaceC4099 = this.f3483;
        C4741 c4741M2817 = m2817(c5286);
        C0453 c0453 = (C0453) interfaceC4099;
        c0453.m1886(c4741M2817);
        C1801 c1801 = c0453.f2468;
        C5286 c52862 = c4741M2817.f18038;
        C4683 c4683 = c4741M2817.f18034;
        C0977 c0977M4950 = c1801.m4950(c4683, c52862);
        C4305 c4305 = new C4305();
        c4305.f16399 = (!Objects.equals(c52862.f19987, "audio/raw") ? c0453.f2467.m10348(c4683, c52862) != null : c52862.f19962 == 2) ? 0 : 2;
        c4305.f16397 = c0977M4950.f4273;
        c4305.f16398 = c0977M4950.f4271;
        c4305.f16400 = c0977M4950.f4272;
        int i = c4305.m9298().f13653;
        if (i != 1) {
            if (i != 2) {
                return 0;
            }
            if (!z) {
                return 2;
            }
        }
        return 1;
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final void mo2812(C2136 c2136) {
        this.f3500 = c2136;
    }

    /* JADX WARN: Removed duplicated region for block: B:51:0x00c4  */
    /* JADX INFO: renamed from: ˌᵨʠᵫ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m2813(long j) throws AudioSink$WriteException {
        InterfaceC3982 interfaceC3982;
        if (this.f3487 == null) {
            return;
        }
        C5021 c5021 = this.f3510;
        if (((Exception) c5021.f19027) != null && (f3469.get() > 0 || SystemClock.elapsedRealtime() < c5021.f19026)) {
            return;
        }
        int iRemaining = this.f3487.remaining();
        try {
            boolean zM8780 = this.f3491.m8780(this.f3475, j, this.f3487);
            this.f3492 = SystemClock.elapsedRealtime();
            c5021.f19027 = null;
            c5021.f19028 = -9223372036854775807L;
            c5021.f19026 = -9223372036854775807L;
            if (this.f3491.m8777()) {
                if (this.f3490 > 0) {
                    this.f3497 = false;
                }
                if (this.f3494 && (interfaceC3982 = this.f3488) != null && !zM8780 && !this.f3497) {
                    interfaceC3982.m8746();
                }
            }
            if (C5540.m11162(this.f3502)) {
                this.f3478 += (long) (iRemaining - this.f3487.remaining());
            }
            if (zM8780) {
                if (!C5540.m11162(this.f3502)) {
                    ᵻᵪ.ˌᴵ(this.f3487 == this.f3477);
                    this.f3490 = (((long) this.f3520) * ((long) this.f3475)) + this.f3490;
                }
                this.f3487 = null;
            }
        } catch (AudioOutput$WriteException e) {
            boolean z = e.f614;
            if (!z) {
                z = false;
            } else if (m2823() <= 0) {
                if (this.f3491.m8777()) {
                    boolean z2 = ((C2558) this.f3502.f20918).f9893;
                }
            }
            AudioSink$WriteException audioSink$WriteException = new AudioSink$WriteException(e.f613, (C5286) this.f3502.f20917, z);
            InterfaceC3982 interfaceC39822 = this.f3488;
            if (interfaceC39822 != null) {
                interfaceC39822.m8741(audioSink$WriteException);
            }
            if (z) {
                throw audioSink$WriteException;
            }
            c5021.m10358(audioSink$WriteException);
        }
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ˏːˆ, reason: contains not printable characters */
    public final void mo2814() {
        this.f3495 = true;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final C4000 m2815(C2558 c2558) throws AudioSink$InitializationException {
        try {
            return ((C0453) this.f3483).m1887(c2558);
        } catch (AudioOutputProvider$InitializationException e) {
            AudioSink$InitializationException audioSink$InitializationException = new AudioSink$InitializationException(c2558.f9890, c2558.f9892, c2558.f9895, c2558.f9900, (C5286) this.f3502.f20917, c2558.f9893, e);
            InterfaceC3982 interfaceC3982 = this.f3488;
            if (interfaceC3982 == null) {
                throw audioSink$InitializationException;
            }
            interfaceC3982.m8741(audioSink$InitializationException);
            throw audioSink$InitializationException;
        }
    }

    /* JADX INFO: renamed from: ˑʢ, reason: contains not printable characters */
    public final boolean m2816() {
        C5540 c5540 = this.f3502;
        return c5540 != null && ((C2558) c5540.f20918).f9894;
    }

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public final C4741 m2817(C5286 c5286) {
        C4741 c4741 = new C4741(c5286);
        c4741.f18034 = this.f3485;
        c4741.f18040 = this.f3521 != 0;
        c4741.f18036 = this.f3482;
        c4741.f18037 = this.f3479;
        c4741.f18039 = this.f3474;
        c4741.f18035 = -1;
        c4741.f18041 = this.f3476;
        return new C4741(c4741);
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final void mo2818(C0191 c0191) {
        if (this.f3501.equals(c0191)) {
            return;
        }
        c0191.getClass();
        if (this.f3491 != null) {
            this.f3501.getClass();
        }
        this.f3501 = c0191;
    }

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public final void m2819() {
        if (m2802()) {
            C4000 c4000 = this.f3491;
            C4688 c4688 = this.f3496;
            AudioTrack audioTrack = c4000.f15324;
            try {
                audioTrack.setPlaybackParams(new PlaybackParams().allowDefaults().setSpeed(AbstractC0956.m3270(c4688.f17813, 0.1f, c4000.f15316)).setPitch(AbstractC0956.m3270(c4688.f17811, 0.1f, 8.0f)).setAudioFallbackMode(2));
            } catch (IllegalArgumentException e) {
                ˋˀᵧ.ᵠˏˏ("Failed to set playback params", e);
            }
            C1371 c1371 = c4000.f15329;
            c1371.f5688 = audioTrack.getPlaybackParams().getSpeed();
            c1371.f5667.m5511(0);
            c1371.f5686 = 0L;
            c1371.f5670 = 0;
            c1371.f5664 = 0;
            c1371.f5679 = 0L;
            c1371.f5677 = -9223372036854775807L;
            c1371.f5680 = -9223372036854775807L;
            PlaybackParams playbackParams = this.f3491.f15324.getPlaybackParams();
            this.f3496 = new C4688(playbackParams.getSpeed(), playbackParams.getPitch());
        }
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final void mo2820() {
        ᵻᵪ.ˌᴵ(this.f3471);
        if (this.f3474) {
            return;
        }
        this.f3474 = true;
        m2807();
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵝᵶ, reason: contains not printable characters */
    public final void mo2821(InterfaceC4099 interfaceC4099) {
        C5304 c5304;
        if (interfaceC4099.equals(this.f3483)) {
            return;
        }
        C0453 c0453 = (C0453) this.f3483;
        C3252 c3252 = c0453.f2476;
        if (c3252 != null) {
            c3252.m7414();
        }
        C2939 c2939 = c0453.f2475;
        if (c2939 != null) {
            Context context = (Context) c2939.f11317;
            if (c2939.f11322) {
                c2939.f11326 = null;
                ˁᵨᵦ.ᵨᵣ(context).unregisterAudioDeviceCallback((C2066) c2939.f11320);
                if (Build.VERSION.SDK_INT >= 32 && (c5304 = (C5304) c2939.f11318) != null) {
                    c5304.m10891();
                    c2939.f11318 = null;
                }
                context.unregisterReceiver((C2911) c2939.f11327);
                C3779 c3779 = (C3779) c2939.f11323;
                if (c3779 != null) {
                    c3779.f14373.unregisterContentObserver(c3779);
                }
                c2939.f11322 = false;
            }
        }
        this.f3483 = interfaceC4099;
        C1668 c1668 = this.f3480;
        if (c1668 != null) {
            C0453 c04532 = (C0453) interfaceC4099;
            c04532.m1888();
            if (c04532.f2476 == null) {
                c04532.f2476 = new C3252(Thread.currentThread());
            }
            c04532.f2476.m7413(c1668);
        }
        m2807();
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public final void mo2822() {
        if (this.f3474) {
            this.f3474 = false;
            m2807();
        }
    }

    /* JADX INFO: renamed from: ᵠˏˏ, reason: contains not printable characters */
    public final long m2823() {
        if (!C5540.m11162(this.f3502)) {
            return this.f3490;
        }
        long j = this.f3478;
        long j2 = this.f3502.f20916;
        return ((j + j2) - 1) / j2;
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final void mo2824() {
        this.f3494 = false;
        if (m2802()) {
            C4000 c4000 = this.f3491;
            C1371 c1371 = c4000.f15329;
            c1371.f5686 = 0L;
            c1371.f5670 = 0;
            c1371.f5664 = 0;
            c1371.f5679 = 0L;
            c1371.f5677 = -9223372036854775807L;
            c1371.f5680 = -9223372036854775807L;
            if (c1371.f5666 == -9223372036854775807L) {
                c1371.f5667.m5511(0);
            }
            c1371.f5673 = c1371.m3917();
            if (!c4000.f15326 || c4000.m8777()) {
                c4000.f15324.pause();
            }
        }
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final void mo2825(int i) {
        if (i == 0 || i == -1) {
            i = -1;
        }
        if (this.f3476 == i) {
            return;
        }
        this.f3476 = i;
        m2807();
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵪᵹᵥᵻ, reason: contains not printable characters */
    public final long mo2826(boolean z) {
        ArrayDeque arrayDeque;
        long j;
        if (!m2802() || this.f3472) {
            return Long.MIN_VALUE;
        }
        long jMin = Math.min(this.f3491.m8779(), AbstractC0956.m3230(m2823(), ((C2558) this.f3502.f20918).f9890));
        while (true) {
            arrayDeque = this.f3486;
            if (arrayDeque.isEmpty() || jMin < ((C5543) arrayDeque.getFirst()).f20934) {
                break;
            }
            this.f3499 = (C5543) arrayDeque.remove();
        }
        C5543 c5543 = this.f3499;
        long jM3218 = jMin - c5543.f20934;
        long jM3269 = AbstractC0956.m3269(jM3218, c5543.f20935.f17813);
        boolean zIsEmpty = arrayDeque.isEmpty();
        ᵯᵨᵲ r2 = this.f3470;
        if (zIsEmpty) {
            C2810 c2810 = (C2810) r2.ᵨᵼⁱ;
            if (c2810.mo3847()) {
                if (c2810.f10797 >= 1024) {
                    long j2 = c2810.f10799;
                    C4739 c4739 = c2810.f10803;
                    c4739.getClass();
                    long jMo1288 = j2 - ((long) (c4739.f18030.mo1288() * (c4739.f18025 * c4739.f18015)));
                    int i = c2810.f10796.f11222;
                    int i2 = c2810.f10804.f11222;
                    long j3 = c2810.f10797;
                    jM3218 = i == i2 ? AbstractC0956.m3218(jM3218, jMo1288, j3, RoundingMode.DOWN) : AbstractC0956.m3218(jM3218, jMo1288 * ((long) i), j3 * ((long) i2), RoundingMode.DOWN);
                } else {
                    jM3218 = (long) (((double) c2810.f10798) * jM3218);
                }
            }
            C5543 c55432 = this.f3499;
            j = c55432.f20933 + jM3218;
            c55432.f20936 = jM3218 - jM3269;
        } else {
            C5543 c55433 = this.f3499;
            j = c55433.f20933 + jM3269 + c55433.f20936;
        }
        long j4 = ((C1330) r2.ᵔᵖᵹᵫ).f5541;
        long jM3230 = AbstractC0956.m3230(j4, ((C2558) this.f3502.f20918).f9890) + j;
        long j5 = this.f3473;
        if (j4 > j5) {
            long jM32302 = AbstractC0956.m3230(j4 - j5, ((C2558) this.f3502.f20918).f9890);
            this.f3473 = j4;
            this.f3504 += jM32302;
            if (this.f3505 == null) {
                this.f3505 = new Handler(Looper.myLooper());
            }
            this.f3505.removeCallbacksAndMessages(null);
            this.f3505.postDelayed(new RunnableC2846(13, this), 100L);
        }
        return jM3230;
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public final long mo2827() {
        if (!m2802()) {
            return -9223372036854775807L;
        }
        if (C5540.m11162(this.f3502)) {
            return AbstractC0956.m3230(this.f3491.f15324.getBufferSizeInFrames(), ((C2558) this.f3502.f20918).f9890);
        }
        long bufferSizeInFrames = this.f3491.f15324.getBufferSizeInFrames();
        int i = ᵽˊᵘᵬ.ᵶᵥᵝ(((C2558) this.f3502.f20918).f9895);
        ᵻᵪ.ˌᴵ(i != -2147483647);
        return AbstractC0956.m3218(bufferSizeInFrames, 1000000L, i, RoundingMode.DOWN);
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public final void mo2828() {
        this.f3494 = true;
        if (m2802()) {
            C4000 c4000 = this.f3491;
            C1371 c1371 = c4000.f15329;
            if (c1371.f5666 != -9223372036854775807L) {
                c1371.f5662.getClass();
                c1371.f5666 = AbstractC0956.m3214(SystemClock.elapsedRealtime());
            }
            c1371.f5682 = AbstractC0956.m3230(c1371.m3917(), c1371.f5676);
            c1371.f5667.m5511(0);
            if (!c4000.f15326 || c4000.m8777()) {
                c4000.f15324.play();
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v11, types: [java.lang.Object, ˎʞᵴˏ] */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵱʡˏ, reason: contains not printable characters */
    public final void mo2829(C5286 c5286, int[] iArr) throws AudioSink$ConfigurationException {
        C1316 c1316;
        C5286 c52862;
        int i;
        int iM3227;
        if (this.f3480 == null && this.f3514 != null) {
            ?? r0 = new Object() { // from class: ˎʞᵴˏ
            };
            this.f3480 = r0;
            C0453 c0453 = (C0453) this.f3483;
            c0453.m1888();
            if (c0453.f2476 == null) {
                c0453.f2476 = new C3252(Thread.currentThread());
            }
            c0453.f2476.m7413(r0);
        }
        String str = c5286.f19987;
        int i2 = c5286.f19984;
        int i3 = c5286.f19962;
        if ("audio/raw".equals(str)) {
            ᵻᵪ.ᵱᵽʡᵚ(AbstractC0956.m3253(i3));
            int iM32272 = AbstractC0956.m3227(i3) * i2;
            C3975 c3975 = new C3975(4);
            c3975.m7408(this.f3516);
            c3975.m7406(this.f3507);
            c3975.m8719((InterfaceC2497[]) this.f3470.ᵜᵪʾ);
            c1316 = new C1316(c3975.m8718());
            if (c1316.equals(this.f3512)) {
                c1316 = this.f3512;
            }
            int i4 = c5286.f19961;
            int i5 = c5286.f19971;
            C4990 c4990 = this.f3519;
            c4990.f18920 = i4;
            c4990.f18918 = i5;
            this.f3493.f11928 = iArr;
            C2917 c2917 = new C2917(c5286.f19966, i2, i3);
            try {
                AbstractC4509 abstractC4509 = c1316.f5484;
                if (c2917.equals(C2917.f11219)) {
                    throw new AudioProcessor$UnhandledAudioFormatException(c2917);
                }
                for (int i6 = 0; i6 < abstractC4509.size(); i6++) {
                    InterfaceC2497 interfaceC2497 = (InterfaceC2497) abstractC4509.get(i6);
                    C2917 c2917Mo4912 = interfaceC2497.mo4912(c2917);
                    if (interfaceC2497.mo3847()) {
                        ᵻᵪ.ˌᴵ(!c2917Mo4912.equals(C2917.f11219));
                        c2917 = c2917Mo4912;
                    }
                }
                int i7 = c2917.f11220;
                int i8 = c2917.f11221;
                C4753 c4753M10878 = c5286.m10878();
                c4753M10878.f18095 = i8;
                c4753M10878.f18113 = c2917.f11222;
                c4753M10878.f18090 = i7;
                c52862 = new C5286(c4753M10878);
                i = iM32272;
                iM3227 = AbstractC0956.m3227(i8) * i7;
            } catch (AudioProcessor$UnhandledAudioFormatException e) {
                throw new AudioSink$ConfigurationException(e, c5286);
            }
        } else {
            c1316 = new C1316(C2598.f10048);
            c52862 = c5286;
            i = -1;
            iM3227 = -1;
        }
        C1316 c13162 = c1316;
        C4741 c4741M2817 = m2817(c52862);
        C5286 c52863 = c4741M2817.f18038;
        try {
            C2558 c2558M1885 = ((C0453) this.f3483).m1885(c4741M2817);
            boolean z = c2558M1885.f9893;
            if (c2558M1885.f9895 == 0) {
                throw new AudioSink$ConfigurationException(AbstractC3589.m8112("Invalid output encoding (isOffload=", ")", z), c52863);
            }
            if (c2558M1885.f9892 == 0) {
                throw new AudioSink$ConfigurationException(AbstractC3589.m8112("Invalid output channel config (isOffload=", ")", z), c52863);
            }
            C5540 c5540 = new C5540(c5286, c52862, i, iM3227, c2558M1885, c13162);
            if (m2802()) {
                this.f3509 = c5540;
            } else {
                this.f3502 = c5540;
            }
        } catch (AudioOutputProvider$ConfigurationException e2) {
            throw new AudioSink$ConfigurationException(e2, c5286);
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:62:0x0100, code lost:
    
        if (r5 == 0) goto L63;
     */
    /* JADX WARN: Removed duplicated region for block: B:111:0x008d A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:21:0x0052  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x009f  */
    /* JADX WARN: Removed duplicated region for block: B:72:0x011e  */
    /* JADX WARN: Removed duplicated region for block: B:73:0x012b  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x0156  */
    /* JADX WARN: Removed duplicated region for block: B:84:0x0173  */
    /* JADX WARN: Removed duplicated region for block: B:94:0x019a  */
    /* JADX WARN: Removed duplicated region for block: B:95:0x01a5  */
    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean mo2830(int i, long j, ByteBuffer byteBuffer) throws AudioSink$WriteException, AudioSink$InitializationException {
        boolean zM2802;
        long j2;
        long j3;
        C5540 c5540;
        long j4;
        InterfaceC3982 interfaceC3982;
        ByteBuffer byteBuffer2 = this.f3477;
        ᵻᵪ.ᵱᵽʡᵚ(byteBuffer2 == null || byteBuffer == byteBuffer2);
        if (this.f3509 == null) {
            zM2802 = m2802();
            C5021 c5021 = this.f3518;
            if (zM2802) {
                try {
                    if (m2805()) {
                        c5021.f19027 = null;
                        c5021.f19028 = -9223372036854775807L;
                        c5021.f19026 = -9223372036854775807L;
                        if (this.f3472) {
                            this.f3503 = Math.max(0L, j);
                            this.f3495 = false;
                            this.f3472 = false;
                            if (m2816()) {
                                m2819();
                            }
                            m2831(j);
                            if (this.f3494) {
                                mo2828();
                            }
                        }
                        if (this.f3477 == null) {
                            ᵻᵪ.ᵱᵽʡᵚ(byteBuffer.order() == ByteOrder.LITTLE_ENDIAN);
                            if (byteBuffer.hasRemaining()) {
                                if (!C5540.m11162(this.f3502) && this.f3520 == 0) {
                                    int iM2799 = m2799(((C2558) this.f3502.f20918).f9895, byteBuffer);
                                    this.f3520 = iM2799;
                                }
                                if (this.f3489 == null) {
                                    long j5 = this.f3503;
                                    c5540 = this.f3502;
                                    if (C5540.m11162(c5540)) {
                                        j2 = -9223372036854775807L;
                                        j3 = 0;
                                        j4 = this.f3517;
                                    } else {
                                        j2 = -9223372036854775807L;
                                        j3 = 0;
                                        j4 = this.f3511 / ((long) this.f3502.f20919);
                                    }
                                    long jM3230 = AbstractC0956.m3230(j4 - this.f3519.f18916, ((C5286) c5540.f20917).f19966) + j5;
                                    if (!this.f3495 && Math.abs(jM3230 - j) > 200000) {
                                        interfaceC3982 = this.f3488;
                                        if (interfaceC3982 != null) {
                                            StringBuilder sbM8220 = AbstractC3653.m8220(jM3230, "Unexpected audio track timestamp discontinuity: expected ", ", got ");
                                            sbM8220.append(j);
                                            interfaceC3982.m8741(new AudioSink$UnexpectedDiscontinuityException(sbM8220.toString()));
                                        }
                                        this.f3495 = true;
                                    }
                                    if (this.f3495) {
                                        if (m2837()) {
                                            long j6 = j - jM3230;
                                            this.f3503 += j6;
                                            this.f3495 = false;
                                            m2831(j);
                                            InterfaceC3982 interfaceC39822 = this.f3488;
                                            if (interfaceC39822 != null && j6 != j3) {
                                                interfaceC39822.m8744();
                                            }
                                        }
                                    }
                                    if (C5540.m11162(this.f3502)) {
                                        this.f3517 = (((long) this.f3520) * ((long) i)) + this.f3517;
                                    } else {
                                        this.f3511 += (long) byteBuffer.remaining();
                                    }
                                    this.f3477 = byteBuffer;
                                    this.f3475 = i;
                                } else if (m2837()) {
                                    m2831(j);
                                    this.f3489 = null;
                                    long j52 = this.f3503;
                                    c5540 = this.f3502;
                                    if (C5540.m11162(c5540)) {
                                    }
                                    long jM32302 = AbstractC0956.m3230(j4 - this.f3519.f18916, ((C5286) c5540.f20917).f19966) + j52;
                                    if (!this.f3495) {
                                        interfaceC3982 = this.f3488;
                                        if (interfaceC3982 != null) {
                                        }
                                        this.f3495 = true;
                                    }
                                    if (this.f3495) {
                                    }
                                    if (C5540.m11162(this.f3502)) {
                                    }
                                    this.f3477 = byteBuffer;
                                    this.f3475 = i;
                                }
                            }
                            return true;
                        }
                        j2 = -9223372036854775807L;
                        j3 = 0;
                        m2810(j);
                        if (!this.f3477.hasRemaining()) {
                            this.f3477 = null;
                            this.f3475 = 0;
                            return true;
                        }
                        C4000 c4000 = this.f3491;
                        C1371 c1371 = c4000.f15329;
                        long jM8776 = c4000.m8776();
                        if (c1371.f5669 != j2 && jM8776 > j3) {
                            c1371.f5662.getClass();
                            if (SystemClock.elapsedRealtime() - c1371.f5669 >= 200) {
                                ˋˀᵧ.ʿٴˇ("Resetting stalled audio output");
                                flush();
                                return true;
                            }
                        }
                    }
                } catch (AudioSink$InitializationException e) {
                    if (e.f616) {
                        throw e;
                    }
                    c5021.m10358(e);
                    return false;
                }
            }
        } else if (m2837()) {
            if (this.f3491 != null) {
                C2558 c2558 = (C2558) this.f3502.f20918;
                m2817((C5286) this.f3509.f20920);
                if (((C2558) this.f3509.f20918).equals(c2558)) {
                    this.f3502 = this.f3509;
                    this.f3509 = null;
                    C4000 c40002 = this.f3491;
                    if (c40002 != null && c40002.m8777() && ((C2558) this.f3502.f20918).f9897) {
                        this.f3491.m8778();
                        C4000 c40003 = this.f3491;
                        C5286 c5286 = (C5286) this.f3502.f20917;
                        c40003.m8781(c5286.f19961, c5286.f19971);
                        this.f3497 = true;
                    }
                } else {
                    m2801();
                    if (!mo2838()) {
                        flush();
                    }
                }
                m2831(j);
                zM2802 = m2802();
                C5021 c50212 = this.f3518;
                if (zM2802) {
                }
            }
        }
        return false;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m2831(long j) {
        C4688 c4688;
        boolean zM2816 = m2816();
        boolean z = false;
        ᵯᵨᵲ r2 = this.f3470;
        if (zM2816) {
            c4688 = C4688.f17810;
        } else {
            if (this.f3474 || !C5540.m11162(this.f3502)) {
                c4688 = C4688.f17810;
            } else {
                int i = ((C5286) this.f3502.f20917).f19962;
                c4688 = this.f3496;
                C2810 c2810 = (C2810) r2.ᵨᵼⁱ;
                float f = c4688.f17813;
                c2810.getClass();
                ᵻᵪ.ᵱᵽʡᵚ(f > 0.0f);
                if (c2810.f10798 != f) {
                    c2810.f10798 = f;
                    c2810.f10807 = true;
                }
                float f2 = c4688.f17811;
                ᵻᵪ.ᵱᵽʡᵚ(f2 > 0.0f);
                if (c2810.f10806 != f2) {
                    c2810.f10806 = f2;
                    c2810.f10807 = true;
                }
            }
            this.f3496 = c4688;
        }
        C4688 c46882 = c4688;
        if (!this.f3474 && C5540.m11162(this.f3502)) {
            int i2 = ((C5286) this.f3502.f20917).f19962;
            z = this.f3508;
            ((C1330) r2.ᵔᵖᵹᵫ).f5539 = z;
        }
        this.f3508 = z;
        this.f3486.add(new C5543(c46882, Math.max(0L, j), AbstractC0956.m3230(m2823(), ((C2558) this.f3502.f20918).f9890)));
        C1316 c1316 = (C1316) this.f3502.f20921;
        this.f3512 = c1316;
        c1316.m3837();
        InterfaceC3982 interfaceC3982 = this.f3488;
        if (interfaceC3982 != null) {
            interfaceC3982.m8742(this.f3508);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x003e  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x0173  */
    /* JADX WARN: Removed duplicated region for block: B:83:0x0221  */
    /* JADX WARN: Removed duplicated region for block: B:94:0x0235 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:96:0x0061 A[SYNTHETIC] */
    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m2832(ByteBuffer byteBuffer) {
        ByteBuffer byteBufferOrder;
        int i;
        byte b;
        int i2;
        int i3;
        ᵻᵪ.ˌᴵ(this.f3487 == null);
        if (byteBuffer.hasRemaining()) {
            if (C5540.m11162(this.f3502)) {
                int iM3218 = (int) AbstractC0956.m3218(AbstractC0956.m3214(20L), ((C2558) this.f3502.f20918).f9890, 1000000L, RoundingMode.UP);
                long jM2823 = m2823();
                long j = iM3218;
                if (jM2823 < j) {
                    C5540 c5540 = this.f3502;
                    int i4 = ((C2558) c5540.f20918).f9895;
                    int i5 = c5540.f20916;
                    int i6 = (int) jM2823;
                    byteBufferOrder = ByteBuffer.allocateDirect(byteBuffer.remaining()).order(ByteOrder.nativeOrder());
                    int iPosition = byteBuffer.position();
                    while (byteBuffer.hasRemaining() && i6 < iM3218) {
                        if (i4 != 2) {
                            if (i4 == 3) {
                                i3 = (byteBuffer.get() & 255) << 24;
                            } else if (i4 == 4) {
                                float fM3270 = AbstractC0956.m3270(byteBuffer.getFloat(), -1.0f, 1.0f);
                                i3 = (int) (fM3270 < 0.0f ? (-fM3270) * (-2.1474836E9f) : fM3270 * 2.1474836E9f);
                            } else if (i4 == 21) {
                                i = ((byteBuffer.get() & 255) << 8) | ((byteBuffer.get() & 255) << 16);
                                b = byteBuffer.get();
                            } else if (i4 != 22) {
                                if (i4 == 268435456) {
                                    i = (byteBuffer.get() & 255) << 24;
                                    i2 = (byteBuffer.get() & 255) << 16;
                                } else if (i4 == 1342177280) {
                                    i = ((byteBuffer.get() & 255) << 24) | ((byteBuffer.get() & 255) << 16);
                                    i2 = (byteBuffer.get() & 255) << 8;
                                } else if (i4 == 1610612736) {
                                    i = ((byteBuffer.get() & 255) << 24) | ((byteBuffer.get() & 255) << 16) | ((byteBuffer.get() & 255) << 8);
                                    i2 = byteBuffer.get() & 255;
                                } else if (i4 != 1879048192) {
                                    ᵷᵝˎ.ᵱʡˏ();
                                    return;
                                } else {
                                    double dMax = Math.max(-1.0d, Math.min(byteBuffer.getDouble(), 1.0d));
                                    i3 = (int) (dMax < 0.0d ? (-dMax) * (-2.147483648E9d) : dMax * 2.147483647E9d);
                                }
                                i3 = i | i2;
                            } else {
                                i = (byteBuffer.get() & 255) | ((byteBuffer.get() & 255) << 8) | ((byteBuffer.get() & 255) << 16);
                                b = byteBuffer.get();
                            }
                            int i7 = (int) ((((long) i3) * ((long) i6)) / j);
                            if (i4 != 2) {
                                byteBufferOrder.put((byte) (i7 >> 16));
                                byteBufferOrder.put((byte) (i7 >> 24));
                            } else if (i4 == 3) {
                                byteBufferOrder.put((byte) (i7 >> 24));
                            } else if (i4 != 4) {
                                if (i4 == 21) {
                                    byteBufferOrder.put((byte) (i7 >> 8));
                                    byteBufferOrder.put((byte) (i7 >> 16));
                                    byteBufferOrder.put((byte) (i7 >> 24));
                                } else if (i4 == 22) {
                                    byteBufferOrder.put((byte) i7);
                                    byteBufferOrder.put((byte) (i7 >> 8));
                                    byteBufferOrder.put((byte) (i7 >> 16));
                                    byteBufferOrder.put((byte) (i7 >> 24));
                                } else if (i4 == 268435456) {
                                    byteBufferOrder.put((byte) (i7 >> 24));
                                    byteBufferOrder.put((byte) (i7 >> 16));
                                } else if (i4 == 1342177280) {
                                    byteBufferOrder.put((byte) (i7 >> 24));
                                    byteBufferOrder.put((byte) (i7 >> 16));
                                    byteBufferOrder.put((byte) (i7 >> 8));
                                } else if (i4 == 1610612736) {
                                    byteBufferOrder.put((byte) (i7 >> 24));
                                    byteBufferOrder.put((byte) (i7 >> 16));
                                    byteBufferOrder.put((byte) (i7 >> 8));
                                    byteBufferOrder.put((byte) i7);
                                } else if (i4 != 1879048192) {
                                    ᵷᵝˎ.ᵱʡˏ();
                                    return;
                                } else if (i7 < 0) {
                                    byteBufferOrder.putDouble((-i7) / (-2.147483648E9d));
                                } else {
                                    byteBufferOrder.putDouble(((double) i7) / 2.147483647E9d);
                                }
                            } else if (i7 < 0) {
                                byteBufferOrder.putFloat((-i7) / (-2.1474836E9f));
                            } else {
                                byteBufferOrder.putFloat(i7 / 2.1474836E9f);
                            }
                            if (byteBuffer.position() != iPosition + i5) {
                                i6++;
                                iPosition = byteBuffer.position();
                            }
                        } else {
                            i = (byteBuffer.get() & 255) << 16;
                            b = byteBuffer.get();
                        }
                        i2 = (b & 255) << 24;
                        i3 = i | i2;
                        int i72 = (int) ((((long) i3) * ((long) i6)) / j);
                        if (i4 != 2) {
                        }
                        if (byteBuffer.position() != iPosition + i5) {
                        }
                    }
                    byteBufferOrder.put(byteBuffer);
                    byteBufferOrder.flip();
                }
            } else {
                byteBufferOrder = byteBuffer;
            }
            this.f3487 = byteBufferOrder;
        }
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final C4688 mo2833() {
        return this.f3496;
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public final void mo2834(boolean z) {
        this.f3508 = z;
        C5543 c5543 = new C5543(m2816() ? C4688.f17810 : this.f3496, -9223372036854775807L, -9223372036854775807L);
        if (m2802()) {
            this.f3489 = c5543;
        } else {
            this.f3499 = c5543;
        }
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public final void mo2835(int i) {
        if (this.f3506) {
            if (this.f3479 != i) {
                return;
            } else {
                this.f3506 = false;
            }
        }
        if (this.f3479 != i) {
            this.f3479 = i;
            this.f3471 = i != 0;
            m2807();
        }
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final boolean mo2836(C5286 c5286) {
        return mo2811(c5286) != 0;
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x0043 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0044 A[RETURN] */
    /* JADX INFO: renamed from: ᵸˆˁ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean m2837() throws AudioSink$WriteException {
        ByteBuffer byteBuffer;
        if (!this.f3512.m3838()) {
            m2813(Long.MIN_VALUE);
            return this.f3487 == null;
        }
        C1316 c1316 = this.f3512;
        if (c1316.m3838() && !c1316.f5485) {
            c1316.f5485 = true;
            ((InterfaceC2497) c1316.f5482.get(0)).mo4909();
        }
        m2810(Long.MIN_VALUE);
        if (!this.f3512.m3835() || ((byteBuffer = this.f3487) != null && byteBuffer.hasRemaining())) {
        }
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public final boolean mo2838() {
        if (!m2802()) {
            return false;
        }
        if (Build.VERSION.SDK_INT >= 29 && this.f3491.m8777() && this.f3515) {
            return false;
        }
        long jM2823 = m2823();
        long jM8779 = this.f3491.m8779();
        C4000 c4000 = this.f3491;
        c4000.getClass();
        return jM2823 > AbstractC0956.m3218(jM8779, (long) c4000.f15324.getSampleRate(), 1000000L, RoundingMode.UP);
    }

    @Override // defpackage.InterfaceC2890
    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final void mo2839(C4688 c4688) {
        if (m2816()) {
            this.f3496 = c4688;
            m2819();
            return;
        }
        C4688 c46882 = new C4688(AbstractC0956.m3270(c4688.f17813, 0.1f, 8.0f), AbstractC0956.m3270(c4688.f17811, 0.1f, 8.0f));
        this.f3496 = c46882;
        C5543 c5543 = new C5543(c46882, -9223372036854775807L, -9223372036854775807L);
        if (m2802()) {
            this.f3489 = c5543;
        } else {
            this.f3499 = c5543;
        }
    }
}
