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.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$WriteException;
import j$.util.Objects;
import java.math.RoundingMode;
import java.nio.ByteBuffer;
import java.util.ArrayDeque;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/* renamed from: ˁʾʕᵚ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C0646 implements InterfaceC3867 {

    /* renamed from: ˊʾˊ, reason: contains not printable characters */
    public static final AtomicInteger f3172 = new AtomicInteger();

    /* renamed from: ˀˁᵨ, reason: contains not printable characters */
    public Handler f3173;

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public long f3174;

    /* renamed from: ˀᵗᵩ, reason: contains not printable characters */
    public int f3175;

    /* renamed from: ˁˑᵰ, reason: contains not printable characters */
    public ByteBuffer f3176;

    /* renamed from: ˆᵼᵷˊ, reason: contains not printable characters */
    public boolean f3177;

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final C2928 f3178;

    /* renamed from: ˊʽˎ, reason: contains not printable characters */
    public long f3179;

    /* renamed from: ˊᵸˊ, reason: contains not printable characters */
    public boolean f3180;

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public C4805 f3181;

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final C1271 f3182;

    /* renamed from: ˌᵪ, reason: contains not printable characters */
    public AudioDeviceInfo f3183;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final C4471 f3184;

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public boolean f3185;

    /* renamed from: ˎᵬˀ, reason: contains not printable characters */
    public boolean f3186;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final C0496 f3187;

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

    /* renamed from: ˑᵝﹳᵜ, reason: contains not printable characters */
    public boolean f3189;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public int f3190;

    /* renamed from: ˑᵱ, reason: contains not printable characters */
    public C1028 f3191;

    /* renamed from: ᐧﾞ, reason: contains not printable characters */
    public ByteBuffer f3192;

    /* renamed from: ᵙᵢᵨᵳ, reason: contains not printable characters */
    public boolean f3193;

    /* renamed from: ᵛˈᵤ, reason: contains not printable characters */
    public C0298 f3194;

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final int f3195;

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public C0455 f3196;

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public C4633 f3197;

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public long f3198;

    /* renamed from: ᵡᵘˎʽ, reason: contains not printable characters */
    public boolean f3199;

    /* renamed from: ᵡᵶᵡ, reason: contains not printable characters */
    public boolean f3200;

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public long f3201;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public C5472 f3202;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public long f3203;

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

    /* renamed from: ᵧـˌᵎ, reason: contains not printable characters */
    public long f3205;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public C5472 f3206;

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public C2361 f3207;

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public InterfaceC5159 f3208;

    /* renamed from: ᵫᵮʾ, reason: contains not printable characters */
    public long f3209;

    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    public boolean f3210;

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public C1545 f3211;

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public C4805 f3212;

    /* renamed from: ᵳᵹᵺˋ, reason: contains not printable characters */
    public int f3213;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final ʽᵡ f3214;

    /* renamed from: ᵶʔᵢˊ, reason: contains not printable characters */
    public int f3215;

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public C5551 f3216;

    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public InterfaceC3601 f3217;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final C1271 f3218;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final ArrayDeque f3219;

    /* renamed from: ᵺʙ, reason: contains not printable characters */
    public float f3220;

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

    /* renamed from: ᵽʛ, reason: contains not printable characters */
    public long f3222;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public boolean f3223;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public C0068 f3224;

    /* renamed from: ﾞⁱ, reason: contains not printable characters */
    public boolean f3225;

    public C0646(ˉʿᵧʽ r9) {
        int deviceId;
        Context context = (Context) r9.ᵴᵳ;
        this.f3204 = context == null ? null : context.getApplicationContext();
        this.f3191 = C1028.f4492;
        this.f3214 = (ʽᵡ) r9.ᵻᵢﹳᵰ;
        this.f3195 = 0;
        this.f3217 = (C2171) r9.ˏˋٴ;
        C4938 c4938 = new C4938();
        this.f3188 = c4938;
        C3180 c3180 = new C3180();
        c3180.f12055 = AbstractC3558.f13330;
        this.f3221 = c3180;
        this.f3178 = new C2928();
        this.f3187 = new C0496();
        this.f3184 = AbstractC2692.m6698(c3180, c4938);
        this.f3220 = 1.0f;
        this.f3175 = 0;
        this.f3194 = new C0298();
        C0068 c0068 = C0068.f1304;
        this.f3202 = new C5472(c0068, 0L, 0L);
        this.f3224 = c0068;
        this.f3223 = false;
        this.f3219 = new ArrayDeque();
        this.f3218 = new C1271();
        this.f3182 = new C1271();
        int i = -1;
        if (Build.VERSION.SDK_INT >= 34 && context != null && (deviceId = context.getDeviceId()) != 0 && deviceId != -1) {
            i = deviceId;
        }
        this.f3213 = i;
    }

    /* JADX WARN: Removed duplicated region for block: B:48:0x00c0  */
    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static int m2540(int r10, java.nio.ByteBuffer r11) {
        /*
            Method dump skipped, instructions count: 546
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C0646.m2540(int, java.nio.ByteBuffer):int");
    }

    @Override // defpackage.InterfaceC3867
    public final void flush() throws IllegalStateException {
        C1561 c1561;
        if (m2553()) {
            this.f3203 = 0L;
            this.f3201 = 0L;
            this.f3174 = 0L;
            this.f3198 = 0L;
            int i = 0;
            this.f3186 = false;
            this.f3190 = 0;
            this.f3202 = new C5472(this.f3224, 0L, 0L);
            this.f3205 = 0L;
            this.f3206 = null;
            this.f3219.clear();
            this.f3192 = null;
            this.f3215 = 0;
            this.f3176 = null;
            this.f3193 = false;
            this.f3225 = false;
            this.f3199 = false;
            this.f3221.f12056 = 0L;
            C4633 c4633 = (C4633) this.f3181.f17834;
            this.f3197 = c4633;
            c4633.m9819();
            this.f3216 = null;
            C4805 c4805 = this.f3212;
            if (c4805 != null) {
                this.f3181 = c4805;
                this.f3212 = null;
            }
            f3172.incrementAndGet();
            C2361 c2361 = this.f3207;
            if (c2361.f9262.f5966.getPlayState() == 3) {
                c2361.f9267.pause();
            }
            int i2 = Build.VERSION.SDK_INT;
            if (i2 >= 29 && c2361.m6127()) {
                C0470 c0470 = c2361.f9264;
                c0470.getClass();
                C0470.m2065(c0470);
            }
            if (i2 >= 24 && (c1561 = c2361.f9258) != null) {
                C1561.m4533(c1561);
                c2361.f9258 = null;
            }
            AudioTrack audioTrack = c2361.f9267;
            C5128 c5128 = c2361.f9272;
            Handler handlerM8130 = AbstractC3558.m8130(null);
            synchronized (C2361.f9257) {
                try {
                    if (C2361.f9255 == null) {
                        C2361.f9255 = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryC4715());
                    }
                    C2361.f9256++;
                    C2361.f9255.schedule(new RunnableC2331(audioTrack, handlerM8130, c5128, i), 20L, TimeUnit.MILLISECONDS);
                } catch (Throwable th) {
                    throw th;
                }
            }
            this.f3207 = null;
        }
        C1271 c1271 = this.f3182;
        c1271.f5283 = null;
        c1271.f5284 = -9223372036854775807L;
        c1271.f5285 = -9223372036854775807L;
        C1271 c12712 = this.f3218;
        c12712.f5283 = null;
        c12712.f5284 = -9223372036854775807L;
        c12712.f5285 = -9223372036854775807L;
        this.f3209 = 0L;
        this.f3222 = 0L;
        Handler handler = this.f3173;
        if (handler != null) {
            handler.removeCallbacksAndMessages(null);
        }
    }

    @Override // defpackage.InterfaceC3867
    public final void reset() throws IllegalStateException {
        flush();
        C4421 c4421M6704 = this.f3184.listIterator(0);
        while (c4421M6704.hasNext()) {
            ((InterfaceC0240) c4421M6704.next()).reset();
        }
        this.f3178.reset();
        this.f3187.reset();
        C4633 c4633 = this.f3197;
        if (c4633 != null) {
            AbstractC2692 abstractC2692 = c4633.f17162;
            for (int i = 0; i < abstractC2692.size(); i++) {
                InterfaceC0240 interfaceC0240 = (InterfaceC0240) abstractC2692.get(i);
                interfaceC0240.mo1538(C3046.f11698);
                interfaceC0240.reset();
            }
            c4633.f17163.clear();
            c4633.f17161 = new ByteBuffer[0];
            C2263 c2263 = C2263.f8838;
            c4633.f17164 = false;
        }
        this.f3189 = false;
    }

    @Override // defpackage.InterfaceC3867
    public final void setPreferredDevice(AudioDeviceInfo audioDeviceInfo) {
        this.f3183 = audioDeviceInfo;
        C2361 c2361 = this.f3207;
        if (c2361 != null) {
            c2361.f9267.setPreferredDevice(audioDeviceInfo);
        }
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public final void mo2541(C1875 c1875) {
        ((C2171) this.f3217).f8565 = c1875;
    }

    /* renamed from: ˁˑᵰ, reason: contains not printable characters */
    public final void m2542(long j) throws AudioSink$WriteException {
        ByteBuffer byteBuffer;
        m2558(j);
        if (this.f3176 != null) {
            return;
        }
        if (!this.f3197.m9821()) {
            ByteBuffer byteBuffer2 = this.f3192;
            if (byteBuffer2 != null) {
                m2559(byteBuffer2);
                m2558(j);
                return;
            }
            return;
        }
        while (!this.f3197.m9818()) {
            do {
                C4633 c4633 = this.f3197;
                if (c4633.m9821()) {
                    ByteBuffer byteBuffer3 = c4633.f17161[c4633.m9820()];
                    if (byteBuffer3.hasRemaining()) {
                        byteBuffer = byteBuffer3;
                    } else {
                        c4633.m9817(InterfaceC0240.f1780);
                        byteBuffer = c4633.f17161[c4633.m9820()];
                    }
                } else {
                    byteBuffer = InterfaceC0240.f1780;
                }
                if (byteBuffer.hasRemaining()) {
                    m2559(byteBuffer);
                    m2558(j);
                } else {
                    ByteBuffer byteBuffer4 = this.f3192;
                    if (byteBuffer4 == null || !byteBuffer4.hasRemaining()) {
                        return;
                    }
                    C4633 c46332 = this.f3197;
                    ByteBuffer byteBuffer5 = this.f3192;
                    if (c46332.m9821() && !c46332.f17164) {
                        c46332.m9817(byteBuffer5);
                    }
                }
            } while (this.f3176 == null);
            return;
        }
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void mo2543() throws IllegalStateException {
        this.f3189 = false;
        if (m2553()) {
            C2361 c2361 = this.f3207;
            C1481 c1481 = c2361.f9262;
            c1481.f5964 = 0L;
            c1481.f5957 = 0;
            c1481.f5950 = 0;
            c1481.f5944 = 0L;
            c1481.f5967 = -9223372036854775807L;
            c1481.f5954 = -9223372036854775807L;
            if (c1481.f5948 == -9223372036854775807L) {
                c1481.f5965.m8491(0);
            }
            c1481.f5953 = c1481.m4398();
            if (!c2361.f9274 || c2361.m6127()) {
                c2361.f9267.pause();
            }
        }
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public final void mo2544() throws IllegalStateException {
        if (this.f3200) {
            this.f3200 = false;
            m2580();
        }
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final long mo2545() {
        if (!m2553()) {
            return -9223372036854775807L;
        }
        if (C4805.m10119(this.f3181)) {
            return AbstractC3558.m8110(this.f3207.f9267.getBufferSizeInFrames(), ((C1091) this.f3181.f17833).f4698);
        }
        long bufferSizeInFrames = this.f3207.f9267.getBufferSizeInFrames();
        int i = ᵿᵧ.ˌʾˀ(((C1091) this.f3181.f17833).f4697);
        ᵛᵾˏ.ᵿʗᵝʽ(i != -2147483647);
        return AbstractC3558.m8115(bufferSizeInFrames, 1000000L, i, RoundingMode.DOWN);
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final C0068 mo2546() {
        return this.f3224;
    }

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public final C3151 m2547(C3446 c3446) {
        C3151 c3151 = new C3151(c3446);
        c3151.f11969 = this.f3191;
        c3151.f11971 = this.f3195 != 0;
        c3151.f11967 = this.f3183;
        c3151.f11964 = this.f3175;
        c3151.f11965 = this.f3200;
        c3151.f11970 = -1;
        c3151.f11966 = this.f3213;
        return new C3151(c3151);
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void mo2548(C0068 c0068) {
        if (m2550()) {
            this.f3224 = c0068;
            m2554();
            return;
        }
        C0068 c00682 = new C0068(AbstractC3558.m8127(c0068.f1306, 0.1f, 8.0f), AbstractC3558.m8127(c0068.f1307, 0.1f, 8.0f));
        this.f3224 = c00682;
        C5472 c5472 = new C5472(c00682, -9223372036854775807L, -9223372036854775807L);
        if (m2553()) {
            this.f3206 = c5472;
        } else {
            this.f3202 = c5472;
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final C2361 m2549(C1091 c1091) throws AudioSink$InitializationException {
        try {
            return ((C2171) this.f3217).m5805(c1091);
        } catch (AudioOutputProvider$InitializationException e) {
            AudioSink$InitializationException audioSink$InitializationException = new AudioSink$InitializationException(c1091.f4698, c1091.f4695, c1091.f4697, c1091.f4694, (C3446) this.f3181.f17835, c1091.f4692, e);
            InterfaceC5159 interfaceC5159 = this.f3208;
            if (interfaceC5159 == null) {
                throw audioSink$InitializationException;
            }
            interfaceC5159.m10645(audioSink$InitializationException);
            throw audioSink$InitializationException;
        }
    }

    /* renamed from: ˑᵝﹳᵜ, reason: contains not printable characters */
    public final boolean m2550() {
        C4805 c4805 = this.f3181;
        return c4805 != null && ((C1091) c4805.f17833).f4699;
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x0043 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0044 A[RETURN] */
    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean m2551() throws androidx.media3.exoplayer.audio.AudioSink$WriteException {
        /*
            r6 = this;
            ᵴˆˊː r0 = r6.f3197
            boolean r0 = r0.m9821()
            r1 = -9223372036854775808
            r3 = 0
            r4 = 1
            if (r0 != 0) goto L14
            r6.m2558(r1)
            java.nio.ByteBuffer r6 = r6.f3176
            if (r6 != 0) goto L44
            goto L43
        L14:
            ᵴˆˊː r0 = r6.f3197
            boolean r5 = r0.m9821()
            if (r5 == 0) goto L2e
            boolean r5 = r0.f17164
            if (r5 == 0) goto L21
            goto L2e
        L21:
            r0.f17164 = r4
            java.util.ArrayList r0 = r0.f17163
            java.lang.Object r0 = r0.get(r3)
            ʾˈʡ r0 = (defpackage.InterfaceC0240) r0
            r0.mo1544()
        L2e:
            r6.m2542(r1)
            ᵴˆˊː r0 = r6.f3197
            boolean r0 = r0.m9818()
            if (r0 == 0) goto L44
            java.nio.ByteBuffer r6 = r6.f3176
            if (r6 == 0) goto L43
            boolean r6 = r6.hasRemaining()
            if (r6 != 0) goto L44
        L43:
            return r4
        L44:
            return r3
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C0646.m2551():boolean");
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ˑᵱ, reason: contains not printable characters */
    public final void mo2552(float f) {
        if (this.f3220 != f) {
            this.f3220 = f;
            if (m2553()) {
                C2361 c2361 = this.f3207;
                c2361.f9267.setVolume(this.f3220);
            }
        }
    }

    /* renamed from: ᐧﾞ, reason: contains not printable characters */
    public final boolean m2553() {
        return this.f3207 != null;
    }

    /* renamed from: ᵙᵢᵨᵳ, reason: contains not printable characters */
    public final void m2554() {
        if (m2553()) {
            C2361 c2361 = this.f3207;
            C0068 c0068 = this.f3224;
            AudioTrack audioTrack = c2361.f9267;
            try {
                audioTrack.setPlaybackParams(new PlaybackParams().allowDefaults().setSpeed(AbstractC3558.m8127(c0068.f1306, 0.1f, c2361.f9263)).setPitch(AbstractC3558.m8127(c0068.f1307, 0.1f, 8.0f)).setAudioFallbackMode(2));
            } catch (IllegalArgumentException e) {
                ᵳʿˉ.ˁˑᵰ("Failed to set playback params", e);
            }
            C1481 c1481 = c2361.f9262;
            c1481.f5949 = audioTrack.getPlaybackParams().getSpeed();
            c1481.f5965.m8491(0);
            c1481.f5964 = 0L;
            c1481.f5957 = 0;
            c1481.f5950 = 0;
            c1481.f5944 = 0L;
            c1481.f5967 = -9223372036854775807L;
            c1481.f5954 = -9223372036854775807L;
            PlaybackParams playbackParams = this.f3207.f9267.getPlaybackParams();
            this.f3224 = new C0068(playbackParams.getSpeed(), playbackParams.getPitch());
        }
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final boolean mo2555() {
        if (!m2553()) {
            return false;
        }
        if (Build.VERSION.SDK_INT >= 29 && this.f3207.m6127() && this.f3199) {
            return false;
        }
        long jM2564 = m2564();
        long jM6128 = this.f3207.m6128();
        C2361 c2361 = this.f3207;
        c2361.getClass();
        return jM2564 > AbstractC3558.m8115(jM6128, (long) c2361.f9267.getSampleRate(), 1000000L, RoundingMode.UP);
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public final void mo2556(InterfaceC5159 interfaceC5159) {
        this.f3208 = interfaceC5159;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v11, types: [java.lang.Object, ʿᵮʿ] */
    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public final void mo2557(C3446 c3446, int[] iArr) throws AudioProcessor$UnhandledAudioFormatException, AudioSink$ConfigurationException {
        C4633 c4633;
        C3446 c34462;
        int i;
        int iM8123;
        if (this.f3196 == null && this.f3204 != null) {
            ?? r0 = new Object() { // from class: ʿᵮʿ
            };
            this.f3196 = r0;
            C2171 c2171 = (C2171) this.f3217;
            c2171.m5807();
            if (c2171.f8566 == null) {
                c2171.f8566 = new C5128(Thread.currentThread());
            }
            c2171.f8566.m10592(r0);
        }
        String str = c3446.f12929;
        int i2 = c3446.f12923;
        int i3 = c3446.f12912;
        if ("audio/raw".equals(str)) {
            ᵛᵾˏ.ᵯٴᵦ(AbstractC3558.m8107(i3));
            int iM81232 = AbstractC3558.m8123(i3) * i2;
            C4704 c4704 = new C4704(4);
            c4704.m3198(this.f3184);
            c4704.m3197(this.f3178);
            c4704.m9893((InterfaceC0240[]) this.f3214.ᵢˇᵭ);
            c4633 = new C4633(c4704.m9892());
            if (c4633.equals(this.f3197)) {
                c4633 = this.f3197;
            }
            int i4 = c3446.f12931;
            int i5 = c3446.f12900;
            C3180 c3180 = this.f3221;
            c3180.f12053 = i4;
            c3180.f12057 = i5;
            this.f3188.f18345 = iArr;
            C2263 c2263 = new C2263(c3446.f12936, i2, i3);
            try {
                AbstractC2692 abstractC2692 = c4633.f17162;
                if (c2263.equals(C2263.f8838)) {
                    throw new AudioProcessor$UnhandledAudioFormatException(c2263);
                }
                for (int i6 = 0; i6 < abstractC2692.size(); i6++) {
                    InterfaceC0240 interfaceC0240 = (InterfaceC0240) abstractC2692.get(i6);
                    C2263 c2263Mo1539 = interfaceC0240.mo1539(c2263);
                    if (interfaceC0240.mo1541()) {
                        ᵛᵾˏ.ᵿʗᵝʽ(!c2263Mo1539.equals(C2263.f8838));
                        c2263 = c2263Mo1539;
                    }
                }
                int i7 = c2263.f8841;
                int i8 = c2263.f8839;
                C2153 c2153M7829 = c3446.m7829();
                c2153M7829.f8526 = i8;
                c2153M7829.f8513 = c2263.f8840;
                c2153M7829.f8517 = i7;
                c34462 = new C3446(c2153M7829);
                i = iM81232;
                iM8123 = AbstractC3558.m8123(i8) * i7;
            } catch (AudioProcessor$UnhandledAudioFormatException e) {
                throw new AudioSink$ConfigurationException(e, c3446);
            }
        } else {
            c4633 = new C4633(C4471.f16684);
            c34462 = c3446;
            i = -1;
            iM8123 = -1;
        }
        C4633 c46332 = c4633;
        C3151 c3151M2547 = m2547(c34462);
        C3446 c34463 = c3151M2547.f11968;
        try {
            C1091 c1091M5806 = ((C2171) this.f3217).m5806(c3151M2547);
            boolean z = c1091M5806.f4692;
            if (c1091M5806.f4697 == 0) {
                throw new AudioSink$ConfigurationException(AbstractC4486.m9559("Invalid output encoding (isOffload=", ")", z), c34463);
            }
            if (c1091M5806.f4695 == 0) {
                throw new AudioSink$ConfigurationException(AbstractC4486.m9559("Invalid output channel config (isOffload=", ")", z), c34463);
            }
            C4805 c4805 = new C4805(c3446, c34462, i, iM8123, c1091M5806, c46332);
            if (m2553()) {
                this.f3212 = c4805;
            } else {
                this.f3181 = c4805;
            }
        } catch (AudioOutputProvider$ConfigurationException e2) {
            throw new AudioSink$ConfigurationException(e2, c3446);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:51:0x00c4  */
    /* renamed from: ᵡˎ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void m2558(long r10) throws androidx.media3.exoplayer.audio.AudioSink$WriteException {
        /*
            Method dump skipped, instructions count: 224
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C0646.m2558(long):void");
    }

    /* 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] */
    /* renamed from: ᵡᵘˎʽ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void m2559(java.nio.ByteBuffer r23) {
        /*
            Method dump skipped, instructions count: 584
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C0646.m2559(java.nio.ByteBuffer):void");
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public final void mo2560(boolean z) {
        this.f3223 = z;
        C5472 c5472 = new C5472(m2550() ? C0068.f1304 : this.f3224, -9223372036854775807L, -9223372036854775807L);
        if (m2553()) {
            this.f3206 = c5472;
        } else {
            this.f3202 = c5472;
        }
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final void mo2561() throws IllegalStateException {
        ᵛᵾˏ.ᵿʗᵝʽ(this.f3180);
        if (this.f3200) {
            return;
        }
        this.f3200 = true;
        m2580();
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final void mo2562() throws IllegalStateException {
        this.f3189 = true;
        if (m2553()) {
            C2361 c2361 = this.f3207;
            C1481 c1481 = c2361.f9262;
            if (c1481.f5948 != -9223372036854775807L) {
                c1481.f5961.getClass();
                c1481.f5948 = AbstractC3558.m8133(SystemClock.elapsedRealtime());
            }
            c1481.f5962 = AbstractC3558.m8110(c1481.m4398(), c1481.f5942);
            c1481.f5965.m8491(0);
            if (!c2361.f9274 || c2361.m6127()) {
                c2361.f9267.play();
            }
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m2563(long j) {
        C0068 c0068;
        boolean zM2550 = m2550();
        boolean z = false;
        ʽᵡ r2 = this.f3214;
        if (zM2550) {
            c0068 = C0068.f1304;
        } else {
            if (this.f3200 || !C4805.m10119(this.f3181)) {
                c0068 = C0068.f1304;
            } else {
                int i = ((C3446) this.f3181.f17835).f12912;
                c0068 = this.f3224;
                C4131 c4131 = (C4131) r2.ᵾᵬ;
                float f = c0068.f1306;
                c4131.getClass();
                ᵛᵾˏ.ᵯٴᵦ(f > 0.0f);
                if (c4131.f15435 != f) {
                    c4131.f15435 = f;
                    c4131.f15436 = true;
                }
                float f2 = c0068.f1307;
                ᵛᵾˏ.ᵯٴᵦ(f2 > 0.0f);
                if (c4131.f15444 != f2) {
                    c4131.f15444 = f2;
                    c4131.f15436 = true;
                }
            }
            this.f3224 = c0068;
        }
        C0068 c00682 = c0068;
        if (!this.f3200 && C4805.m10119(this.f3181)) {
            int i2 = ((C3446) this.f3181.f17835).f12912;
            z = this.f3223;
            ((C3016) r2.ᵿʗᵝʽ).f11621 = z;
        }
        this.f3223 = z;
        this.f3219.add(new C5472(c00682, Math.max(0L, j), AbstractC3558.m8110(m2564(), ((C1091) this.f3181.f17833).f4698)));
        C4633 c4633 = (C4633) this.f3181.f17834;
        this.f3197 = c4633;
        c4633.m9819();
        InterfaceC5159 interfaceC5159 = this.f3208;
        if (interfaceC5159 != null) {
            interfaceC5159.m10641(this.f3223);
        }
    }

    /* renamed from: ᵧـˌᵎ, reason: contains not printable characters */
    public final long m2564() {
        if (!C4805.m10119(this.f3181)) {
            return this.f3198;
        }
        long j = this.f3174;
        long j2 = this.f3181.f17837;
        return ((j + j2) - 1) / j2;
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final void mo2565(C1545 c1545) {
        this.f3211 = c1545;
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public final void mo2566() {
        this.f3185 = true;
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public final int mo2567(C3446 c3446) {
        boolean z;
        if (!AbstractC3558.m8107(c3446.f12912) || c3446.f12912 == 2) {
            z = false;
        } else {
            C2153 c2153M7829 = c3446.m7829();
            c2153M7829.f8526 = 2;
            c3446 = new C3446(c2153M7829);
            z = true;
        }
        InterfaceC3601 interfaceC3601 = this.f3217;
        C3151 c3151M2547 = m2547(c3446);
        C2171 c2171 = (C2171) interfaceC3601;
        c2171.m5804(c3151M2547);
        C3086 c3086 = c2171.f8567;
        C3446 c34462 = c3151M2547.f11968;
        C1028 c1028 = c3151M2547.f11969;
        C4222 c4222M7412 = c3086.m7412(c1028, c34462);
        C5249 c5249 = new C5249();
        c5249.f19652 = (!Objects.equals(c34462.f12929, "audio/raw") ? c2171.f8573.m7695(c1028, c34462) != null : c34462.f12912 == 2) ? 0 : 2;
        c5249.f19653 = c4222M7412.f15821;
        c5249.f19651 = c4222M7412.f15822;
        c5249.f19654 = c4222M7412.f15820;
        int i = c5249.m10900().f18183;
        if (i != 1) {
            if (i != 2) {
                return 0;
            }
            if (!z) {
                return 2;
            }
        }
        return 1;
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public final void mo2568(InterfaceC3601 interfaceC3601) throws IllegalStateException {
        C1434 c1434;
        if (interfaceC3601.equals(this.f3217)) {
            return;
        }
        C2171 c2171 = (C2171) this.f3217;
        C5128 c5128 = c2171.f8566;
        if (c5128 != null) {
            c5128.m10594();
        }
        C0744 c0744 = c2171.f8568;
        if (c0744 != null) {
            Context context = (Context) c0744.f3576;
            if (c0744.f3575) {
                c0744.f3574 = null;
                AbstractC4618.m9787(context).unregisterAudioDeviceCallback((C0350) c0744.f3570);
                if (Build.VERSION.SDK_INT >= 32 && (c1434 = (C1434) c0744.f3579) != null) {
                    c1434.m4335();
                    c0744.f3579 = null;
                }
                context.unregisterReceiver((C2481) c0744.f3572);
                C0303 c0303 = (C0303) c0744.f3571;
                if (c0303 != null) {
                    c0303.f1938.unregisterContentObserver(c0303);
                }
                c0744.f3575 = false;
            }
        }
        this.f3217 = interfaceC3601;
        C0455 c0455 = this.f3196;
        if (c0455 != null) {
            C2171 c21712 = (C2171) interfaceC3601;
            c21712.m5807();
            if (c21712.f8566 == null) {
                c21712.f8566 = new C5128(Thread.currentThread());
            }
            c21712.f8566.m10592(c0455);
        }
        m2580();
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public final long mo2569(boolean z) {
        ArrayDeque arrayDeque;
        long j;
        if (!m2553() || this.f3210) {
            return Long.MIN_VALUE;
        }
        long jMin = Math.min(this.f3207.m6128(), AbstractC3558.m8110(m2564(), ((C1091) this.f3181.f17833).f4698));
        while (true) {
            arrayDeque = this.f3219;
            if (arrayDeque.isEmpty() || jMin < ((C5472) arrayDeque.getFirst()).f20539) {
                break;
            }
            this.f3202 = (C5472) arrayDeque.remove();
        }
        C5472 c5472 = this.f3202;
        long jM8115 = jMin - c5472.f20539;
        long jM8122 = AbstractC3558.m8122(jM8115, c5472.f20540.f1306);
        boolean zIsEmpty = arrayDeque.isEmpty();
        ʽᵡ r2 = this.f3214;
        if (zIsEmpty) {
            C4131 c4131 = (C4131) r2.ᵾᵬ;
            if (c4131.mo1541()) {
                if (c4131.f15437 >= 1024) {
                    long j2 = c4131.f15438;
                    c4131.f15441.getClass();
                    long jMo5900 = j2 - (r7.f13908.mo5900() * (r7.f13915 * r7.f13914));
                    int i = c4131.f15443.f8840;
                    int i2 = c4131.f15433.f8840;
                    long j3 = c4131.f15437;
                    jM8115 = i == i2 ? AbstractC3558.m8115(jM8115, jMo5900, j3, RoundingMode.DOWN) : AbstractC3558.m8115(jM8115, jMo5900 * i, j3 * i2, RoundingMode.DOWN);
                } else {
                    jM8115 = (long) (c4131.f15435 * jM8115);
                }
            }
            C5472 c54722 = this.f3202;
            j = c54722.f20541 + jM8115;
            c54722.f20542 = jM8115 - jM8122;
        } else {
            C5472 c54723 = this.f3202;
            j = c54723.f20541 + jM8122 + c54723.f20542;
        }
        long j4 = ((C3016) r2.ᵿʗᵝʽ).f11616;
        long jM8110 = AbstractC3558.m8110(j4, ((C1091) this.f3181.f17833).f4698) + j;
        long j5 = this.f3209;
        if (j4 > j5) {
            long jM81102 = AbstractC3558.m8110(j4 - j5, ((C1091) this.f3181.f17833).f4698);
            this.f3209 = j4;
            this.f3222 += jM81102;
            if (this.f3173 == null) {
                this.f3173 = new Handler(Looper.myLooper());
            }
            this.f3173.removeCallbacksAndMessages(null);
            this.f3173.postDelayed(new RunnableC3566(13, this), 100L);
        }
        return jM8110;
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final boolean mo2570() {
        if (m2553()) {
            return this.f3225 && !mo2555();
        }
        return true;
    }

    /* renamed from: ᵶʔᵢˊ, reason: contains not printable characters */
    public final void m2571() throws IllegalStateException {
        if (this.f3193) {
            return;
        }
        this.f3193 = true;
        if (this.f3207.m6127()) {
            this.f3199 = false;
        }
        C2361 c2361 = this.f3207;
        if (c2361.f9274) {
            return;
        }
        c2361.f9274 = true;
        C1481 c1481 = c2361.f9262;
        long jM6129 = c2361.m6129();
        c1481.f5953 = c1481.m4398();
        c1481.f5961.getClass();
        c1481.f5948 = AbstractC3558.m8133(SystemClock.elapsedRealtime());
        c1481.f5968 = jM6129;
        c2361.f9267.stop();
        c2361.f9259 = 0;
    }

    /* 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.InterfaceC3867
    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean mo2572(int r21, long r22, java.nio.ByteBuffer r24) throws java.lang.IllegalStateException, androidx.media3.exoplayer.audio.AudioSink$WriteException, androidx.media3.exoplayer.audio.AudioSink$InitializationException {
        /*
            Method dump skipped, instructions count: 502
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C0646.mo2572(int, long, java.nio.ByteBuffer):boolean");
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public final void mo2573(C1028 c1028) throws IllegalStateException {
        if (this.f3191.equals(c1028)) {
            return;
        }
        this.f3191 = c1028;
        if (this.f3200) {
            return;
        }
        m2580();
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final void mo2574(int i) throws IllegalStateException {
        if (this.f3177) {
            if (this.f3175 != i) {
                return;
            } else {
                this.f3177 = false;
            }
        }
        if (this.f3175 != i) {
            this.f3175 = i;
            this.f3180 = i != 0;
            m2580();
        }
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final void mo2575() throws IllegalStateException {
        if (!this.f3225 && m2553() && m2551()) {
            m2571();
            this.f3225 = true;
        }
    }

    /* renamed from: ᵺʙ, reason: contains not printable characters */
    public final boolean m2576() throws AudioSink$InitializationException {
        C2361 c2361M2549;
        C1271 c1271 = this.f3218;
        if (((Exception) c1271.f5283) != null && (f3172.get() > 0 || SystemClock.elapsedRealtime() < c1271.f5285)) {
            return false;
        }
        try {
            c2361M2549 = m2549((C1091) this.f3181.f17833);
        } catch (AudioSink$InitializationException e) {
            int i = ((C1091) this.f3181.f17833).f4694;
            while (true) {
                C4805 c4805 = this.f3181;
                if (i <= 1000000) {
                    boolean z = ((C1091) c4805.f17833).f4692;
                    throw e;
                }
                int i2 = i / 2;
                int i3 = c4805.f17837;
                if (i3 == -1) {
                    i3 = 1;
                }
                int i4 = i2 % i3;
                int i5 = i4 != 0 ? (i3 - i4) + i2 : i2;
                C0559 c0559M3494 = ((C1091) c4805.f17833).m3494();
                c0559M3494.f2916 = i5;
                C1091 c1091 = new C1091(c0559M3494);
                try {
                    c2361M2549 = m2549(c1091);
                    C4805 c48052 = this.f3181;
                    this.f3181 = new C4805((C3446) c48052.f17835, (C3446) c48052.f17838, c48052.f17836, c48052.f17837, c1091, (C4633) c48052.f17834);
                    break;
                } catch (AudioSink$InitializationException e2) {
                    e.addSuppressed(e2);
                    i = i5;
                }
            }
        }
        this.f3207 = c2361M2549;
        C5551 c5551 = new C5551(this, (C1091) this.f3181.f17833);
        this.f3216 = c5551;
        c2361M2549.f9272.m10592(c5551);
        if (this.f3207.m6127()) {
            C4805 c48053 = this.f3181;
            if (((C1091) c48053.f17833).f4700) {
                C2361 c2361 = this.f3207;
                C3446 c3446 = (C3446) c48053.f17835;
                c2361.m6130(c3446.f12931, c3446.f12900);
            }
        }
        C1545 c1545 = this.f3211;
        if (c1545 != null) {
            this.f3207.m6126(c1545);
        }
        if (m2553()) {
            this.f3207.f9267.setVolume(this.f3220);
        }
        this.f3194.getClass();
        AudioDeviceInfo audioDeviceInfo = this.f3183;
        if (audioDeviceInfo != null) {
            this.f3207.f9267.setPreferredDevice(audioDeviceInfo);
        }
        this.f3210 = true;
        int audioSessionId = this.f3207.f9267.getAudioSessionId();
        boolean z2 = audioSessionId != this.f3175;
        this.f3175 = audioSessionId;
        InterfaceC5159 interfaceC5159 = this.f3208;
        if (interfaceC5159 != null) {
            int i6 = ((C1091) this.f3181.f17833).f4697;
            interfaceC5159.m10649(new ʾᵚᵱ(11));
            if (z2) {
                this.f3177 = true;
                C4805 c48054 = this.f3181;
                C0559 c0559M34942 = ((C1091) c48054.f17833).m3494();
                c0559M34942.f2923 = this.f3175;
                this.f3181 = new C4805((C3446) c48054.f17835, (C3446) c48054.f17838, c48054.f17836, c48054.f17837, new C1091(c0559M34942), (C4633) c48054.f17834);
                C4805 c48055 = this.f3212;
                if (c48055 != null) {
                    C0559 c0559M34943 = ((C1091) c48055.f17833).m3494();
                    c0559M34943.f2923 = this.f3175;
                    this.f3212 = new C4805((C3446) c48055.f17835, (C3446) c48055.f17838, c48055.f17836, c48055.f17837, new C1091(c0559M34943), (C4633) c48055.f17834);
                }
                this.f3208.m10646(this.f3175);
            }
        }
        return true;
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final boolean mo2577(C3446 c3446) {
        return mo2567(c3446) != 0;
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final void mo2578(int i) throws IllegalStateException {
        if (i == 0 || i == -1) {
            i = -1;
        }
        if (this.f3213 == i) {
            return;
        }
        this.f3213 = i;
        m2580();
    }

    @Override // defpackage.InterfaceC3867
    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final void mo2579(C0298 c0298) {
        if (this.f3194.equals(c0298)) {
            return;
        }
        c0298.getClass();
        if (this.f3207 != null) {
            this.f3194.getClass();
        }
        this.f3194 = c0298;
    }

    /* renamed from: ﾞⁱ, reason: contains not printable characters */
    public final void m2580() throws IllegalStateException {
        if (this.f3181 != null) {
            C4805 c4805 = this.f3212;
            if (c4805 != null) {
                this.f3181 = c4805;
                this.f3212 = null;
            }
            try {
                C1091 c1091M5806 = ((C2171) this.f3217).m5806(m2547((C3446) this.f3181.f17838));
                C4805 c48052 = this.f3181;
                this.f3181 = new C4805((C3446) c48052.f17835, (C3446) c48052.f17838, c48052.f17836, c48052.f17837, c1091M5806, (C4633) c48052.f17834);
            } catch (AudioOutputProvider$ConfigurationException e) {
                C2707.m6713(new AudioSink$ConfigurationException(e, (C3446) this.f3181.f17835));
                return;
            }
        }
        flush();
    }
}
