package B0;

import L0.AbstractC0146a;
import L0.C0147b;
import L0.InterfaceC0170z;
import android.content.Context;
import android.media.Spatializer;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.os.Trace;
import android.util.Pair;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
import n4.u0;
import u0.C1567c;
import u0.C1579o;
import u0.C1583t;
import u0.C1588y;
import x0.AbstractC1709a;

/* JADX INFO: loaded from: classes.dex */
public final class P implements Handler.Callback, InterfaceC0170z, k0 {
    public static final long q0 = x0.v.W(10000);

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public final u0.Q f605A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public final u0.P f606B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public final long f607C;
    public final C0026m D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public final ArrayList f608E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public final x0.q f609F;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public final C0038z f610G;
    public final Y H;

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    public final i0 f611I;

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public final C0023j f612J;

    /* JADX INFO: renamed from: K, reason: collision with root package name */
    public final long f613K;

    /* JADX INFO: renamed from: L, reason: collision with root package name */
    public final C0.l f614L;

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    public final C0.f f615M;

    /* JADX INFO: renamed from: N, reason: collision with root package name */
    public final x0.s f616N;

    /* JADX INFO: renamed from: O, reason: collision with root package name */
    public final boolean f617O;

    /* JADX INFO: renamed from: P, reason: collision with root package name */
    public final C0019f f618P;

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    public r0 f619Q;

    /* JADX INFO: renamed from: R, reason: collision with root package name */
    public j0 f620R;

    /* JADX INFO: renamed from: S, reason: collision with root package name */
    public A1.x f621S;

    /* JADX INFO: renamed from: T, reason: collision with root package name */
    public boolean f622T;

    /* JADX INFO: renamed from: V, reason: collision with root package name */
    public boolean f624V;

    /* JADX INFO: renamed from: W, reason: collision with root package name */
    public boolean f625W;

    /* JADX INFO: renamed from: Y, reason: collision with root package name */
    public boolean f626Y;

    /* JADX INFO: renamed from: Z, reason: collision with root package name */
    public int f627Z;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public boolean f628a0;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public boolean f629b0;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public boolean f630c0;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public boolean f631d0;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public int f632e0;

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public O f633f0;

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    public long f634g0;

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    public long f635h0;

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    public int f636i0;

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    public boolean f637j0;

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    public C0030q f638k0;

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public C0033u f640m0;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public boolean f642o0;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final q0[] f644q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final AbstractC0020g[] f645r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final boolean[] f646s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final O0.u f647t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final O0.v f648u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final C0025l f649v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final P0.d f650w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public final x0.s f651x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final A1.L f652y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final Looper f653z;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    public long f641n0 = -9223372036854775807L;

    /* JADX INFO: renamed from: U, reason: collision with root package name */
    public boolean f623U = false;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public float f643p0 = 1.0f;

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    public long f639l0 = -9223372036854775807L;
    public long X = -9223372036854775807L;

    public P(Context context, AbstractC0020g[] abstractC0020gArr, AbstractC0020g[] abstractC0020gArr2, O0.u uVar, O0.v vVar, C0025l c0025l, P0.d dVar, int i, boolean z8, C0.f fVar, r0 r0Var, C0023j c0023j, long j8, Looper looper, x0.q qVar, C0038z c0038z, C0.l lVar, C0033u c0033u) {
        this.f610G = c0038z;
        this.f647t = uVar;
        this.f648u = vVar;
        this.f649v = c0025l;
        this.f650w = dVar;
        this.f627Z = i;
        this.f628a0 = z8;
        this.f619Q = r0Var;
        this.f612J = c0023j;
        this.f613K = j8;
        this.f609F = qVar;
        this.f614L = lVar;
        this.f640m0 = c0033u;
        this.f615M = fVar;
        this.f607C = c0025l.f842g;
        u0.O o8 = u0.S.f17199a;
        j0 j0VarJ = j0.j(vVar);
        this.f620R = j0VarJ;
        this.f621S = new A1.x(j0VarJ);
        this.f645r = new AbstractC0020g[abstractC0020gArr.length];
        this.f646s = new boolean[abstractC0020gArr.length];
        O0.q qVar2 = (O0.q) uVar;
        qVar2.getClass();
        this.f644q = new q0[abstractC0020gArr.length];
        boolean z9 = false;
        for (int i5 = 0; i5 < abstractC0020gArr.length; i5++) {
            AbstractC0020g abstractC0020g = abstractC0020gArr[i5];
            abstractC0020g.f760u = i5;
            abstractC0020g.f761v = lVar;
            abstractC0020g.f762w = qVar;
            this.f645r[i5] = abstractC0020g;
            AbstractC0020g abstractC0020g2 = this.f645r[i5];
            synchronized (abstractC0020g2.f756q) {
                abstractC0020g2.f755G = qVar2;
            }
            AbstractC0020g abstractC0020g3 = abstractC0020gArr2[i5];
            if (abstractC0020g3 != null) {
                abstractC0020g3.f760u = abstractC0020gArr.length + i5;
                abstractC0020g3.f761v = lVar;
                abstractC0020g3.f762w = qVar;
                z9 = true;
            }
            this.f644q[i5] = new q0(abstractC0020gArr[i5], abstractC0020g3, i5);
        }
        this.f617O = z9;
        C0026m c0026m = new C0026m();
        c0026m.f847t = this;
        c0026m.f846s = new s0(qVar);
        c0026m.f844q = true;
        this.D = c0026m;
        this.f608E = new ArrayList();
        this.f605A = new u0.Q();
        this.f606B = new u0.P();
        uVar.f4907a = this;
        uVar.f4908b = dVar;
        this.f637j0 = true;
        x0.s sVarA = qVar.a(looper, null);
        this.f616N = sVarA;
        this.H = new Y(fVar, sVarA, new A1.G(7, this), c0033u);
        this.f611I = new i0(this, fVar, sVarA, lVar);
        A1.L l8 = new A1.L();
        this.f652y = l8;
        Looper looperB = l8.b();
        this.f653z = looperB;
        this.f651x = qVar.a(looperB, this);
        this.f618P = new C0019f(context, looperB, this);
    }

    public static Pair Q(u0.S s8, O o8, boolean z8, int i, boolean z9, u0.Q q8, u0.P p3) {
        int iR;
        u0.S s9 = o8.f602a;
        if (s8.p()) {
            return null;
        }
        u0.S s10 = s9.p() ? s8 : s9;
        try {
            Pair pairI = s10.i(q8, p3, o8.f603b, o8.f604c);
            if (!s8.equals(s10)) {
                if (s8.b(pairI.first) == -1) {
                    if (!z8 || (iR = R(q8, p3, i, z9, pairI.first, s10, s8)) == -1) {
                        return null;
                    }
                    return s8.i(q8, p3, iR, -9223372036854775807L);
                }
                if (s10.g(pairI.first, p3).f17180f && s10.m(p3.f17177c, q8, 0L).f17196n == s10.b(pairI.first)) {
                    return s8.i(q8, p3, s8.g(pairI.first, p3).f17177c, o8.f604c);
                }
            }
            return pairI;
        } catch (IndexOutOfBoundsException unused) {
            return null;
        }
    }

    public static int R(u0.Q q8, u0.P p3, int i, boolean z8, Object obj, u0.S s8, u0.S s9) {
        u0.Q q9 = q8;
        u0.S s10 = s8;
        Object obj2 = s10.m(s10.g(obj, p3).f17177c, q8, 0L).f17184a;
        for (int i5 = 0; i5 < s9.o(); i5++) {
            if (s9.m(i5, q8, 0L).f17184a.equals(obj2)) {
                return i5;
            }
        }
        int iB = s10.b(obj);
        int iH = s10.h();
        int iB2 = -1;
        int i8 = 0;
        while (i8 < iH && iB2 == -1) {
            u0.S s11 = s10;
            int iD = s11.d(iB, p3, q9, i, z8);
            if (iD == -1) {
                break;
            }
            iB2 = s9.b(s11.l(iD));
            i8++;
            s10 = s11;
            iB = iD;
            q9 = q8;
        }
        if (iB2 == -1) {
            return -1;
        }
        return s9.f(iB2, p3, false).f17177c;
    }

    /* JADX WARN: Type inference failed for: r1v0, types: [L0.A, L0.e0, java.lang.Object] */
    public static boolean x(V v7) {
        if (v7 != null) {
            try {
                ?? r12 = v7.f663a;
                if (v7.f667e) {
                    for (L0.c0 c0Var : v7.f665c) {
                        if (c0Var != null) {
                            c0Var.l();
                        }
                    }
                } else {
                    r12.l();
                }
                if ((!v7.f667e ? 0L : r12.r()) != Long.MIN_VALUE) {
                    return true;
                }
            } catch (IOException unused) {
            }
        }
        return false;
    }

    /* JADX WARN: Type inference failed for: r1v1, types: [L0.A, L0.e0, java.lang.Object] */
    public final void A() {
        Y y8 = this.H;
        y8.k();
        V v7 = y8.f702m;
        if (v7 != null) {
            if (!v7.f666d || v7.f667e) {
                ?? r12 = v7.f663a;
                if (r12.a()) {
                    return;
                }
                u0.S s8 = this.f620R.f815a;
                if (v7.f667e) {
                    r12.k();
                }
                Iterator it = this.f649v.f843h.values().iterator();
                while (it.hasNext()) {
                    if (((C0024k) it.next()).f834a) {
                        return;
                    }
                }
                if (!v7.f666d) {
                    W w4 = v7.f669g;
                    v7.f666d = true;
                    r12.o(this, w4.f679b);
                    return;
                }
                S s9 = new S();
                s9.f657a = this.f634g0 - v7.f677p;
                float f3 = this.D.b().f17159a;
                AbstractC1709a.d(f3 > 0.0f || f3 == -3.4028235E38f);
                s9.f658b = f3;
                long j8 = this.X;
                AbstractC1709a.d(j8 >= 0 || j8 == -9223372036854775807L);
                s9.f659c = j8;
                T t6 = new T(s9);
                AbstractC1709a.j(v7.f674m == null);
                r12.f(t6);
            }
        }
    }

    public final void B() {
        A1.x xVar = this.f621S;
        j0 j0Var = this.f620R;
        boolean z8 = xVar.f357b | (((j0) xVar.f361f) != j0Var);
        xVar.f357b = z8;
        xVar.f361f = j0Var;
        if (z8) {
            I i = this.f610G.f927q;
            i.f585z.c(new A(i, 0, xVar));
            this.f621S = new A1.x(this.f620R);
        }
    }

    public final void C(int i) {
        q0 q0Var = this.f644q[i];
        try {
            V v7 = this.H.i;
            v7.getClass();
            AbstractC0020g abstractC0020gD = q0Var.d(v7);
            abstractC0020gD.getClass();
            L0.c0 c0Var = abstractC0020gD.f764y;
            c0Var.getClass();
            c0Var.l();
        } catch (IOException | RuntimeException e8) {
            int i5 = q0Var.f879a.f757r;
            if (i5 != 3 && i5 != 5) {
                throw e8;
            }
            O0.v vVar = this.H.i.f676o;
            AbstractC1709a.p("ExoPlayerImplInternal", "Disabling track due to error: " + C1579o.c(vVar.f4911c[i].e()), e8);
            O0.v vVar2 = new O0.v((p0[]) vVar.f4910b.clone(), (O0.s[]) vVar.f4911c.clone(), vVar.f4912d, vVar.f4913e);
            vVar2.f4910b[i] = null;
            vVar2.f4911c[i] = null;
            e(i);
            V v8 = this.H.i;
            v8.a(vVar2, this.f620R.f832s, false, new boolean[v8.f671j.length]);
        }
    }

    public final void D(int i, boolean z8) {
        boolean[] zArr = this.f646s;
        if (zArr[i] != z8) {
            zArr[i] = z8;
            this.f616N.c(new K(this, i, z8));
        }
    }

    public final void E() throws Throwable {
        t(this.f611I.c(), true);
    }

    public final void F() {
        this.f621S.f(1);
        throw null;
    }

    public final void G() {
        this.f621S.f(1);
        int i = 0;
        M(false, false, false, true);
        C0025l c0025l = this.f649v;
        c0025l.getClass();
        long id = Thread.currentThread().getId();
        long j8 = c0025l.i;
        AbstractC1709a.i("Players that share the same LoadControl must share the same playback thread. See ExoPlayer.Builder.setPlaybackLooper(Looper).", j8 == -1 || j8 == id);
        c0025l.i = id;
        HashMap map = c0025l.f843h;
        C0.l lVar = this.f614L;
        if (!map.containsKey(lVar)) {
            map.put(lVar, new C0024k());
        }
        C0024k c0024k = (C0024k) map.get(lVar);
        c0024k.getClass();
        int i5 = c0025l.f841f;
        if (i5 == -1) {
            i5 = 13107200;
        }
        c0024k.f835b = i5;
        c0024k.f834a = false;
        i0(this.f620R.f815a.p() ? 4 : 2);
        j0 j0Var = this.f620R;
        boolean z8 = j0Var.f825l;
        t0(this.f618P.d(j0Var.f819e, z8), j0Var.f827n, j0Var.f826m, z8);
        P0.g gVar = (P0.g) this.f650w;
        gVar.getClass();
        i0 i0Var = this.f611I;
        AbstractC1709a.j(!i0Var.f791b);
        i0Var.f800l = gVar;
        while (true) {
            ArrayList arrayList = (ArrayList) i0Var.f790a;
            if (i >= arrayList.size()) {
                i0Var.f791b = true;
                this.f651x.e(2);
                return;
            } else {
                h0 h0Var = (h0) arrayList.get(i);
                i0Var.g(h0Var);
                ((HashSet) i0Var.f797h).add(h0Var);
                i++;
            }
        }
    }

    public final synchronized boolean H() {
        if (!this.f622T && this.f653z.getThread().isAlive()) {
            this.f651x.e(7);
            x0(new J(0, this), this.f613K);
            return this.f622T;
        }
        return true;
    }

    public final void I() {
        C0016c c0016c;
        Spatializer spatializer;
        O0.l lVar;
        Handler handler;
        try {
            M(true, false, true, false);
            J();
            C0025l c0025l = this.f649v;
            if (c0025l.f843h.remove(this.f614L) != null) {
                c0025l.d();
            }
            if (c0025l.f843h.isEmpty()) {
                c0025l.i = -1L;
            }
            C0019f c0019f = this.f618P;
            c0019f.f742c = null;
            c0019f.a();
            c0019f.c(0);
            O0.q qVar = (O0.q) this.f647t;
            qVar.getClass();
            if (x0.v.f18553a >= 32 && (c0016c = qVar.f4903g) != null && (spatializer = (Spatializer) c0016c.f718r) != null && (lVar = (O0.l) c0016c.f720t) != null && (handler = (Handler) c0016c.f719s) != null) {
                spatializer.removeOnSpatializerStateChangedListener(lVar);
                handler.removeCallbacksAndMessages(null);
            }
            qVar.f4907a = null;
            qVar.f4908b = null;
            i0(1);
            this.f652y.c();
            synchronized (this) {
                this.f622T = true;
                notifyAll();
            }
        } catch (Throwable th) {
            this.f652y.c();
            synchronized (this) {
                this.f622T = true;
                notifyAll();
                throw th;
            }
        }
    }

    public final void J() {
        for (int i = 0; i < this.f644q.length; i++) {
            AbstractC0020g abstractC0020g = this.f645r[i];
            synchronized (abstractC0020g.f756q) {
                abstractC0020g.f755G = null;
            }
            q0 q0Var = this.f644q[i];
            AbstractC0020g abstractC0020g2 = q0Var.f879a;
            AbstractC1709a.j(abstractC0020g2.f763x == 0);
            abstractC0020g2.p();
            q0Var.f883e = false;
            AbstractC0020g abstractC0020g3 = q0Var.f881c;
            if (abstractC0020g3 != null) {
                AbstractC1709a.j(abstractC0020g3.f763x == 0);
                abstractC0020g3.p();
                q0Var.f884f = false;
            }
        }
    }

    public final void K(int i, int i5, L0.f0 f0Var) throws Throwable {
        this.f621S.f(1);
        i0 i0Var = this.f611I;
        i0Var.getClass();
        AbstractC1709a.d(i >= 0 && i <= i5 && i5 <= ((ArrayList) i0Var.f790a).size());
        i0Var.f799k = f0Var;
        i0Var.i(i, i5);
        t(i0Var.c(), false);
    }

    /* JADX WARN: Removed duplicated region for block: B:78:0x0173  */
    /* JADX WARN: Removed duplicated region for block: B:91:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void L() {
        int i;
        int i5;
        float f3 = this.D.b().f17159a;
        Y y8 = this.H;
        V v7 = y8.i;
        V v8 = y8.f699j;
        O0.v vVar = null;
        V v9 = v7;
        boolean z8 = true;
        while (v9 != null && v9.f667e) {
            j0 j0Var = this.f620R;
            O0.v vVarJ = v9.j(f3, j0Var.f815a, j0Var.f825l);
            O0.v vVar2 = v9 == this.H.i ? vVarJ : vVar;
            O0.v vVar3 = v9.f676o;
            if (vVar3 != null) {
                int length = vVar3.f4911c.length;
                O0.s[] sVarArr = vVarJ.f4911c;
                if (length == sVarArr.length) {
                    for (int i8 = 0; i8 < sVarArr.length; i8++) {
                        if (vVarJ.a(vVar3, i8)) {
                        }
                    }
                    if (v9 == v8) {
                        z8 = false;
                    }
                    v9 = v9.f674m;
                    vVar = vVar2;
                }
            }
            if (!z8) {
                i = 4;
                this.H.n(v9);
                if (v9.f667e) {
                    long jMax = Math.max(v9.f669g.f679b, this.f634g0 - v9.f677p);
                    if (this.f617O && b() && this.H.f700k == v9) {
                        d();
                    }
                    i5 = 4;
                    v9.a(vVarJ, jMax, false, new boolean[v9.f671j.length]);
                }
                r(true);
                if (this.f620R.f819e == i5) {
                    z();
                    u0();
                    this.f651x.e(2);
                    return;
                }
                return;
            }
            Y y9 = this.H;
            V v10 = y9.i;
            boolean z9 = (y9.n(v10) & 1) != 0;
            boolean[] zArr = new boolean[this.f644q.length];
            vVar2.getClass();
            long jA = v10.a(vVar2, this.f620R.f832s, z9, zArr);
            j0 j0Var2 = this.f620R;
            boolean z10 = (j0Var2.f819e == 4 || jA == j0Var2.f832s) ? false : true;
            j0 j0Var3 = this.f620R;
            i = 4;
            this.f620R = w(j0Var3.f816b, jA, j0Var3.f817c, j0Var3.f818d, z10, 5);
            if (z10) {
                O(jA);
            }
            d();
            boolean[] zArr2 = new boolean[this.f644q.length];
            int i9 = 0;
            while (true) {
                q0[] q0VarArr = this.f644q;
                if (i9 >= q0VarArr.length) {
                    break;
                }
                int iC = q0VarArr[i9].c();
                zArr2[i9] = this.f644q[i9].g();
                q0 q0Var = this.f644q[i9];
                L0.c0 c0Var = v10.f665c[i9];
                C0026m c0026m = this.D;
                long j8 = this.f634g0;
                boolean z11 = zArr[i9];
                AbstractC0020g abstractC0020g = q0Var.f879a;
                if (q0.h(abstractC0020g)) {
                    if (c0Var != abstractC0020g.f764y) {
                        q0Var.a(abstractC0020g, c0026m);
                    } else if (z11) {
                        abstractC0020g.D = false;
                        abstractC0020g.f751B = j8;
                        abstractC0020g.f752C = j8;
                        abstractC0020g.o(j8, false);
                    }
                }
                AbstractC0020g abstractC0020g2 = q0Var.f881c;
                if (abstractC0020g2 != null && q0.h(abstractC0020g2)) {
                    if (c0Var != abstractC0020g2.f764y) {
                        q0Var.a(abstractC0020g2, c0026m);
                    } else if (z11) {
                        abstractC0020g2.D = false;
                        abstractC0020g2.f751B = j8;
                        abstractC0020g2.f752C = j8;
                        abstractC0020g2.o(j8, false);
                    }
                }
                if (iC - this.f644q[i9].c() > 0) {
                    D(i9, false);
                }
                this.f632e0 -= iC - this.f644q[i9].c();
                i9++;
            }
            h(zArr2, this.f634g0);
            v10.f670h = true;
            i5 = i;
            r(true);
            if (this.f620R.f819e == i5) {
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x008f  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x0125  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void M(boolean z8, boolean z9, boolean z10, boolean z11) {
        long j8;
        long j9;
        long j10;
        boolean z12;
        L0.C c3;
        u0.S s8;
        List list;
        this.f651x.d(2);
        this.f638k0 = null;
        boolean z13 = true;
        w0(false, true);
        C0026m c0026m = this.D;
        c0026m.f845r = false;
        s0 s0Var = (s0) c0026m.f846s;
        if (s0Var.f891r) {
            s0Var.d(s0Var.e());
            s0Var.f891r = false;
        }
        this.f634g0 = 1000000000000L;
        for (int i = 0; i < this.f644q.length; i++) {
            try {
                e(i);
            } catch (C0030q | RuntimeException e8) {
                AbstractC1709a.p("ExoPlayerImplInternal", "Disable failed.", e8);
            }
        }
        this.f641n0 = -9223372036854775807L;
        if (z8) {
            for (q0 q0Var : this.f644q) {
                try {
                    q0Var.l();
                } catch (RuntimeException e9) {
                    AbstractC1709a.p("ExoPlayerImplInternal", "Reset failed.", e9);
                }
            }
        }
        this.f632e0 = 0;
        j0 j0Var = this.f620R;
        L0.C c8 = j0Var.f816b;
        long j11 = j0Var.f832s;
        if (!this.f620R.f816b.b()) {
            j0 j0Var2 = this.f620R;
            u0.P p3 = this.f606B;
            L0.C c9 = j0Var2.f816b;
            u0.S s9 = j0Var2.f815a;
            j8 = (s9.p() || s9.g(c9.f3625a, p3).f17180f) ? this.f620R.f817c : this.f620R.f832s;
        }
        if (z9) {
            this.f633f0 = null;
            Pair pairK = k(this.f620R.f815a);
            c8 = (L0.C) pairK.first;
            long jLongValue = ((Long) pairK.second).longValue();
            z12 = !c8.equals(this.f620R.f816b);
            j9 = jLongValue;
            j10 = -9223372036854775807L;
        } else {
            j9 = j11;
            j10 = j8;
            z12 = false;
        }
        this.H.b();
        this.f626Y = false;
        u0.S s10 = this.f620R.f815a;
        if (z10 && (s10 instanceof o0)) {
            o0 o0Var = (o0) s10;
            L0.f0 f0Var = (L0.f0) this.f611I.f799k;
            u0.S[] sArr = o0Var.f867h;
            u0.S[] sArr2 = new u0.S[sArr.length];
            int i5 = 0;
            while (i5 < sArr.length) {
                sArr2[i5] = new n0(sArr[i5]);
                i5++;
                z13 = z13;
            }
            o0 o0Var2 = new o0(sArr2, o0Var.i, f0Var);
            if (c8.f3626b != -1) {
                o0Var2.g(c8.f3625a, this.f606B);
                int i8 = this.f606B.f17177c;
                u0.Q q8 = this.f605A;
                o0Var2.m(i8, q8, 0L);
                if (q8.a()) {
                    s8 = o0Var2;
                    c3 = new L0.C(c8.f3628d, c8.f3625a);
                } else {
                    c3 = c8;
                    s8 = o0Var2;
                }
            }
        } else {
            c3 = c8;
            s8 = s10;
        }
        j0 j0Var3 = this.f620R;
        int i9 = j0Var3.f819e;
        C0030q c0030q = z11 ? null : j0Var3.f820f;
        L0.n0 n0Var = z12 ? L0.n0.f3882d : j0Var3.f822h;
        O0.v vVar = z12 ? this.f648u : j0Var3.i;
        if (z12) {
            C3.E e10 = C3.G.f1197r;
            list = C3.W.f1225u;
        } else {
            list = j0Var3.f823j;
        }
        this.f620R = new j0(s8, c3, j10, j9, i9, c0030q, false, n0Var, vVar, list, c3, j0Var3.f825l, j0Var3.f826m, j0Var3.f827n, j0Var3.f828o, j9, 0L, j9, 0L, false);
        if (z10) {
            Y y8 = this.H;
            if (!y8.f706q.isEmpty()) {
                ArrayList arrayList = new ArrayList();
                for (int i10 = 0; i10 < y8.f706q.size(); i10++) {
                    ((V) y8.f706q.get(i10)).i();
                }
                y8.f706q = arrayList;
                y8.f702m = null;
                y8.k();
            }
            i0 i0Var = this.f611I;
            HashMap map = (HashMap) i0Var.f795f;
            for (g0 g0Var : map.values()) {
                try {
                    g0Var.f766a.n(g0Var.f767b);
                } catch (RuntimeException e11) {
                    AbstractC1709a.p("MediaSourceList", "Failed to release child source.", e11);
                }
                AbstractC0146a abstractC0146a = g0Var.f766a;
                f0 f0Var2 = g0Var.f768c;
                abstractC0146a.q(f0Var2);
                g0Var.f766a.p(f0Var2);
            }
            map.clear();
            ((HashSet) i0Var.f797h).clear();
            i0Var.f791b = false;
        }
    }

    public final void N() {
        V v7 = this.H.i;
        this.f624V = v7 != null && v7.f669g.i && this.f623U;
    }

    public final void O(long j8) {
        V v7 = this.H.i;
        long j9 = j8 + (v7 == null ? 1000000000000L : v7.f677p);
        this.f634g0 = j9;
        ((s0) this.D.f846s).d(j9);
        for (q0 q0Var : this.f644q) {
            long j10 = this.f634g0;
            AbstractC0020g abstractC0020gD = q0Var.d(v7);
            if (abstractC0020gD != null) {
                abstractC0020gD.D = false;
                abstractC0020gD.f751B = j10;
                abstractC0020gD.f752C = j10;
                abstractC0020gD.o(j10, false);
            }
        }
        for (V v8 = r0.i; v8 != null; v8 = v8.f674m) {
            for (O0.s sVar : v8.f676o.f4911c) {
                if (sVar != null) {
                    sVar.m();
                }
            }
        }
    }

    public final void P(u0.S s8, u0.S s9) {
        if (s8.p() && s9.p()) {
            return;
        }
        ArrayList arrayList = this.f608E;
        int size = arrayList.size() - 1;
        if (size < 0) {
            Collections.sort(arrayList);
        } else {
            I1.a.v(arrayList.get(size));
            throw null;
        }
    }

    public final void S(long j8) {
        this.f651x.f18548a.sendEmptyMessageAtTime(2, j8 + ((this.f620R.f819e != 3 || l0()) ? q0 : 1000L));
    }

    public final void T(boolean z8) {
        L0.C c3 = this.H.i.f669g.f678a;
        long jV = V(c3, this.f620R.f832s, true, false);
        if (jV != this.f620R.f832s) {
            j0 j0Var = this.f620R;
            this.f620R = w(c3, jV, j0Var.f817c, j0Var.f818d, z8, 5);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:23:0x00a0 A[Catch: all -> 0x00a3, TryCatch #1 {all -> 0x00a3, blocks: (B:21:0x0096, B:23:0x00a0, B:30:0x00ac, B:32:0x00b2, B:33:0x00b5, B:35:0x00bd, B:40:0x00cd, B:44:0x00d5), top: B:100:0x0096 }] */
    /* JADX WARN: Removed duplicated region for block: B:28:0x00a9  */
    /* JADX WARN: Type inference failed for: r0v17, types: [L0.A, java.lang.Object] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void U(O o8) throws Throwable {
        long jLongValue;
        L0.C cP;
        long j8;
        boolean z8;
        long j9;
        boolean z9;
        L0.C c3;
        long j10;
        long jC;
        long j11;
        j0 j0Var;
        int i;
        long j12;
        L0.C c8;
        int i5;
        long j13;
        long jV;
        j0 j0Var2;
        L0.C c9;
        u0.S s8;
        long j14;
        P p3 = this;
        p3.f621S.f(1);
        Pair pairQ = Q(p3.f620R.f815a, o8, true, p3.f627Z, p3.f628a0, p3.f605A, p3.f606B);
        try {
            if (pairQ == null) {
                Pair pairK = p3.k(p3.f620R.f815a);
                cP = (L0.C) pairK.first;
                jLongValue = ((Long) pairK.second).longValue();
                z8 = !p3.f620R.f815a.p();
                j9 = -9223372036854775807L;
            } else {
                Object obj = pairQ.first;
                jLongValue = ((Long) pairQ.second).longValue();
                long j15 = o8.f604c == -9223372036854775807L ? -9223372036854775807L : jLongValue;
                cP = p3.H.p(p3.f620R.f815a, obj, jLongValue);
                if (!cP.b()) {
                    j8 = 0;
                    z8 = o8.f604c == -9223372036854775807L;
                    j9 = j15;
                    if (!p3.f620R.f815a.p()) {
                        p3.f633f0 = o8;
                    } else if (pairQ == null) {
                        if (p3.f620R.f819e != 1) {
                            p3.i0(4);
                        }
                        p3.M(false, true, false, true);
                    } else {
                        try {
                            try {
                                try {
                                    try {
                                        if (cP.equals(p3.f620R.f816b)) {
                                            try {
                                            } catch (Throwable th) {
                                                th = th;
                                                z9 = z8;
                                                c3 = cP;
                                                j10 = jLongValue;
                                                p3.f620R = p3.w(c3, j10, j9, j10, z9, 2);
                                                throw th;
                                            }
                                            try {
                                                V v7 = p3.H.i;
                                                jC = (v7 == null || !v7.f667e || jLongValue == j8) ? jLongValue : v7.f663a.c(jLongValue, p3.f619Q);
                                                if (x0.v.W(jC) != x0.v.W(p3.f620R.f832s) || ((i = (j0Var = p3.f620R).f819e) != 2 && i != 3)) {
                                                    z9 = z8;
                                                    j11 = j9;
                                                    c3 = cP;
                                                }
                                                j12 = j0Var.f832s;
                                                z9 = z8;
                                                c8 = cP;
                                                i5 = 2;
                                                j13 = j12;
                                                p3.f620R = p3.w(c8, j12, j9, j13, z9, i5);
                                                return;
                                            } catch (Throwable th2) {
                                                th = th2;
                                                z9 = z8;
                                                c3 = cP;
                                                j10 = jLongValue;
                                                j9 = j9;
                                                p3.f620R = p3.w(c3, j10, j9, j10, z9, 2);
                                                throw th;
                                            }
                                        }
                                        z9 = z8;
                                        j11 = j9;
                                        c3 = cP;
                                        jC = jLongValue;
                                        p3.v0(s8, c9, s8, j0Var2.f816b, j14, true);
                                        c8 = c9;
                                        j9 = j14;
                                        j12 = jV;
                                        i5 = 2;
                                        j13 = j12;
                                        p3 = this;
                                        p3.f620R = p3.w(c8, j12, j9, j13, z9, i5);
                                        return;
                                    } catch (Throwable th3) {
                                        th = th3;
                                        c3 = c9;
                                        j9 = j14;
                                        j10 = jV;
                                        p3.f620R = p3.w(c3, j10, j9, j10, z9, 2);
                                        throw th;
                                    }
                                    s8 = j0Var2.f815a;
                                    j14 = j11;
                                } catch (Throwable th4) {
                                    th = th4;
                                    c3 = c9;
                                    j9 = j11;
                                    j10 = jV;
                                    p3.f620R = p3.w(c3, j10, j9, j10, z9, 2);
                                    throw th;
                                }
                                j0Var2 = p3.f620R;
                                c9 = c3;
                            } catch (Throwable th5) {
                                th = th5;
                            }
                            boolean z10 = p3.f620R.f819e == 4;
                            Y y8 = p3.H;
                            jV = p3.V(c3, jC, y8.i != y8.f699j, z10);
                            z9 |= jLongValue != jV;
                        } catch (Throwable th6) {
                            th = th6;
                            j9 = j11;
                            j10 = jLongValue;
                            p3.f620R = p3.w(c3, j10, j9, j10, z9, 2);
                            throw th;
                        }
                    }
                    z9 = z8;
                    c8 = cP;
                    j12 = jLongValue;
                    i5 = 2;
                    j13 = j12;
                    p3 = this;
                    p3.f620R = p3.w(c8, j12, j9, j13, z9, i5);
                    return;
                }
                p3.f620R.f815a.g(cP.f3625a, p3.f606B);
                if (p3.f606B.e(cP.f3626b) == cP.f3627c) {
                    p3.f606B.f17181g.getClass();
                }
                z8 = true;
                j9 = j15;
                jLongValue = 0;
            }
            if (!p3.f620R.f815a.p()) {
            }
            z9 = z8;
            c8 = cP;
            j12 = jLongValue;
            i5 = 2;
            j13 = j12;
            p3 = this;
            p3.f620R = p3.w(c8, j12, j9, j13, z9, i5);
            return;
        } catch (Throwable th7) {
            th = th7;
            z9 = z8;
        }
        j8 = 0;
    }

    /* JADX WARN: Type inference failed for: r10v10, types: [L0.A, java.lang.Object] */
    public final long V(L0.C c3, long j8, boolean z8, boolean z9) {
        q0[] q0VarArr;
        p0();
        w0(false, true);
        if (z9 || this.f620R.f819e == 3) {
            i0(2);
        }
        Y y8 = this.H;
        V v7 = y8.i;
        V v8 = v7;
        while (v8 != null && !c3.equals(v8.f669g.f678a)) {
            v8 = v8.f674m;
        }
        if (z8 || v7 != v8 || (v8 != null && v8.f677p + j8 < 0)) {
            int i = 0;
            while (true) {
                q0VarArr = this.f644q;
                if (i >= q0VarArr.length) {
                    break;
                }
                e(i);
                i++;
            }
            this.f641n0 = -9223372036854775807L;
            if (v8 != null) {
                while (y8.i != v8) {
                    y8.a();
                }
                y8.n(v8);
                v8.f677p = 1000000000000L;
                h(new boolean[q0VarArr.length], y8.f699j.e());
                v8.f670h = true;
            }
        }
        d();
        if (v8 != null) {
            y8.n(v8);
            if (!v8.f667e) {
                v8.f669g = v8.f669g.b(j8);
            } else if (v8.f668f) {
                ?? r10 = v8.f663a;
                j8 = r10.p(j8);
                r10.q(j8 - this.f607C);
            }
            O(j8);
            z();
        } else {
            y8.b();
            O(j8);
        }
        r(false);
        this.f651x.e(2);
        return j8;
    }

    public final void W(m0 m0Var) {
        m0Var.getClass();
        Looper looper = m0Var.f854e;
        Looper looper2 = this.f653z;
        x0.s sVar = this.f651x;
        if (looper != looper2) {
            sVar.a(15, m0Var).b();
            return;
        }
        synchronized (m0Var) {
        }
        try {
            m0Var.f850a.d(m0Var.f852c, m0Var.f853d);
            m0Var.a(true);
            int i = this.f620R.f819e;
            if (i == 3 || i == 2) {
                sVar.e(2);
            }
        } catch (Throwable th) {
            m0Var.a(true);
            throw th;
        }
    }

    public final void X(m0 m0Var) {
        Looper looper = m0Var.f854e;
        if (looper.getThread().isAlive()) {
            this.f609F.a(looper, null).c(new A(this, 1, m0Var));
        } else {
            AbstractC1709a.B("TAG", "Trying to send message on a dead thread.");
            m0Var.a(false);
        }
    }

    public final void Y(C1567c c1567c, boolean z8) {
        O0.q qVar = (O0.q) this.f647t;
        if (!qVar.f4904h.equals(c1567c)) {
            qVar.f4904h = c1567c;
            qVar.d();
        }
        if (!z8) {
            c1567c = null;
        }
        C0019f c0019f = this.f618P;
        if (!Objects.equals(c0019f.f743d, c1567c)) {
            c0019f.f743d = c1567c;
            int i = c1567c == null ? 0 : 1;
            c0019f.f745f = i;
            AbstractC1709a.c("Automatic handling of audio focus is only available for USAGE_MEDIA and USAGE_GAME.", i == 1 || i == 0);
        }
        j0 j0Var = this.f620R;
        boolean z9 = j0Var.f825l;
        t0(c0019f.d(j0Var.f819e, z9), j0Var.f827n, j0Var.f826m, z9);
    }

    public final void Z(boolean z8, AtomicBoolean atomicBoolean) {
        if (this.f629b0 != z8) {
            this.f629b0 = z8;
            if (!z8) {
                for (q0 q0Var : this.f644q) {
                    q0Var.l();
                }
            }
        }
        if (atomicBoolean != null) {
            synchronized (this) {
                atomicBoolean.set(true);
                notifyAll();
            }
        }
    }

    public final void a(M m8, int i) throws Throwable {
        this.f621S.f(1);
        i0 i0Var = this.f611I;
        if (i == -1) {
            i = ((ArrayList) i0Var.f790a).size();
        }
        t(i0Var.a(i, m8.f592a, m8.f593b), false);
    }

    public final void a0(M m8) throws Throwable {
        this.f621S.f(1);
        int i = m8.f594c;
        ArrayList arrayList = m8.f592a;
        L0.f0 f0Var = m8.f593b;
        if (i != -1) {
            this.f633f0 = new O(new o0(arrayList, f0Var), m8.f594c, m8.f595d);
        }
        i0 i0Var = this.f611I;
        ArrayList arrayList2 = (ArrayList) i0Var.f790a;
        i0Var.i(0, arrayList2.size());
        t(i0Var.a(arrayList2.size(), arrayList, f0Var), false);
    }

    public final boolean b() {
        if (!this.f617O) {
            return false;
        }
        for (q0 q0Var : this.f644q) {
            if (q0Var.f()) {
                return true;
            }
        }
        return false;
    }

    public final void b0(boolean z8) {
        this.f623U = z8;
        N();
        if (this.f624V) {
            Y y8 = this.H;
            if (y8.f699j != y8.i) {
                T(true);
                r(false);
            }
        }
    }

    public final void c() {
        L();
        T(true);
    }

    public final void c0(u0.H h8) {
        this.f651x.d(16);
        C0026m c0026m = this.D;
        c0026m.a(h8);
        u0.H hB = c0026m.b();
        v(hB, hB.f17159a, true, true);
    }

    public final void d() {
        AbstractC0020g abstractC0020g;
        if (this.f617O && b()) {
            for (q0 q0Var : this.f644q) {
                int iC = q0Var.c();
                if (q0Var.f()) {
                    int i = q0Var.f882d;
                    boolean z8 = i == 4 || i == 2;
                    int i5 = i != 4 ? 0 : 1;
                    if (z8) {
                        abstractC0020g = q0Var.f879a;
                    } else {
                        abstractC0020g = q0Var.f881c;
                        abstractC0020g.getClass();
                    }
                    q0Var.a(abstractC0020g, this.D);
                    q0Var.j(z8);
                    q0Var.f882d = i5;
                }
                this.f632e0 -= iC - q0Var.c();
            }
            this.f641n0 = -9223372036854775807L;
        }
    }

    public final void d0(C0033u c0033u) {
        this.f640m0 = c0033u;
        u0.S s8 = this.f620R.f815a;
        Y y8 = this.H;
        y8.getClass();
        c0033u.getClass();
        if (y8.f706q.isEmpty()) {
            return;
        }
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < y8.f706q.size(); i++) {
            ((V) y8.f706q.get(i)).i();
        }
        y8.f706q = arrayList;
        y8.f702m = null;
        y8.k();
    }

    public final void e(int i) {
        q0[] q0VarArr = this.f644q;
        int iC = q0VarArr[i].c();
        q0 q0Var = q0VarArr[i];
        AbstractC0020g abstractC0020g = q0Var.f879a;
        C0026m c0026m = this.D;
        q0Var.a(abstractC0020g, c0026m);
        AbstractC0020g abstractC0020g2 = q0Var.f881c;
        if (abstractC0020g2 != null) {
            boolean z8 = (abstractC0020g2.f763x != 0) && q0Var.f882d != 3;
            q0Var.a(abstractC0020g2, c0026m);
            q0Var.j(false);
            if (z8) {
                abstractC0020g2.getClass();
                abstractC0020g2.d(17, q0Var.f879a);
            }
        }
        q0Var.f882d = 0;
        D(i, false);
        this.f632e0 -= iC;
    }

    public final void e0(int i) {
        this.f627Z = i;
        u0.S s8 = this.f620R.f815a;
        Y y8 = this.H;
        y8.f697g = i;
        int iR = y8.r(s8);
        if ((iR & 1) != 0) {
            T(true);
        } else if ((iR & 2) != 0) {
            d();
        }
        r(false);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:106:0x01f6  */
    /* JADX WARN: Removed duplicated region for block: B:116:0x0220  */
    /* JADX WARN: Removed duplicated region for block: B:18:0x0058  */
    /* JADX WARN: Removed duplicated region for block: B:199:0x0357  */
    /* JADX WARN: Removed duplicated region for block: B:256:0x041a  */
    /* JADX WARN: Removed duplicated region for block: B:310:0x04c7  */
    /* JADX WARN: Removed duplicated region for block: B:313:0x04e6  */
    /* JADX WARN: Removed duplicated region for block: B:320:0x04ff  */
    /* JADX WARN: Removed duplicated region for block: B:327:0x0534  */
    /* JADX WARN: Removed duplicated region for block: B:349:0x0571  */
    /* JADX WARN: Removed duplicated region for block: B:353:0x057c  */
    /* JADX WARN: Removed duplicated region for block: B:412:0x0643  */
    /* JADX WARN: Removed duplicated region for block: B:459:0x06dc  */
    /* JADX WARN: Removed duplicated region for block: B:509:0x07a3  */
    /* JADX WARN: Removed duplicated region for block: B:540:0x080d  */
    /* JADX WARN: Removed duplicated region for block: B:559:0x0847  */
    /* JADX WARN: Removed duplicated region for block: B:561:0x084a  */
    /* JADX WARN: Removed duplicated region for block: B:562:0x0852  */
    /* JADX WARN: Removed duplicated region for block: B:572:0x088a  */
    /* JADX WARN: Removed duplicated region for block: B:575:0x088f  */
    /* JADX WARN: Removed duplicated region for block: B:579:0x0896  */
    /* JADX WARN: Removed duplicated region for block: B:582:0x089d  */
    /* JADX WARN: Removed duplicated region for block: B:583:0x08f6  */
    /* JADX WARN: Removed duplicated region for block: B:74:0x018c  */
    /* JADX WARN: Type inference failed for: r10v1 */
    /* JADX WARN: Type inference failed for: r10v10 */
    /* JADX WARN: Type inference failed for: r10v11 */
    /* JADX WARN: Type inference failed for: r10v12 */
    /* JADX WARN: Type inference failed for: r10v13 */
    /* JADX WARN: Type inference failed for: r10v15 */
    /* JADX WARN: Type inference failed for: r10v16 */
    /* JADX WARN: Type inference failed for: r10v17 */
    /* JADX WARN: Type inference failed for: r10v18 */
    /* JADX WARN: Type inference failed for: r10v19 */
    /* JADX WARN: Type inference failed for: r10v2 */
    /* JADX WARN: Type inference failed for: r10v20 */
    /* JADX WARN: Type inference failed for: r10v21, types: [int] */
    /* JADX WARN: Type inference failed for: r10v22 */
    /* JADX WARN: Type inference failed for: r10v24 */
    /* JADX WARN: Type inference failed for: r10v25 */
    /* JADX WARN: Type inference failed for: r10v26, types: [int] */
    /* JADX WARN: Type inference failed for: r10v4 */
    /* JADX WARN: Type inference failed for: r10v40 */
    /* JADX WARN: Type inference failed for: r10v41 */
    /* JADX WARN: Type inference failed for: r10v42 */
    /* JADX WARN: Type inference failed for: r10v43 */
    /* JADX WARN: Type inference failed for: r10v5, types: [int] */
    /* JADX WARN: Type inference failed for: r10v7 */
    /* JADX WARN: Type inference failed for: r10v8 */
    /* JADX WARN: Type inference failed for: r14v12 */
    /* JADX WARN: Type inference failed for: r14v13 */
    /* JADX WARN: Type inference failed for: r14v14 */
    /* JADX WARN: Type inference failed for: r15v0 */
    /* JADX WARN: Type inference failed for: r15v1, types: [boolean, int] */
    /* JADX WARN: Type inference failed for: r15v3 */
    /* JADX WARN: Type inference failed for: r2v113 */
    /* JADX WARN: Type inference failed for: r2v3, types: [L0.A, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r2v39 */
    /* JADX WARN: Type inference failed for: r2v4 */
    /* JADX WARN: Type inference failed for: r2v40 */
    /* JADX WARN: Type inference failed for: r2v41 */
    /* JADX WARN: Type inference failed for: r2v45, types: [L0.A, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r2v46 */
    /* JADX WARN: Type inference failed for: r2v47 */
    /* JADX WARN: Type inference failed for: r2v48 */
    /* JADX WARN: Type inference failed for: r2v49 */
    /* JADX WARN: Type inference failed for: r2v5 */
    /* JADX WARN: Type inference failed for: r2v50 */
    /* JADX WARN: Type inference failed for: r2v51 */
    /* JADX WARN: Type inference failed for: r2v61, types: [L0.A, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r3v115, types: [L0.A, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r3v130 */
    /* JADX WARN: Type inference failed for: r3v16 */
    /* JADX WARN: Type inference failed for: r3v17 */
    /* JADX WARN: Type inference failed for: r3v31 */
    /* JADX WARN: Type inference failed for: r3v32, types: [boolean] */
    /* JADX WARN: Type inference failed for: r3v34 */
    /* JADX WARN: Type inference failed for: r3v91, types: [L0.A, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r49v0 */
    /* JADX WARN: Type inference failed for: r49v1 */
    /* JADX WARN: Type inference failed for: r49v2, types: [boolean] */
    /* JADX WARN: Type inference failed for: r49v3 */
    /* JADX WARN: Type inference failed for: r4v16 */
    /* JADX WARN: Type inference failed for: r4v17 */
    /* JADX WARN: Type inference failed for: r4v21 */
    /* JADX WARN: Type inference failed for: r4v31, types: [A1.x] */
    /* JADX WARN: Type inference failed for: r4v38 */
    /* JADX WARN: Type inference failed for: r4v39 */
    /* JADX WARN: Type inference failed for: r4v42 */
    /* JADX WARN: Type inference failed for: r52v0, types: [B0.P, L0.z] */
    /* JADX WARN: Type inference failed for: r5v11 */
    /* JADX WARN: Type inference failed for: r5v12, types: [boolean] */
    /* JADX WARN: Type inference failed for: r5v14 */
    /* JADX WARN: Type inference failed for: r5v15, types: [B0.f] */
    /* JADX WARN: Type inference failed for: r5v26 */
    /* JADX WARN: Type inference failed for: r5v27 */
    /* JADX WARN: Type inference failed for: r5v28 */
    /* JADX WARN: Type inference failed for: r6v12, types: [B0.g, B0.l0, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r7v1 */
    /* JADX WARN: Type inference failed for: r7v14 */
    /* JADX WARN: Type inference failed for: r7v15 */
    /* JADX WARN: Type inference failed for: r7v16 */
    /* JADX WARN: Type inference failed for: r7v2 */
    /* JADX WARN: Type inference failed for: r7v22 */
    /* JADX WARN: Type inference failed for: r7v29, types: [B0.g, B0.l0, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r7v51 */
    /* 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)
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void f() {
        int i;
        ?? r15;
        ?? r22;
        ?? r72;
        boolean z8;
        int i5;
        ?? Y7;
        ?? r10;
        ?? r32;
        j0 j0Var;
        ?? r49;
        ?? r52;
        int i8;
        long j8;
        long j9;
        V v7;
        V v8;
        V v9;
        boolean z9;
        boolean z10;
        Y y8;
        V v10;
        V v11;
        V vA;
        boolean z11;
        boolean zB;
        q0[] q0VarArr;
        int i9;
        q0[] q0VarArr2;
        boolean z12;
        int i10;
        AbstractC0020g abstractC0020g;
        boolean z13;
        int i11;
        Y y9;
        V v12;
        V v13;
        int i12;
        this.f609F.getClass();
        long jUptimeMillis = SystemClock.uptimeMillis();
        this.f651x.d(2);
        if (this.f620R.f815a.p() || !this.f611I.f791b) {
            i = 4;
            r15 = 0;
        } else {
            this.H.m(this.f634g0);
            Y y10 = this.H;
            V v14 = y10.f701l;
            if (v14 == null || (!v14.f669g.f686j && v14.g() && y10.f701l.f669g.f682e != -9223372036854775807L && y10.f703n < 100)) {
                Y y11 = this.H;
                long j10 = this.f634g0;
                j0 j0Var2 = this.f620R;
                V v15 = y11.f701l;
                W wD = v15 == null ? y11.d(j0Var2.f815a, j0Var2.f816b, j0Var2.f817c, j0Var2.f832s) : y11.c(j0Var2.f815a, v15, j10);
                if (wD != null) {
                    Y y12 = this.H;
                    V v16 = y12.f701l;
                    if (v16 == null) {
                        j9 = 1000000000000L;
                        j8 = -9223372036854775807L;
                    } else {
                        j8 = -9223372036854775807L;
                        j9 = (v16.f677p + v16.f669g.f682e) - wD.f679b;
                    }
                    int i13 = 0;
                    while (true) {
                        if (i13 >= y12.f706q.size()) {
                            v7 = null;
                            break;
                        }
                        W w4 = ((V) y12.f706q.get(i13)).f669g;
                        long j11 = w4.f682e;
                        if ((j11 == j8 || j11 == wD.f682e) && w4.f679b == wD.f679b && w4.f678a.equals(wD.f678a)) {
                            v7 = (V) y12.f706q.remove(i13);
                            break;
                        }
                        i13++;
                    }
                    if (v7 == null) {
                        P p3 = (P) y12.f695e.f63r;
                        P0.e eVar = p3.f649v.f836a;
                        p3.f640m0.getClass();
                        v7 = new V(p3.f645r, j9, p3.f647t, eVar, p3.f611I, wD, p3.f648u);
                    } else {
                        v7.f669g = wD;
                        v7.f677p = j9;
                    }
                    V v17 = y12.f701l;
                    if (v17 == null) {
                        y12.i = v7;
                        y12.f699j = v7;
                        y12.f700k = v7;
                    } else if (v7 != v17.f674m) {
                        v17.b();
                        v17.f674m = v7;
                        v17.c();
                    }
                    y12.f704o = null;
                    y12.f701l = v7;
                    y12.f703n++;
                    y12.l();
                    if (!v7.f666d) {
                        long j12 = wD.f679b;
                        v7.f666d = true;
                        v7.f663a.o(this, j12);
                    } else if (v7.f667e) {
                        this.f651x.a(8, v7.f663a).b();
                    }
                    if (this.H.i == v7) {
                        O(wD.f679b);
                    }
                    r(false);
                } else {
                    j8 = -9223372036854775807L;
                }
                if (this.f626Y) {
                    this.f626Y = x(this.H.f701l);
                    q0();
                } else {
                    z();
                }
                if (this.f624V || !this.f617O || this.f642o0 || b() || (v12 = (y9 = this.H).f700k) == null || v12 != y9.f699j || (v13 = v12.f674m) == null || !v13.f667e) {
                    Y y13 = this.H;
                    v8 = y13.f699j;
                    if (v8 != null) {
                        V v18 = v8.f674m;
                        q0[] q0VarArr3 = this.f644q;
                        if (v18 == null || this.f624V) {
                            if (v8.f669g.f686j || this.f624V) {
                                for (q0 q0Var : q0VarArr3) {
                                    if (q0Var.d(v8) != null) {
                                        AbstractC0020g abstractC0020gD = q0Var.d(v8);
                                        abstractC0020gD.getClass();
                                        if (abstractC0020gD.j()) {
                                            long j13 = v8.f669g.f682e;
                                            long j14 = (j13 == -9223372036854775807L || j13 == Long.MIN_VALUE) ? -9223372036854775807L : j13 + v8.f677p;
                                            AbstractC0020g abstractC0020gD2 = q0Var.d(v8);
                                            abstractC0020gD2.getClass();
                                            q0.m(abstractC0020gD2, j14);
                                        }
                                    }
                                }
                            }
                        } else if (v8.f667e) {
                            int i14 = 0;
                            while (true) {
                                if (i14 < q0VarArr3.length) {
                                    q0 q0Var2 = q0VarArr3[i14];
                                    if (!q0Var2.e(v8, q0Var2.f879a) || !q0Var2.e(v8, q0Var2.f881c)) {
                                        break;
                                    } else {
                                        i14++;
                                    }
                                } else if (!b() || y13.f700k != y13.f699j) {
                                    V v19 = v8.f674m;
                                    if (v19.f667e || this.f634g0 >= v19.e()) {
                                        O0.v vVar = v8.f676o;
                                        V v20 = y13.f700k;
                                        V v21 = y13.f699j;
                                        if (v20 == v21) {
                                            AbstractC1709a.k(v21);
                                            y13.f700k = v21.f674m;
                                        }
                                        V v22 = y13.f699j;
                                        AbstractC1709a.k(v22);
                                        y13.f699j = v22.f674m;
                                        y13.l();
                                        V v23 = y13.f699j;
                                        AbstractC1709a.k(v23);
                                        O0.v vVar2 = v23.f676o;
                                        u0.S s8 = this.f620R.f815a;
                                        v0(s8, v23.f669g.f678a, s8, v8.f669g.f678a, -9223372036854775807L, false);
                                        if (!v23.f667e || ((!(z13 = this.f617O) || this.f641n0 == j8) && v23.f663a.t() == j8)) {
                                            int length = q0VarArr3.length;
                                            int i15 = 0;
                                            while (i15 < length) {
                                                q0 q0Var3 = q0VarArr3[i15];
                                                long jE = v23.e();
                                                int i16 = q0Var3.f880b;
                                                boolean zB2 = vVar.b(i16);
                                                boolean zB3 = vVar2.b(i16);
                                                AbstractC0020g abstractC0020g2 = q0Var3.f879a;
                                                int i17 = length;
                                                AbstractC0020g abstractC0020g3 = q0Var3.f881c;
                                                if (abstractC0020g3 != null) {
                                                    int i18 = q0Var3.f882d;
                                                    i10 = i15;
                                                    if (i18 != 3 && (i18 != 0 || !q0.h(abstractC0020g2))) {
                                                        abstractC0020g = abstractC0020g3;
                                                    }
                                                    if (!zB2 && !abstractC0020g.D) {
                                                        boolean z14 = abstractC0020g2.f757r == -2;
                                                        p0 p0Var = vVar.f4910b[i16];
                                                        p0 p0Var2 = vVar2.f4910b[i16];
                                                        if (!zB3 || !Objects.equals(p0Var2, p0Var) || z14 || q0Var3.f()) {
                                                            q0.m(abstractC0020g, jE);
                                                        }
                                                    }
                                                    i15 = i10 + 1;
                                                    length = i17;
                                                } else {
                                                    i10 = i15;
                                                }
                                                abstractC0020g = abstractC0020g2;
                                                if (!zB2) {
                                                }
                                                i15 = i10 + 1;
                                                length = i17;
                                            }
                                        } else {
                                            this.f641n0 = j8;
                                            boolean z15 = z13 && !this.f642o0;
                                            if (z15) {
                                                int i19 = 0;
                                                while (true) {
                                                    if (i19 >= q0VarArr3.length) {
                                                        break;
                                                    }
                                                    if (vVar2.b(i19)) {
                                                        O0.s[] sVarArr = vVar2.f4911c;
                                                        if (!u0.E.a(sVarArr[i19].e().f17358n, sVarArr[i19].e().f17355k) && !q0VarArr3[i19].f()) {
                                                            z15 = false;
                                                            break;
                                                        }
                                                    }
                                                    i19++;
                                                }
                                            }
                                            if (!z15) {
                                                long jE2 = v23.e();
                                                for (q0 q0Var4 : q0VarArr3) {
                                                    AbstractC0020g abstractC0020g4 = q0Var4.f879a;
                                                    if (q0.h(abstractC0020g4) && (i11 = q0Var4.f882d) != 4 && i11 != 2) {
                                                        q0.m(abstractC0020g4, jE2);
                                                    }
                                                    AbstractC0020g abstractC0020g5 = q0Var4.f881c;
                                                    if (abstractC0020g5 != null) {
                                                        if ((abstractC0020g5.f763x != 0) && q0Var4.f882d != 3) {
                                                            q0.m(abstractC0020g5, jE2);
                                                        }
                                                    }
                                                }
                                                if (!v23.g()) {
                                                    y13.n(v23);
                                                    r(false);
                                                    z();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    Y y14 = this.H;
                    v9 = y14.f699j;
                    if (v9 != null || y14.i == v9 || v9.f670h) {
                        z9 = true;
                    } else {
                        O0.v vVar3 = v9.f676o;
                        int i20 = 0;
                        boolean z16 = true;
                        while (true) {
                            q0VarArr2 = this.f644q;
                            if (i20 >= q0VarArr2.length) {
                                break;
                            }
                            int iC = q0VarArr2[i20].c();
                            q0 q0Var5 = q0VarArr2[i20];
                            AbstractC0020g abstractC0020g6 = q0Var5.f879a;
                            C0026m c0026m = this.D;
                            int iK = q0Var5.k(abstractC0020g6, v9, vVar3, c0026m);
                            int iK2 = q0Var5.k(q0Var5.f881c, v9, vVar3, c0026m);
                            if (iK == 1) {
                                iK = iK2;
                            }
                            if ((iK & 2) != 0 && (z12 = this.f631d0) && z12) {
                                this.f631d0 = false;
                                if (this.f620R.f829p) {
                                    this.f651x.e(2);
                                }
                            }
                            this.f632e0 -= iC - q0VarArr2[i20].c();
                            z16 &= (iK & 1) != 0;
                            i20++;
                        }
                        z9 = true;
                        if (z16) {
                            for (int i21 = 0; i21 < q0VarArr2.length; i21++) {
                                if (vVar3.b(i21)) {
                                    if (!(q0VarArr2[i21].d(v9) != null)) {
                                        g(v9, i21, false, v9.e());
                                    }
                                }
                            }
                        }
                        if (z16) {
                            y14.f699j.f670h = true;
                        }
                    }
                    z10 = false;
                    while (l0() && !this.f624V && (v10 = (y8 = this.H).i) != null && (v11 = v10.f674m) != null && this.f634g0 >= v11.e() && v11.f670h) {
                        if (z10) {
                            B();
                        }
                        this.f642o0 = false;
                        vA = y8.a();
                        vA.getClass();
                        if (!this.f620R.f816b.f3625a.equals(vA.f669g.f678a.f3625a)) {
                            L0.C c3 = this.f620R.f816b;
                            if (c3.f3626b == -1) {
                                L0.C c8 = vA.f669g.f678a;
                                z11 = (c8.f3626b != -1 || c3.f3629e == c8.f3629e) ? false : z9;
                            }
                        }
                        W w6 = vA.f669g;
                        L0.C c9 = w6.f678a;
                        long j15 = w6.f679b;
                        this.f620R = w(c9, j15, w6.f680c, j15, !z11, 0);
                        N();
                        u0();
                        zB = b();
                        q0VarArr = this.f644q;
                        if (zB && vA == y8.f700k) {
                            for (q0 q0Var6 : q0VarArr) {
                                int i22 = q0Var6.f882d;
                                if (i22 == 3 || i22 == 4) {
                                    boolean z17 = i22 == 4;
                                    ?? r6 = q0Var6.f879a;
                                    ?? r73 = q0Var6.f881c;
                                    if (z17) {
                                        r73.getClass();
                                        r73.d(17, r6);
                                    } else {
                                        r73.getClass();
                                        r6.d(17, r73);
                                    }
                                    q0Var6.f882d = q0Var6.f882d == 4 ? 0 : 1;
                                } else if (i22 == 2) {
                                    q0Var6.f882d = 0;
                                }
                            }
                        }
                        if (this.f620R.f819e == 3) {
                            n0();
                        }
                        O0.v vVar4 = y8.i.f676o;
                        for (i9 = 0; i9 < q0VarArr.length; i9++) {
                            if (vVar4.b(i9)) {
                                q0 q0Var7 = q0VarArr[i9];
                                AbstractC0020g abstractC0020g7 = q0Var7.f879a;
                                if (q0.h(abstractC0020g7)) {
                                    abstractC0020g7.g();
                                } else {
                                    AbstractC0020g abstractC0020g8 = q0Var7.f881c;
                                    if (abstractC0020g8 != null) {
                                        if (abstractC0020g8.f763x != 0) {
                                            abstractC0020g8.g();
                                        }
                                    }
                                }
                            }
                        }
                        z10 = true;
                        z9 = true;
                    }
                    i = 4;
                    r15 = 0;
                    this.f640m0.getClass();
                } else {
                    y9.f700k = v13;
                    y9.l();
                    AbstractC1709a.k(y9.f700k);
                    V v24 = y9.f700k;
                    if (v24 != null) {
                        O0.v vVar5 = v24.f676o;
                        int i23 = 0;
                        while (true) {
                            q0[] q0VarArr4 = this.f644q;
                            if (i23 >= q0VarArr4.length) {
                                break;
                            }
                            if (vVar5.b(i23)) {
                                q0 q0Var8 = q0VarArr4[i23];
                                if (q0Var8.f881c != null && !q0Var8.f()) {
                                    q0 q0Var9 = q0VarArr4[i23];
                                    AbstractC1709a.j(!q0Var9.f());
                                    if (q0.h(q0Var9.f879a)) {
                                        i12 = 3;
                                    } else {
                                        AbstractC0020g abstractC0020g9 = q0Var9.f881c;
                                        i12 = (abstractC0020g9 == null || abstractC0020g9.f763x == 0) ? 2 : 4;
                                    }
                                    q0Var9.f882d = i12;
                                    g(v24, i23, false, v24.e());
                                }
                            }
                            i23++;
                        }
                        if (b()) {
                            this.f641n0 = v24.f663a.t();
                            if (!v24.g()) {
                                y9.n(v24);
                                r(false);
                                z();
                            }
                        }
                    }
                    Y y132 = this.H;
                    v8 = y132.f699j;
                    if (v8 != null) {
                    }
                    Y y142 = this.H;
                    v9 = y142.f699j;
                    if (v9 != null) {
                        z9 = true;
                        z10 = false;
                        while (l0()) {
                            if (z10) {
                            }
                            this.f642o0 = false;
                            vA = y8.a();
                            vA.getClass();
                            if (!this.f620R.f816b.f3625a.equals(vA.f669g.f678a.f3625a)) {
                            }
                            W w62 = vA.f669g;
                            L0.C c92 = w62.f678a;
                            long j152 = w62.f679b;
                            this.f620R = w(c92, j152, w62.f680c, j152, !z11, 0);
                            N();
                            u0();
                            zB = b();
                            q0VarArr = this.f644q;
                            if (zB) {
                                while (i < r2) {
                                }
                            }
                            if (this.f620R.f819e == 3) {
                            }
                            O0.v vVar42 = y8.i.f676o;
                            while (i9 < q0VarArr.length) {
                            }
                            z10 = true;
                            z9 = true;
                        }
                        i = 4;
                        r15 = 0;
                        this.f640m0.getClass();
                    }
                }
            }
        }
        int i24 = this.f620R.f819e;
        if (i24 == 1 || i24 == i) {
            return;
        }
        V v25 = this.H.i;
        if (v25 == null) {
            S(jUptimeMillis);
            return;
        }
        Trace.beginSection("doSomeWork");
        u0();
        if (v25.f667e) {
            this.f609F.getClass();
            this.f635h0 = x0.v.L(SystemClock.elapsedRealtime());
            v25.f663a.q(this.f620R.f832s - this.f607C);
            ?? r102 = r15;
            r22 = 1;
            r72 = 1;
            while (true) {
                q0[] q0VarArr5 = this.f644q;
                if (r102 >= q0VarArr5.length) {
                    break;
                }
                q0 q0Var10 = q0VarArr5[r102];
                if (q0Var10.c() == 0) {
                    D(r102, r15);
                } else {
                    long j16 = this.f634g0;
                    long j17 = this.f635h0;
                    AbstractC0020g abstractC0020g10 = q0Var10.f879a;
                    if (q0.h(abstractC0020g10)) {
                        abstractC0020g10.v(j16, j17);
                    }
                    AbstractC0020g abstractC0020g11 = q0Var10.f881c;
                    if (abstractC0020g11 != null) {
                        if ((abstractC0020g11.f763x != 0 ? 1 : r15) != 0) {
                            abstractC0020g11.v(j16, j17);
                        }
                    }
                    if (r72 != 0) {
                        AbstractC0020g abstractC0020g12 = q0Var10.f879a;
                        boolean zK = q0.h(abstractC0020g12) ? abstractC0020g12.k() : true;
                        AbstractC0020g abstractC0020g13 = q0Var10.f881c;
                        if (abstractC0020g13 != null) {
                            if ((abstractC0020g13.f763x != 0 ? 1 : r15) != 0) {
                                zK &= abstractC0020g13.k();
                            }
                        }
                        ?? r42 = zK ? 1 : r15;
                        AbstractC0020g abstractC0020gD3 = q0Var10.d(v25);
                        ?? r33 = (abstractC0020gD3 == null || abstractC0020gD3.j() || abstractC0020gD3.l() || abstractC0020gD3.k()) ? 1 : r15;
                        D(r102, r33);
                        r22 = (r22 == 0 || r33 == 0) ? r15 : 1;
                        if (r33 == 0) {
                            C(r102);
                        }
                        r72 = r42;
                    }
                }
                r22 = r22;
                r72 = r72;
                r102++;
            }
        } else {
            v25.f663a.l();
            r22 = 1;
            r72 = 1;
        }
        long j18 = v25.f669g.f682e;
        ?? r103 = (r72 == 0 || !v25.f667e || (j18 != -9223372036854775807L && j18 > this.f620R.f832s)) ? r15 : 1;
        if (r103 != 0 && this.f624V) {
            this.f624V = r15;
            int i25 = this.f620R.f827n;
            this.f621S.f(r15);
            t0(this.f618P.d(this.f620R.f819e, r15), i25, 5, r15);
        }
        if (r103 == 0 || !v25.f669g.f686j) {
            j0 j0Var3 = this.f620R;
            if (j0Var3.f819e != 2) {
                z8 = true;
                z8 = true;
                z8 = true;
                z8 = true;
                if (this.f620R.f819e == 3 && (this.f632e0 != 0 ? r22 == 0 : !y())) {
                    w0(l0(), r15);
                    i0(2);
                    if (this.f625W) {
                        for (V v26 = this.H.i; v26 != null; v26 = v26.f674m) {
                            O0.s[] sVarArr2 = v26.f676o.f4911c;
                            int length2 = sVarArr2.length;
                            for (?? r104 = r15; r104 < length2; r104++) {
                                O0.s sVar = sVarArr2[r104];
                                if (sVar != null) {
                                    sVar.r();
                                }
                            }
                        }
                        C0023j c0023j = this.f612J;
                        long j19 = c0023j.f808h;
                        if (j19 != -9223372036854775807L) {
                            long j20 = j19 + c0023j.f802b;
                            c0023j.f808h = j20;
                            long j21 = c0023j.f807g;
                            if (j21 != -9223372036854775807L && j20 > j21) {
                                c0023j.f808h = j21;
                            }
                            c0023j.f811l = -9223372036854775807L;
                        }
                    }
                    p0();
                }
            } else {
                if (this.f632e0 == 0) {
                    Y7 = y();
                } else if (r22 != 0) {
                    if (j0Var3.f821g) {
                        Y y15 = this.H;
                        long j22 = m0(j0Var3.f815a, y15.i.f669g.f678a) ? this.f612J.f808h : -9223372036854775807L;
                        V v27 = y15.f701l;
                        ?? r105 = (v27.g() && v27.f669g.f686j) ? 1 : r15;
                        ?? r43 = (!v27.f669g.f678a.b() || v27.f667e) ? r15 : 1;
                        if (r105 == 0 && r43 == 0) {
                            long jL = l(v27.d());
                            u0.S s9 = this.f620R.f815a;
                            float f3 = this.D.b().f17159a;
                            boolean z18 = this.f620R.f825l;
                            boolean z19 = this.f625W;
                            C0025l c0025l = this.f649v;
                            c0025l.getClass();
                            long jZ = x0.v.z(jL, f3);
                            long jMin = z19 ? c0025l.f840e : c0025l.f839d;
                            if (j22 != -9223372036854775807L) {
                                jMin = Math.min(j22 / 2, jMin);
                            }
                            if (jMin > 0 && jZ < jMin) {
                                P0.e eVar2 = c0025l.f836a;
                                synchronized (eVar2) {
                                    i5 = eVar2.f5266d * eVar2.f5264b;
                                }
                                if (i5 < c0025l.b()) {
                                    Y7 = r15;
                                }
                            }
                        }
                    }
                    Y7 = 1;
                }
                if (Y7 != 0) {
                    i0(3);
                    this.f638k0 = null;
                    if (l0()) {
                        w0(r15, r15);
                        C0026m c0026m2 = this.D;
                        z8 = true;
                        c0026m2.f845r = true;
                        ((s0) c0026m2.f846s).f();
                        n0();
                    }
                }
            }
            if (this.f620R.f819e != 2) {
                ?? r106 = r15;
                while (true) {
                    q0[] q0VarArr6 = this.f644q;
                    if (r106 >= q0VarArr6.length) {
                        break;
                    }
                    if ((q0VarArr6[r106].d(v25) != null ? z8 ? 1 : 0 : r15) != 0) {
                        C(r106);
                    }
                    r106++;
                }
                j0 j0Var4 = this.f620R;
                r10 = (j0Var4.f821g || j0Var4.f831r >= 500000 || !x(this.H.f701l) || !l0()) ? r15 : z8 ? 1 : 0;
            }
            if (r10 != 0) {
                this.f639l0 = -9223372036854775807L;
            } else if (this.f639l0 == -9223372036854775807L) {
                this.f609F.getClass();
                this.f639l0 = SystemClock.elapsedRealtime();
            } else {
                this.f609F.getClass();
                if (SystemClock.elapsedRealtime() - this.f639l0 >= 4000) {
                    throw new IllegalStateException("Playback stuck buffering and not loading");
                }
            }
            ?? r107 = (l0() || this.f620R.f819e != 3) ? r15 : z8 ? 1 : 0;
            if (!this.f631d0) {
                r32 = z8;
                if (!this.f630c0 || r107 == 0) {
                    r32 = r15;
                }
            }
            j0Var = this.f620R;
            if (j0Var.f829p == r32) {
                ?? r492 = r32;
                this.f620R = new j0(j0Var.f815a, j0Var.f816b, j0Var.f817c, j0Var.f818d, j0Var.f819e, j0Var.f820f, j0Var.f821g, j0Var.f822h, j0Var.i, j0Var.f823j, j0Var.f824k, j0Var.f825l, j0Var.f826m, j0Var.f827n, j0Var.f828o, j0Var.f830q, j0Var.f831r, j0Var.f832s, j0Var.f833t, r492);
                r52 = 0;
                r49 = r492;
            } else {
                r49 = r32;
                r52 = r15;
            }
            this.f630c0 = r52;
            if (r49 == 0 && (i8 = this.f620R.f819e) != 4 && (r107 != 0 || i8 == 2 || (i8 == 3 && this.f632e0 != 0))) {
                S(jUptimeMillis);
            }
            Trace.endSection();
        }
        i0(i);
        p0();
        z8 = true;
        if (this.f620R.f819e != 2) {
        }
        if (r10 != 0) {
        }
        if (l0()) {
        }
        if (!this.f631d0) {
        }
        j0Var = this.f620R;
        if (j0Var.f829p == r32) {
        }
        this.f630c0 = r52;
        if (r49 == 0) {
            S(jUptimeMillis);
        }
        Trace.endSection();
    }

    public final void f0(r0 r0Var) {
        this.f619Q = r0Var;
    }

    public final void g(V v7, int i, boolean z8, long j8) {
        q0 q0Var = this.f644q[i];
        if (q0Var.g()) {
            return;
        }
        boolean z9 = v7 == this.H.i;
        O0.v vVar = v7.f676o;
        p0 p0Var = vVar.f4910b[i];
        O0.s sVar = vVar.f4911c[i];
        boolean z10 = l0() && this.f620R.f819e == 3;
        boolean z11 = !z8 && z10;
        this.f632e0++;
        L0.c0 c0Var = v7.f665c[i];
        long j9 = v7.f677p;
        W w4 = v7.f669g;
        int length = sVar != null ? sVar.length() : 0;
        C1579o[] c1579oArr = new C1579o[length];
        for (int i5 = 0; i5 < length; i5++) {
            sVar.getClass();
            c1579oArr[i5] = sVar.h(i5);
        }
        int i8 = q0Var.f882d;
        L0.C c3 = w4.f678a;
        C0026m c0026m = this.D;
        if (i8 == 0 || i8 == 2 || i8 == 4) {
            q0Var.f883e = true;
            AbstractC0020g abstractC0020g = q0Var.f879a;
            AbstractC1709a.j(abstractC0020g.f763x == 0);
            abstractC0020g.f759t = p0Var;
            abstractC0020g.f763x = 1;
            abstractC0020g.n(z11, z9);
            abstractC0020g.w(c1579oArr, c0Var, j8, j9, c3);
            abstractC0020g.D = false;
            abstractC0020g.f751B = j8;
            abstractC0020g.f752C = j8;
            abstractC0020g.o(j8, z11);
            c0026m.d(abstractC0020g);
        } else {
            q0Var.f884f = true;
            AbstractC0020g abstractC0020g2 = q0Var.f881c;
            abstractC0020g2.getClass();
            AbstractC1709a.j(abstractC0020g2.f763x == 0);
            abstractC0020g2.f759t = p0Var;
            abstractC0020g2.f763x = 1;
            abstractC0020g2.n(z11, z9);
            abstractC0020g2.w(c1579oArr, c0Var, j8, j9, c3);
            abstractC0020g2.D = false;
            abstractC0020g2.f751B = j8;
            abstractC0020g2.f752C = j8;
            abstractC0020g2.o(j8, z11);
            c0026m.d(abstractC0020g2);
        }
        L l8 = new L(this);
        AbstractC0020g abstractC0020gD = q0Var.d(v7);
        abstractC0020gD.getClass();
        abstractC0020gD.d(11, l8);
        if (z10 && z9) {
            q0Var.n();
        }
    }

    public final void g0(boolean z8) {
        this.f628a0 = z8;
        u0.S s8 = this.f620R.f815a;
        Y y8 = this.H;
        y8.f698h = z8;
        int iR = y8.r(s8);
        if ((iR & 1) != 0) {
            T(true);
        } else if ((iR & 2) != 0) {
            d();
        }
        r(false);
    }

    public final void h(boolean[] zArr, long j8) {
        q0[] q0VarArr;
        long j9;
        V v7 = this.H.f699j;
        O0.v vVar = v7.f676o;
        int i = 0;
        while (true) {
            q0VarArr = this.f644q;
            if (i >= q0VarArr.length) {
                break;
            }
            if (!vVar.b(i)) {
                q0VarArr[i].l();
            }
            i++;
        }
        int i5 = 0;
        while (i5 < q0VarArr.length) {
            if (vVar.b(i5) && q0VarArr[i5].d(v7) == null) {
                j9 = j8;
                g(v7, i5, zArr[i5], j9);
            } else {
                j9 = j8;
            }
            i5++;
            j8 = j9;
        }
    }

    public final void h0(L0.f0 f0Var) throws Throwable {
        this.f621S.f(1);
        i0 i0Var = this.f611I;
        int size = ((ArrayList) i0Var.f790a).size();
        if (f0Var.f3813b.length != size) {
            f0Var = new L0.f0(new Random(f0Var.f3812a.nextLong())).a(size);
        }
        i0Var.f799k = f0Var;
        t(i0Var.c(), false);
    }

    /* JADX WARN: Removed duplicated region for block: B:121:0x022b  */
    @Override // android.os.Handler.Callback
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean handleMessage(Message message) throws Throwable {
        int i;
        int i5;
        V v7;
        V v8;
        V v9;
        try {
            switch (message.what) {
                case 1:
                    boolean z8 = message.arg1 != 0;
                    int i8 = message.arg2;
                    this.f621S.f(1);
                    t0(this.f618P.d(this.f620R.f819e, z8), i8 >> 4, i8 & 15, z8);
                    break;
                case 2:
                    f();
                    break;
                case 3:
                    U((O) message.obj);
                    break;
                case 4:
                    c0((u0.H) message.obj);
                    break;
                case 5:
                    f0((r0) message.obj);
                    break;
                case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                    o0(false, true);
                    break;
                case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                    I();
                    return true;
                case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                    u((L0.A) message.obj);
                    break;
                case 9:
                    p((L0.A) message.obj);
                    break;
                case 10:
                    L();
                    break;
                case 11:
                    e0(message.arg1);
                    break;
                case 12:
                    g0(message.arg1 != 0);
                    break;
                case 13:
                    Z(message.arg1 != 0, (AtomicBoolean) message.obj);
                    break;
                case 14:
                    W((m0) message.obj);
                    break;
                case 15:
                    X((m0) message.obj);
                    break;
                case 16:
                    u0.H h8 = (u0.H) message.obj;
                    v(h8, h8.f17159a, true, false);
                    break;
                case 17:
                    a0((M) message.obj);
                    break;
                case 18:
                    a((M) message.obj, message.arg1);
                    break;
                case 19:
                    I1.a.v(message.obj);
                    F();
                    throw null;
                case 20:
                    K(message.arg1, message.arg2, (L0.f0) message.obj);
                    break;
                case 21:
                    h0((L0.f0) message.obj);
                    break;
                case 22:
                    E();
                    break;
                case 23:
                    b0(message.arg1 != 0);
                    break;
                case 24:
                default:
                    return false;
                case 25:
                    c();
                    break;
                case 26:
                    L();
                    T(true);
                    break;
                case 27:
                    s0(message.arg1, message.arg2, (List) message.obj);
                    break;
                case 28:
                    d0((C0033u) message.obj);
                    break;
                case 29:
                    G();
                    break;
                case 30:
                    Pair pair = (Pair) message.obj;
                    j0(pair.first, (AtomicBoolean) pair.second);
                    break;
                case 31:
                    Y((C1567c) message.obj, message.arg1 != 0);
                    break;
                case 32:
                    k0(((Float) message.obj).floatValue());
                    break;
                case 33:
                    m(message.arg1);
                    break;
                case 34:
                    o();
                    break;
            }
        } catch (C0030q e8) {
            e = e8;
            int i9 = e.f872s;
            q0[] q0VarArr = this.f644q;
            Y y8 = this.H;
            if (i9 == 1 && (v8 = y8.f699j) != null) {
                int length = q0VarArr.length;
                int i10 = e.f874u;
                e = e.a((!q0VarArr[i10 % length].i(i10) || (v9 = v8.f674m) == null) ? v8.f669g.f678a : v9.f669g.f678a);
            }
            int i11 = e.f872s;
            x0.s sVar = this.f651x;
            if (i11 == 1) {
                int length2 = q0VarArr.length;
                int i12 = e.f874u;
                if (q0VarArr[i12 % length2].i(i12)) {
                    this.f642o0 = true;
                    d();
                    V vG = y8.g();
                    V v10 = y8.i;
                    if (v10 != vG) {
                        while (v10 != null) {
                            V v11 = v10.f674m;
                            if (v11 == vG) {
                                break;
                            }
                            v10 = v11;
                        }
                    }
                    y8.n(v10);
                    if (this.f620R.f819e != 4) {
                        z();
                        sVar.e(2);
                    }
                } else {
                    C0030q c0030q = this.f638k0;
                    if (c0030q != null) {
                        c0030q.addSuppressed(e);
                        e = this.f638k0;
                    }
                    if (e.f872s == 1 && y8.i != y8.f699j) {
                        while (true) {
                            v7 = y8.i;
                            if (v7 == y8.f699j) {
                                break;
                            }
                            y8.a();
                        }
                        AbstractC1709a.h(v7);
                        B();
                        W w4 = v7.f669g;
                        L0.C c3 = w4.f678a;
                        long j8 = w4.f679b;
                        this.f620R = w(c3, j8, w4.f680c, j8, true, 0);
                    }
                    if (e.f878y && (this.f638k0 == null || (i5 = e.f17156q) == 5004 || i5 == 5003)) {
                        AbstractC1709a.C("ExoPlayerImplInternal", "Recoverable renderer error", e);
                        if (this.f638k0 == null) {
                            this.f638k0 = e;
                        }
                        x0.r rVarA = sVar.a(25, e);
                        sVar.getClass();
                        Message message2 = rVarA.f18546a;
                        message2.getClass();
                        sVar.f18548a.sendMessageAtFrontOfQueue(message2);
                        rVarA.a();
                    } else {
                        AbstractC1709a.p("ExoPlayerImplInternal", "Playback error", e);
                        o0(true, false);
                        this.f620R = this.f620R.f(e);
                    }
                }
            }
        } catch (E0.c e9) {
            q(e9.f1969q, e9);
        } catch (C0147b e10) {
            q(1002, e10);
        } catch (u0.F e11) {
            boolean z9 = e11.f17154q;
            int i13 = e11.f17155r;
            if (i13 == 1) {
                i = z9 ? 3001 : 3003;
            } else {
                if (i13 == 4) {
                    i = z9 ? 3002 : 3004;
                }
                q(i, e11);
            }
            i = i;
            q(i, e11);
        } catch (IOException e12) {
            q(2000, e12);
        } catch (RuntimeException e13) {
            C0030q c0030q2 = new C0030q(2, e13, ((e13 instanceof IllegalStateException) || (e13 instanceof IllegalArgumentException)) ? 1004 : 1000);
            AbstractC1709a.p("ExoPlayerImplInternal", "Playback error", c0030q2);
            o0(true, false);
            this.f620R = this.f620R.f(c0030q2);
        } catch (z0.i e14) {
            q(e14.f19131q, e14);
        }
        B();
        return true;
    }

    public final long i(u0.S s8, Object obj, long j8) {
        u0.P p3 = this.f606B;
        int i = s8.g(obj, p3).f17177c;
        u0.Q q8 = this.f605A;
        s8.n(i, q8);
        if (q8.f17189f == -9223372036854775807L || !q8.a() || !q8.i) {
            return -9223372036854775807L;
        }
        long j9 = q8.f17190g;
        return x0.v.L((j9 == -9223372036854775807L ? System.currentTimeMillis() : j9 + SystemClock.elapsedRealtime()) - q8.f17189f) - (j8 + p3.f17179e);
    }

    public final void i0(int i) {
        j0 j0Var = this.f620R;
        if (j0Var.f819e != i) {
            if (i != 2) {
                this.f639l0 = -9223372036854775807L;
            }
            this.f620R = j0Var.h(i);
        }
    }

    public final long j(V v7) {
        if (v7 == null) {
            return 0L;
        }
        long jMax = v7.f677p;
        if (!v7.f667e) {
            return jMax;
        }
        int i = 0;
        while (true) {
            q0[] q0VarArr = this.f644q;
            if (i >= q0VarArr.length) {
                return jMax;
            }
            if (q0VarArr[i].d(v7) != null) {
                AbstractC0020g abstractC0020gD = q0VarArr[i].d(v7);
                Objects.requireNonNull(abstractC0020gD);
                long j8 = abstractC0020gD.f752C;
                if (j8 == Long.MIN_VALUE) {
                    return Long.MIN_VALUE;
                }
                jMax = Math.max(j8, jMax);
            }
            i++;
        }
    }

    public final void j0(Object obj, AtomicBoolean atomicBoolean) {
        for (q0 q0Var : this.f644q) {
            AbstractC0020g abstractC0020g = q0Var.f879a;
            if (abstractC0020g.f757r == 2) {
                int i = q0Var.f882d;
                if (i == 4 || i == 1) {
                    AbstractC0020g abstractC0020g2 = q0Var.f881c;
                    abstractC0020g2.getClass();
                    abstractC0020g2.d(1, obj);
                } else {
                    abstractC0020g.d(1, obj);
                }
            }
        }
        int i5 = this.f620R.f819e;
        if (i5 == 3 || i5 == 2) {
            this.f651x.e(2);
        }
        if (atomicBoolean != null) {
            synchronized (this) {
                atomicBoolean.set(true);
                notifyAll();
            }
        }
    }

    public final Pair k(u0.S s8) {
        long j8 = 0;
        if (s8.p()) {
            return Pair.create(j0.f814u, 0L);
        }
        Pair pairI = s8.i(this.f605A, this.f606B, s8.a(this.f628a0), -9223372036854775807L);
        L0.C cP = this.H.p(s8, pairI.first, 0L);
        long jLongValue = ((Long) pairI.second).longValue();
        if (cP.b()) {
            Object obj = cP.f3625a;
            u0.P p3 = this.f606B;
            s8.g(obj, p3);
            if (cP.f3627c == p3.e(cP.f3626b)) {
                p3.f17181g.getClass();
            }
        } else {
            j8 = jLongValue;
        }
        return Pair.create(cP, Long.valueOf(j8));
    }

    public final void k0(float f3) {
        this.f643p0 = f3;
        float f7 = f3 * this.f618P.f746g;
        for (q0 q0Var : this.f644q) {
            AbstractC0020g abstractC0020g = q0Var.f879a;
            if (abstractC0020g.f757r == 1) {
                abstractC0020g.d(2, Float.valueOf(f7));
                AbstractC0020g abstractC0020g2 = q0Var.f881c;
                if (abstractC0020g2 != null) {
                    abstractC0020g2.d(2, Float.valueOf(f7));
                }
            }
        }
    }

    public final long l(long j8) {
        V v7 = this.H.f701l;
        if (v7 == null) {
            return 0L;
        }
        return Math.max(0L, j8 - (this.f634g0 - v7.f677p));
    }

    public final boolean l0() {
        j0 j0Var = this.f620R;
        return j0Var.f825l && j0Var.f827n == 0;
    }

    public final void m(int i) {
        j0 j0Var = this.f620R;
        t0(i, j0Var.f827n, j0Var.f826m, j0Var.f825l);
    }

    public final boolean m0(u0.S s8, L0.C c3) {
        if (c3.b() || s8.p()) {
            return false;
        }
        int i = s8.g(c3.f3625a, this.f606B).f17177c;
        u0.Q q8 = this.f605A;
        s8.n(i, q8);
        return q8.a() && q8.i && q8.f17189f != -9223372036854775807L;
    }

    @Override // L0.InterfaceC0170z
    public final void n(L0.A a3) {
        this.f651x.a(8, a3).b();
    }

    public final void n0() {
        V v7 = this.H.i;
        if (v7 == null) {
            return;
        }
        O0.v vVar = v7.f676o;
        int i = 0;
        while (true) {
            q0[] q0VarArr = this.f644q;
            if (i >= q0VarArr.length) {
                return;
            }
            if (vVar.b(i)) {
                q0VarArr[i].n();
            }
            i++;
        }
    }

    public final void o() {
        k0(this.f643p0);
    }

    public final void o0(boolean z8, boolean z9) {
        M(z8 || !this.f629b0, false, true, false);
        this.f621S.f(z9 ? 1 : 0);
        C0025l c0025l = this.f649v;
        if (c0025l.f843h.remove(this.f614L) != null) {
            c0025l.d();
        }
        this.f618P.d(1, this.f620R.f825l);
        i0(1);
    }

    public final void p(L0.A a3) {
        Y y8 = this.H;
        V v7 = y8.f701l;
        if (v7 != null && v7.f663a == a3) {
            y8.m(this.f634g0);
            z();
            return;
        }
        V v8 = y8.f702m;
        if (v8 == null || v8.f663a != a3) {
            return;
        }
        A();
    }

    public final void p0() {
        C0026m c0026m = this.D;
        c0026m.f845r = false;
        s0 s0Var = (s0) c0026m.f846s;
        if (s0Var.f891r) {
            s0Var.d(s0Var.e());
            s0Var.f891r = false;
        }
        for (q0 q0Var : this.f644q) {
            AbstractC0020g abstractC0020g = q0Var.f879a;
            if (q0.h(abstractC0020g)) {
                q0.b(abstractC0020g);
            }
            AbstractC0020g abstractC0020g2 = q0Var.f881c;
            if (abstractC0020g2 != null && abstractC0020g2.f763x != 0) {
                q0.b(abstractC0020g2);
            }
        }
    }

    public final void q(int i, IOException iOException) {
        C0030q c0030q = new C0030q(0, iOException, i);
        V v7 = this.H.i;
        if (v7 != null) {
            c0030q = c0030q.a(v7.f669g.f678a);
        }
        AbstractC1709a.p("ExoPlayerImplInternal", "Playback error", c0030q);
        o0(false, false);
        this.f620R = this.f620R.f(c0030q);
    }

    /* JADX WARN: Type inference failed for: r0v6, types: [L0.e0, java.lang.Object] */
    public final void q0() {
        V v7 = this.H.f701l;
        boolean z8 = this.f626Y || (v7 != null && v7.f663a.a());
        j0 j0Var = this.f620R;
        if (z8 != j0Var.f821g) {
            this.f620R = j0Var.b(z8);
        }
    }

    public final void r(boolean z8) {
        V v7 = this.H.f701l;
        L0.C c3 = v7 == null ? this.f620R.f816b : v7.f669g.f678a;
        boolean zEquals = this.f620R.f824k.equals(c3);
        if (!zEquals) {
            this.f620R = this.f620R.c(c3);
        }
        j0 j0Var = this.f620R;
        j0Var.f830q = v7 == null ? j0Var.f832s : v7.d();
        j0 j0Var2 = this.f620R;
        j0Var2.f831r = l(j0Var2.f830q);
        if ((!zEquals || z8) && v7 != null && v7.f667e) {
            r0(v7.f676o);
        }
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    public final void r0(O0.v vVar) {
        V v7 = this.H.f701l;
        v7.getClass();
        l(v7.d());
        if (m0(this.f620R.f815a, v7.f669g.f678a)) {
            long j8 = this.f612J.f808h;
        }
        u0.S s8 = this.f620R.f815a;
        float f3 = this.D.b().f17159a;
        boolean z8 = this.f620R.f825l;
        O0.s[] sVarArr = vVar.f4911c;
        C0025l c0025l = this.f649v;
        C0024k c0024k = (C0024k) c0025l.f843h.get(this.f614L);
        c0024k.getClass();
        int iMax = c0025l.f841f;
        if (iMax == -1) {
            int length = sVarArr.length;
            int i = 0;
            int i5 = 0;
            while (true) {
                int i8 = 13107200;
                if (i < length) {
                    O0.s sVar = sVarArr[i];
                    if (sVar != null) {
                        switch (sVar.b().f17202c) {
                            case -2:
                                i8 = 0;
                                i5 += i8;
                                break;
                            case -1:
                            case 1:
                                i5 += i8;
                                break;
                            case u0.f15495q /* 0 */:
                                i8 = 144310272;
                                i5 += i8;
                                break;
                            case 2:
                                i8 = 131072000;
                                i5 += i8;
                                break;
                            case 3:
                            case 4:
                            case 5:
                            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                                i8 = 131072;
                                i5 += i8;
                                break;
                            default:
                                throw new IllegalArgumentException();
                        }
                    }
                    i++;
                } else {
                    iMax = Math.max(13107200, i5);
                }
            }
        }
        c0024k.f835b = iMax;
        c0025l.d();
    }

    @Override // L0.d0
    public final void s(L0.e0 e0Var) {
        this.f651x.a(9, (L0.A) e0Var).b();
    }

    public final void s0(int i, int i5, List list) throws Throwable {
        this.f621S.f(1);
        i0 i0Var = this.f611I;
        i0Var.getClass();
        ArrayList arrayList = (ArrayList) i0Var.f790a;
        AbstractC1709a.d(i >= 0 && i <= i5 && i5 <= arrayList.size());
        AbstractC1709a.d(list.size() == i5 - i);
        for (int i8 = i; i8 < i5; i8++) {
            ((h0) arrayList.get(i8)).f780a.r((C1588y) list.get(i8 - i));
        }
        t(i0Var.c(), false);
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:205:0x0371  */
    /* JADX WARN: Removed duplicated region for block: B:206:0x0373  */
    /* JADX WARN: Removed duplicated region for block: B:211:0x0388  */
    /* JADX WARN: Removed duplicated region for block: B:219:0x03a7  */
    /* JADX WARN: Removed duplicated region for block: B:222:0x03b3  */
    /* JADX WARN: Removed duplicated region for block: B:224:0x03b9  */
    /* JADX WARN: Removed duplicated region for block: B:228:0x03da  */
    /* JADX WARN: Removed duplicated region for block: B:235:0x03fe  */
    /* JADX WARN: Removed duplicated region for block: B:236:0x0400  */
    /* JADX WARN: Removed duplicated region for block: B:239:0x040b  */
    /* JADX WARN: Removed duplicated region for block: B:241:0x0413  */
    /* JADX WARN: Removed duplicated region for block: B:249:0x0432  */
    /* JADX WARN: Removed duplicated region for block: B:252:0x043e  */
    /* JADX WARN: Removed duplicated region for block: B:254:0x0444  */
    /* JADX WARN: Removed duplicated region for block: B:258:0x0465  */
    /* JADX WARN: Type inference failed for: r11v1 */
    /* JADX WARN: Type inference failed for: r11v2, types: [u0.S] */
    /* JADX WARN: Type inference failed for: r11v3 */
    /* JADX WARN: Type inference failed for: r11v4 */
    /* JADX WARN: Type inference failed for: r11v5 */
    /* JADX WARN: Type inference failed for: r12v10 */
    /* JADX WARN: Type inference failed for: r12v11 */
    /* JADX WARN: Type inference failed for: r12v12 */
    /* JADX WARN: Type inference failed for: r12v19 */
    /* JADX WARN: Type inference failed for: r12v20 */
    /* JADX WARN: Type inference failed for: r12v22 */
    /* JADX WARN: Type inference failed for: r12v23 */
    /* JADX WARN: Type inference failed for: r12v4, types: [long] */
    /* JADX WARN: Type inference failed for: r12v5 */
    /* JADX WARN: Type inference failed for: r12v6, types: [int] */
    /* JADX WARN: Type inference failed for: r12v7 */
    /* JADX WARN: Type inference failed for: r12v8 */
    /* JADX WARN: Type inference failed for: r12v9 */
    /* JADX WARN: Type inference failed for: r13v22 */
    /* JADX WARN: Type inference failed for: r13v4 */
    /* JADX WARN: Type inference failed for: r13v5, types: [B0.O] */
    /* JADX WARN: Type inference failed for: r13v6 */
    /* JADX WARN: Type inference failed for: r13v7 */
    /* JADX WARN: Type inference failed for: r20v1 */
    /* JADX WARN: Type inference failed for: r20v10 */
    /* JADX WARN: Type inference failed for: r20v11, types: [long] */
    /* JADX WARN: Type inference failed for: r20v12 */
    /* JADX WARN: Type inference failed for: r20v13 */
    /* JADX WARN: Type inference failed for: r20v14 */
    /* JADX WARN: Type inference failed for: r20v15 */
    /* JADX WARN: Type inference failed for: r20v16 */
    /* JADX WARN: Type inference failed for: r20v17 */
    /* JADX WARN: Type inference failed for: r20v18 */
    /* JADX WARN: Type inference failed for: r20v19 */
    /* JADX WARN: Type inference failed for: r20v2, types: [long] */
    /* JADX WARN: Type inference failed for: r20v20 */
    /* JADX WARN: Type inference failed for: r20v21 */
    /* JADX WARN: Type inference failed for: r20v22 */
    /* JADX WARN: Type inference failed for: r20v4 */
    /* JADX WARN: Type inference failed for: r20v6 */
    /* JADX WARN: Type inference failed for: r20v7 */
    /* JADX WARN: Type inference failed for: r20v8 */
    /* JADX WARN: Type inference failed for: r20v9 */
    /* JADX WARN: Type inference failed for: r2v25, types: [u0.S] */
    /* JADX WARN: Type inference failed for: r2v30, types: [B0.j0] */
    /* JADX WARN: Type inference failed for: r2v34, types: [x0.s] */
    /* JADX WARN: Type inference failed for: r2v52, types: [B0.Y] */
    /* JADX WARN: Type inference failed for: r31v0 */
    /* JADX WARN: Type inference failed for: r31v4, types: [boolean] */
    /* JADX WARN: Type inference failed for: r31v5 */
    /* JADX WARN: Type inference failed for: r31v6 */
    /* JADX WARN: Type inference failed for: r35v0, types: [B0.P] */
    /* JADX WARN: Type inference failed for: r5v21, types: [long] */
    /* JADX WARN: Type inference failed for: r5v34, types: [long] */
    /* JADX WARN: Type inference failed for: r8v16, types: [int] */
    /* JADX WARN: Type inference failed for: r8v17 */
    /* JADX WARN: Type inference failed for: r8v18 */
    /* JADX WARN: Type inference failed for: r8v21 */
    /* JADX WARN: Type inference failed for: r8v22 */
    /* JADX WARN: Type inference failed for: r8v26 */
    /* JADX WARN: Type inference failed for: r8v27 */
    /* JADX WARN: Type inference failed for: r8v31, types: [u0.S] */
    /* JADX WARN: Type inference failed for: r8v32 */
    /* JADX WARN: Type inference failed for: r8v33 */
    /* JADX WARN: Type inference failed for: r8v34 */
    /* 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)
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void t(u0.S s8, boolean z8) throws Throwable {
        long j8;
        u0.Q q8;
        Object obj;
        long jLongValue;
        int iA;
        int i;
        Object obj2;
        boolean z9;
        ?? r31;
        boolean z10;
        boolean z11;
        boolean z12;
        L0.C c3;
        int i5;
        u0.P p3;
        u0.S s9;
        long j9;
        long j10;
        N n8;
        int i8;
        long jLongValue2;
        int iA2;
        boolean z13;
        boolean z14;
        long j11;
        boolean z15;
        int i9;
        ?? r11;
        L0.C c8;
        ?? r20;
        ?? r12;
        ?? r13;
        boolean z16;
        L0.C c9;
        boolean z17;
        int i10;
        ?? r202;
        ?? r8;
        ?? r203;
        L0.C c10;
        ?? r122;
        ?? r82;
        u0.S s10;
        int i11;
        V v7;
        ?? r204;
        O o8;
        int i12;
        L0.C c11;
        ?? r205;
        j0 j0Var = this.f620R;
        O o9 = this.f633f0;
        Y y8 = this.H;
        int i13 = this.f627Z;
        boolean z18 = this.f628a0;
        u0.Q q9 = this.f605A;
        u0.P p4 = this.f606B;
        if (s8.p()) {
            i9 = 0;
            s9 = s8;
            n8 = new N(j0.f814u, 0L, -9223372036854775807L, false, true, false);
            j8 = -9223372036854775807L;
        } else {
            L0.C c12 = j0Var.f816b;
            j8 = -9223372036854775807L;
            Object obj3 = c12.f3625a;
            u0.S s11 = j0Var.f815a;
            boolean z19 = s11.p() || s11.g(c12.f3625a, p4).f17180f;
            long j12 = (j0Var.f816b.b() || z19) ? j0Var.f817c : j0Var.f832s;
            if (o9 != null) {
                c3 = c12;
                Pair pairQ = Q(s8, o9, true, i13, z18, q9, p4);
                if (pairQ == null) {
                    iA2 = s8.a(z18);
                    j11 = j12;
                    z14 = false;
                    i9 = 1;
                    z15 = false;
                } else {
                    if (o9.f604c == -9223372036854775807L) {
                        iA2 = s8.g(pairQ.first, p4).f17177c;
                        jLongValue2 = j12;
                        z13 = false;
                    } else {
                        obj3 = pairQ.first;
                        jLongValue2 = ((Long) pairQ.second).longValue();
                        iA2 = -1;
                        z13 = true;
                    }
                    boolean z20 = z13;
                    z14 = j0Var.f819e == 4;
                    j11 = jLongValue2;
                    z15 = z20;
                    i9 = 0;
                }
                iA = iA2;
                z9 = z14;
                obj = obj3;
                r31 = i9;
                z10 = z15;
                jLongValue = j11;
                q8 = q9;
                i = -1;
            } else {
                L0.C c13 = c12;
                if (j0Var.f815a.p()) {
                    iA = s8.a(z18);
                    q8 = q9;
                    jLongValue = j12;
                    obj = obj3;
                } else if (s8.b(obj3) == -1) {
                    obj = obj3;
                    int iR = R(q9, p4, i13, z18, obj, j0Var.f815a, s8);
                    q8 = q9;
                    p4 = p4;
                    if (iR == -1) {
                        iR = s8.a(z18);
                        z11 = true;
                    } else {
                        z11 = false;
                    }
                    iA = iR;
                    z12 = z11;
                    jLongValue = j12;
                    i = -1;
                    z9 = false;
                    z10 = false;
                    c3 = c13;
                    r31 = z12;
                } else {
                    q8 = q9;
                    obj = obj3;
                    if (j12 == -9223372036854775807L) {
                        iA = s8.g(obj, p4).f17177c;
                        jLongValue = j12;
                    } else if (z19) {
                        j0Var.f815a.g(c13.f3625a, p4);
                        if (j0Var.f815a.m(p4.f17177c, q8, 0L).f17196n == j0Var.f815a.b(c13.f3625a)) {
                            Pair pairI = s8.i(q8, p4, s8.g(obj, p4).f17177c, p4.f17179e + j12);
                            obj2 = pairI.first;
                            jLongValue = ((Long) pairI.second).longValue();
                        } else {
                            obj2 = obj;
                            jLongValue = j12;
                        }
                        obj = obj2;
                        iA = -1;
                        i = -1;
                        z9 = false;
                        r31 = 0;
                        z10 = true;
                        c3 = c13;
                    } else {
                        jLongValue = j12;
                        iA = -1;
                        i = -1;
                        z9 = false;
                        z12 = false;
                        z10 = false;
                        c3 = c13;
                        r31 = z12;
                    }
                }
                i = -1;
                z9 = false;
                z12 = false;
                z10 = false;
                c3 = c13;
                r31 = z12;
            }
            if (iA != i) {
                int i14 = iA;
                u0.P p8 = p4;
                i5 = i;
                s9 = s8;
                Pair pairI2 = s9.i(q8, p8, i14, -9223372036854775807L);
                p3 = p8;
                obj = pairI2.first;
                jLongValue = ((Long) pairI2.second).longValue();
                j9 = -9223372036854775807L;
            } else {
                u0.P p9 = p4;
                i5 = i;
                p3 = p9;
                s9 = s8;
                j9 = jLongValue;
            }
            L0.C cP = y8.p(s9, obj, jLongValue);
            int i15 = cP.f3629e;
            boolean z21 = c3.f3625a.equals(obj) && !c3.b() && !cP.b() && (i15 == i5 || ((i8 = c3.f3629e) != i5 && i15 >= i8));
            u0.P pG = s9.g(obj, p3);
            if (!z19 && j12 == j9 && c3.f3625a.equals(cP.f3625a)) {
                if (c3.b()) {
                    pG.g(c3.f3626b);
                }
                if (cP.b()) {
                    pG.g(cP.f3626b);
                }
            }
            L0.C c14 = !z21 ? cP : c3;
            if (!c14.b()) {
                j10 = jLongValue;
                n8 = new N(c14, j10, j9, z9, r31, z10);
            } else if (c14.equals(c3)) {
                jLongValue = j0Var.f832s;
                j10 = jLongValue;
                n8 = new N(c14, j10, j9, z9, r31, z10);
            } else {
                s9.g(c14.f3625a, p3);
                if (c14.f3627c == p3.e(c14.f3626b)) {
                    p3.f17181g.getClass();
                }
                j10 = 0;
                n8 = new N(c14, j10, j9, z9, r31, z10);
            }
        }
        L0.C c15 = n8.f596a;
        ?? r123 = n8.f598c;
        boolean z22 = n8.f599d;
        long jV = n8.f597b;
        boolean z23 = (this.f620R.f816b.equals(c15) && jV == this.f620R.f832s) ? false : true;
        try {
            if (n8.f600e) {
                try {
                    z17 = true;
                    if (this.f620R.f819e != 1) {
                        i10 = 4;
                        try {
                            i0(4);
                        } catch (Throwable th) {
                            th = th;
                            r11 = s9;
                            c8 = c15;
                            z16 = z17;
                            i9 = i10;
                            r20 = r123;
                            r12 = 2;
                            r13 = 0;
                        }
                    } else {
                        i10 = 4;
                    }
                    M(false, false, false, true);
                } catch (Throwable th2) {
                    th = th2;
                    z17 = true;
                    i10 = 4;
                    r11 = s9;
                    c8 = c15;
                    z16 = z17;
                    i9 = i10;
                    r20 = r123;
                    r12 = 2;
                    r13 = 0;
                }
            } else {
                z17 = true;
                i10 = 4;
            }
            for (q0 q0Var : this.f644q) {
                try {
                    AbstractC0020g abstractC0020g = q0Var.f879a;
                    if (!Objects.equals(abstractC0020g.f754F, s9)) {
                        abstractC0020g.f754F = s9;
                    }
                    AbstractC0020g abstractC0020g2 = q0Var.f881c;
                    if (abstractC0020g2 != null && !Objects.equals(abstractC0020g2.f754F, s9)) {
                        abstractC0020g2.f754F = s9;
                    }
                } catch (Throwable th3) {
                    th = th3;
                    r11 = s9;
                    c8 = c15;
                    i9 = i10;
                    r20 = r123;
                    r12 = 2;
                    r13 = 0;
                    z16 = true;
                }
            }
            try {
                if (z23) {
                    r8 = s9;
                    i9 = i10;
                    r202 = r123;
                    i12 = 2;
                    i12 = 2;
                    r122 = 2;
                    r123 = 2;
                    o8 = null;
                    o8 = null;
                    c10 = null;
                    c3 = null;
                    z16 = true;
                    r205 = r202;
                    if (r8.p()) {
                        c8 = c15;
                        r204 = r205;
                    } else {
                        try {
                            for (V v8 = this.H.i; v8 != null; v8 = v8.f674m) {
                                if (v8.f669g.f678a.equals(c15)) {
                                    v8.f669g = this.H.h(r8, v8.f669g);
                                    v8.k();
                                }
                            }
                            Y y9 = this.H;
                            c8 = c15;
                            try {
                                jV = V(c8, jV, y9.i != y9.f699j, z22);
                                r204 = r202;
                            } catch (Throwable th4) {
                                th = th4;
                                jV = jV;
                                r82 = r8;
                                r203 = r202;
                                r11 = r82;
                                r12 = r122;
                                r13 = c10;
                                r20 = r203;
                                j0 j0Var2 = this.f620R;
                                u0.S s12 = j0Var2.f815a;
                                L0.C c16 = j0Var2.f816b;
                                c9 = c8;
                                v0(r11, c9, s12, c16, !n8.f601f ? jV : j8, false);
                                if (!z23) {
                                }
                                N();
                                P(r11, this.f620R.f815a);
                                this.f620R = this.f620R.i(r11);
                                if (!r11.p()) {
                                }
                                r(false);
                                this.f651x.e(r12);
                                throw th;
                            }
                        } catch (Throwable th5) {
                            th = th5;
                            c8 = c15;
                            r82 = r8;
                            r122 = r123;
                            c10 = c3;
                            r203 = r202;
                            r11 = r82;
                            r12 = r122;
                            r13 = c10;
                            r20 = r203;
                            j0 j0Var22 = this.f620R;
                            u0.S s122 = j0Var22.f815a;
                            L0.C c162 = j0Var22.f816b;
                            c9 = c8;
                            v0(r11, c9, s122, c162, !n8.f601f ? jV : j8, false);
                            if (!z23) {
                            }
                            N();
                            P(r11, this.f620R.f815a);
                            this.f620R = this.f620R.i(r11);
                            if (!r11.p()) {
                            }
                            r(false);
                            this.f651x.e(r12);
                            throw th;
                        }
                    }
                    j0 j0Var3 = this.f620R;
                    c11 = c8;
                    v0(s8, c11, j0Var3.f815a, j0Var3.f816b, !n8.f601f ? jV : j8, false);
                    if (!z23) {
                        j0 j0Var4 = this.f620R;
                        Object obj4 = j0Var4.f816b.f3625a;
                        u0.S s13 = j0Var4.f815a;
                        if (z23) {
                            this.f620R = w(c11, jV, r204, this.f620R.f818d, (z23 || !z8 || s13.p() || s13.g(obj4, this.f606B).f17180f) ? false : z16, s8.b(obj4) != -1 ? i9 : 3);
                        }
                    }
                    N();
                    P(s8, this.f620R.f815a);
                    this.f620R = this.f620R.i(s8);
                    if (!s8.p()) {
                    }
                    r(false);
                    this.f651x.e(i12);
                    return;
                }
                try {
                    try {
                        V v9 = this.H.f699j;
                        try {
                            i11 = i10;
                        } catch (Throwable th6) {
                            th = th6;
                            s10 = s8;
                            i9 = i10;
                            r8 = s10;
                            r202 = r123;
                            r123 = 2;
                            c3 = null;
                            z16 = true;
                            c8 = c15;
                            r82 = r8;
                            r122 = r123;
                            c10 = c3;
                            r203 = r202;
                            r11 = r82;
                            r12 = r122;
                            r13 = c10;
                            r20 = r203;
                            j0 j0Var222 = this.f620R;
                            u0.S s1222 = j0Var222.f815a;
                            L0.C c1622 = j0Var222.f816b;
                            c9 = c8;
                            v0(r11, c9, s1222, c1622, !n8.f601f ? jV : j8, false);
                            if (!z23) {
                                j0 j0Var5 = this.f620R;
                                Object obj5 = j0Var5.f816b.f3625a;
                                u0.S s14 = j0Var5.f815a;
                                if (z23) {
                                    this.f620R = w(c9, jV, r20, this.f620R.f818d, (z23 || !z8 || s14.p() || s14.g(obj5, this.f606B).f17180f) ? false : z16, r11.b(obj5) != -1 ? i9 : 3);
                                }
                            }
                            N();
                            P(r11, this.f620R.f815a);
                            this.f620R = this.f620R.i(r11);
                            if (!r11.p()) {
                            }
                            r(false);
                            this.f651x.e(r12);
                            throw th;
                        }
                        try {
                            i9 = i11;
                            r202 = r123;
                            r123 = 2;
                            i12 = 2;
                            i12 = 2;
                            i12 = 2;
                            c3 = null;
                            o8 = null;
                            o8 = null;
                            o8 = null;
                            z16 = true;
                            try {
                                int iS = this.H.s(s8, this.f634g0, v9 == null ? 0L : j(v9), (!b() || (v7 = this.H.f700k) == null) ? 0L : j(v7));
                                if ((iS & 1) != 0) {
                                    T(false);
                                    r205 = r202;
                                } else {
                                    r205 = r202;
                                    if ((iS & 2) != 0) {
                                        d();
                                        r205 = r202;
                                    }
                                }
                                c8 = c15;
                                r204 = r205;
                                j0 j0Var32 = this.f620R;
                                c11 = c8;
                                v0(s8, c11, j0Var32.f815a, j0Var32.f816b, !n8.f601f ? jV : j8, false);
                                if (!z23 || r204 != this.f620R.f817c) {
                                    j0 j0Var42 = this.f620R;
                                    Object obj42 = j0Var42.f816b.f3625a;
                                    u0.S s132 = j0Var42.f815a;
                                    this.f620R = w(c11, jV, r204, this.f620R.f818d, (z23 || !z8 || s132.p() || s132.g(obj42, this.f606B).f17180f) ? false : z16, s8.b(obj42) != -1 ? i9 : 3);
                                }
                                N();
                                P(s8, this.f620R.f815a);
                                this.f620R = this.f620R.i(s8);
                                if (!s8.p()) {
                                    this.f633f0 = o8;
                                }
                                r(false);
                                this.f651x.e(i12);
                                return;
                            } catch (Throwable th7) {
                                th = th7;
                                r8 = s8;
                                c8 = c15;
                                r82 = r8;
                                r122 = r123;
                                c10 = c3;
                                r203 = r202;
                                r11 = r82;
                                r12 = r122;
                                r13 = c10;
                                r20 = r203;
                                j0 j0Var2222 = this.f620R;
                                u0.S s12222 = j0Var2222.f815a;
                                L0.C c16222 = j0Var2222.f816b;
                                c9 = c8;
                                v0(r11, c9, s12222, c16222, !n8.f601f ? jV : j8, false);
                                if (!z23) {
                                }
                                N();
                                P(r11, this.f620R.f815a);
                                this.f620R = this.f620R.i(r11);
                                if (!r11.p()) {
                                }
                                r(false);
                                this.f651x.e(r12);
                                throw th;
                            }
                        } catch (Throwable th8) {
                            th = th8;
                            r8 = s8;
                            i9 = i11;
                            r202 = r123;
                            r123 = 2;
                            c3 = null;
                            z16 = true;
                            c8 = c15;
                            r82 = r8;
                            r122 = r123;
                            c10 = c3;
                            r203 = r202;
                            r11 = r82;
                            r12 = r122;
                            r13 = c10;
                            r20 = r203;
                            j0 j0Var22222 = this.f620R;
                            u0.S s122222 = j0Var22222.f815a;
                            L0.C c162222 = j0Var22222.f816b;
                            c9 = c8;
                            v0(r11, c9, s122222, c162222, !n8.f601f ? jV : j8, false);
                            if (!z23) {
                            }
                            N();
                            P(r11, this.f620R.f815a);
                            this.f620R = this.f620R.i(r11);
                            if (!r11.p()) {
                            }
                            r(false);
                            this.f651x.e(r12);
                            throw th;
                        }
                    } catch (Throwable th9) {
                        th = th9;
                        r8 = s9;
                        i9 = i10;
                    }
                } catch (Throwable th10) {
                    th = th10;
                    s10 = s9;
                }
            } catch (Throwable th11) {
                th = th11;
            }
        } catch (Throwable th12) {
            th = th12;
            r11 = s9;
            c8 = c15;
            r20 = r123;
            r12 = 2;
            r13 = 0;
            z16 = true;
            i9 = 4;
        }
        j0 j0Var222222 = this.f620R;
        u0.S s1222222 = j0Var222222.f815a;
        L0.C c1622222 = j0Var222222.f816b;
        c9 = c8;
        v0(r11, c9, s1222222, c1622222, !n8.f601f ? jV : j8, false);
        if (!z23 || r20 != this.f620R.f817c) {
            j0 j0Var52 = this.f620R;
            Object obj52 = j0Var52.f816b.f3625a;
            u0.S s142 = j0Var52.f815a;
            this.f620R = w(c9, jV, r20, this.f620R.f818d, (z23 || !z8 || s142.p() || s142.g(obj52, this.f606B).f17180f) ? false : z16, r11.b(obj52) != -1 ? i9 : 3);
        }
        N();
        P(r11, this.f620R.f815a);
        this.f620R = this.f620R.i(r11);
        if (!r11.p()) {
            this.f633f0 = r13;
        }
        r(false);
        this.f651x.e(r12);
        throw th;
    }

    public final void t0(int i, int i5, int i8, boolean z8) {
        boolean z9 = z8 && i != -1;
        if (i == -1) {
            i8 = 2;
        } else if (i8 == 2) {
            i8 = 1;
        }
        if (i == 0) {
            i5 = 1;
        } else if (i5 == 1) {
            i5 = 0;
        }
        j0 j0Var = this.f620R;
        if (j0Var.f825l == z9 && j0Var.f827n == i5 && j0Var.f826m == i8) {
            return;
        }
        this.f620R = j0Var.e(i8, i5, z9);
        w0(false, false);
        Y y8 = this.H;
        for (V v7 = y8.i; v7 != null; v7 = v7.f674m) {
            for (O0.s sVar : v7.f676o.f4911c) {
                if (sVar != null) {
                    sVar.d(z9);
                }
            }
        }
        if (!l0()) {
            p0();
            u0();
            y8.m(this.f634g0);
            return;
        }
        int i9 = this.f620R.f819e;
        x0.s sVar2 = this.f651x;
        if (i9 != 3) {
            if (i9 == 2) {
                sVar2.e(2);
            }
        } else {
            C0026m c0026m = this.D;
            c0026m.f845r = true;
            ((s0) c0026m.f846s).f();
            n0();
            sVar2.e(2);
        }
    }

    public final void u(L0.A a3) {
        V v7;
        Y y8 = this.H;
        V v8 = y8.f701l;
        int i = 0;
        boolean z8 = v8 != null && v8.f663a == a3;
        C0026m c0026m = this.D;
        if (z8) {
            v8.getClass();
            if (!v8.f667e) {
                float f3 = c0026m.b().f17159a;
                j0 j0Var = this.f620R;
                v8.f(f3, j0Var.f815a, j0Var.f825l);
            }
            r0(v8.f676o);
            if (v8 == y8.i) {
                O(v8.f669g.f679b);
                h(new boolean[this.f644q.length], y8.f699j.e());
                v8.f670h = true;
                j0 j0Var2 = this.f620R;
                L0.C c3 = j0Var2.f816b;
                W w4 = v8.f669g;
                long j8 = j0Var2.f817c;
                long j9 = w4.f679b;
                this.f620R = w(c3, j9, j8, j9, false, 5);
            }
            z();
            return;
        }
        while (true) {
            if (i >= y8.f706q.size()) {
                v7 = null;
                break;
            }
            v7 = (V) y8.f706q.get(i);
            if (v7.f663a == a3) {
                break;
            } else {
                i++;
            }
        }
        if (v7 != null) {
            AbstractC1709a.j(!v7.f667e);
            float f7 = c0026m.b().f17159a;
            j0 j0Var3 = this.f620R;
            v7.f(f7, j0Var3.f815a, j0Var3.f825l);
            V v9 = y8.f702m;
            if (v9 == null || v9.f663a != a3) {
                return;
            }
            A();
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:47:0x00de  */
    /* JADX WARN: Type inference failed for: r2v28, types: [L0.A, java.lang.Object] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void u0() {
        long j8;
        int i;
        u0.H hB;
        long j9;
        boolean z8;
        float f3;
        V v7 = this.H.i;
        if (v7 == null) {
            return;
        }
        long jT = v7.f667e ? v7.f663a.t() : -9223372036854775807L;
        if (jT != -9223372036854775807L) {
            if (!v7.g()) {
                this.H.n(v7);
                r(false);
                z();
            }
            O(jT);
            if (jT != this.f620R.f832s) {
                j0 j0Var = this.f620R;
                j8 = -9223372036854775807L;
                i = 16;
                this.f620R = w(j0Var.f816b, jT, j0Var.f817c, jT, true, 5);
            } else {
                j8 = -9223372036854775807L;
                i = 16;
            }
        } else {
            j8 = -9223372036854775807L;
            i = 16;
            C0026m c0026m = this.D;
            boolean z9 = v7 != this.H.f699j;
            AbstractC0020g abstractC0020g = (AbstractC0020g) c0026m.f848u;
            s0 s0Var = (s0) c0026m.f846s;
            if (abstractC0020g == null || abstractC0020g.k() || ((z9 && ((AbstractC0020g) c0026m.f848u).f763x != 2) || (!((AbstractC0020g) c0026m.f848u).l() && (z9 || ((AbstractC0020g) c0026m.f848u).j())))) {
                c0026m.f844q = true;
                if (c0026m.f845r) {
                    s0Var.f();
                }
            } else {
                U u8 = (U) c0026m.f849v;
                u8.getClass();
                long jE = u8.e();
                if (!c0026m.f844q) {
                    s0Var.d(jE);
                    hB = u8.b();
                    if (!hB.equals((u0.H) s0Var.f894u)) {
                        s0Var.a(hB);
                        ((P) c0026m.f847t).f651x.a(16, hB).b();
                    }
                } else if (jE >= s0Var.e()) {
                    c0026m.f844q = false;
                    if (c0026m.f845r) {
                        s0Var.f();
                    }
                    s0Var.d(jE);
                    hB = u8.b();
                    if (!hB.equals((u0.H) s0Var.f894u)) {
                    }
                } else if (s0Var.f891r) {
                    s0Var.d(s0Var.e());
                    s0Var.f891r = false;
                }
            }
            long jE2 = c0026m.e();
            this.f634g0 = jE2;
            long j10 = jE2 - v7.f677p;
            long j11 = this.f620R.f832s;
            if (!this.f608E.isEmpty() && !this.f620R.f816b.b()) {
                if (this.f637j0) {
                    this.f637j0 = false;
                }
                j0 j0Var2 = this.f620R;
                j0Var2.f815a.b(j0Var2.f816b.f3625a);
                int iMin = Math.min(this.f636i0, this.f608E.size());
                if (iMin > 0 && this.f608E.get(iMin - 1) != null) {
                    throw new ClassCastException();
                }
                if (iMin < this.f608E.size() && this.f608E.get(iMin) != null) {
                    throw new ClassCastException();
                }
                this.f636i0 = iMin;
            }
            if (this.D.c()) {
                boolean z10 = !this.f621S.f359d;
                j0 j0Var3 = this.f620R;
                this.f620R = w(j0Var3.f816b, j10, j0Var3.f817c, j10, z10, 6);
            } else {
                j0 j0Var4 = this.f620R;
                j0Var4.f832s = j10;
                j0Var4.f833t = SystemClock.elapsedRealtime();
            }
        }
        this.f620R.f830q = this.H.f701l.d();
        j0 j0Var5 = this.f620R;
        j0Var5.f831r = l(j0Var5.f830q);
        j0 j0Var6 = this.f620R;
        if (j0Var6.f825l && j0Var6.f819e == 3 && m0(j0Var6.f815a, j0Var6.f816b)) {
            j0 j0Var7 = this.f620R;
            float f7 = 1.0f;
            if (j0Var7.f828o.f17159a == 1.0f) {
                C0023j c0023j = this.f612J;
                long jI = i(j0Var7.f815a, j0Var7.f816b.f3625a, j0Var7.f832s);
                long j12 = this.f620R.f831r;
                if (c0023j.f803c == j8) {
                    z8 = false;
                } else {
                    long j13 = jI - j12;
                    long j14 = c0023j.f812m;
                    if (j14 == j8) {
                        c0023j.f812m = j13;
                        c0023j.f813n = 0L;
                    } else {
                        c0023j.f812m = Math.max(j13, (long) ((j13 * 9.999871E-4f) + (j14 * 0.999f)));
                        c0023j.f813n = (long) ((9.999871E-4f * Math.abs(j13 - r8)) + (c0023j.f813n * 0.999f));
                    }
                    if (c0023j.f811l != j8) {
                        j9 = 1000;
                        if (SystemClock.elapsedRealtime() - c0023j.f811l < 1000) {
                            f7 = c0023j.f810k;
                            z8 = false;
                        }
                    } else {
                        j9 = 1000;
                    }
                    c0023j.f811l = SystemClock.elapsedRealtime();
                    long j15 = (c0023j.f813n * 3) + c0023j.f812m;
                    if (c0023j.f808h > j15) {
                        float fL = x0.v.L(j9);
                        f3 = 1.0E-7f;
                        z8 = false;
                        long[] jArr = {j15, c0023j.f805e, c0023j.f808h - (((long) ((c0023j.f810k - 1.0f) * fL)) + ((long) ((c0023j.i - 1.0f) * fL)))};
                        long j16 = jArr[0];
                        for (int i5 = 1; i5 < 3; i5++) {
                            long j17 = jArr[i5];
                            if (j17 > j16) {
                                j16 = j17;
                            }
                        }
                        c0023j.f808h = j16;
                    } else {
                        z8 = false;
                        f3 = 1.0E-7f;
                        long j18 = x0.v.j(jI - ((long) (Math.max(0.0f, c0023j.f810k - 1.0f) / 1.0E-7f)), c0023j.f808h, j15);
                        c0023j.f808h = j18;
                        long j19 = c0023j.f807g;
                        if (j19 != j8 && j18 > j19) {
                            c0023j.f808h = j19;
                        }
                    }
                    long j20 = jI - c0023j.f808h;
                    if (Math.abs(j20) < c0023j.f801a) {
                        c0023j.f810k = 1.0f;
                    } else {
                        c0023j.f810k = x0.v.h((f3 * j20) + 1.0f, c0023j.f809j, c0023j.i);
                    }
                    f7 = c0023j.f810k;
                }
                if (this.D.b().f17159a != f7) {
                    u0.H h8 = new u0.H(f7, this.f620R.f828o.f17160b);
                    this.f651x.d(i);
                    this.D.a(h8);
                    v(this.f620R.f828o, this.D.b().f17159a, z8, z8);
                }
            }
        }
    }

    public final void v(u0.H h8, float f3, boolean z8, boolean z9) {
        int i;
        if (z8) {
            if (z9) {
                this.f621S.f(1);
            }
            this.f620R = this.f620R.g(h8);
        }
        float f7 = h8.f17159a;
        V v7 = this.H.i;
        while (true) {
            i = 0;
            if (v7 == null) {
                break;
            }
            O0.s[] sVarArr = v7.f676o.f4911c;
            int length = sVarArr.length;
            while (i < length) {
                O0.s sVar = sVarArr[i];
                if (sVar != null) {
                    sVar.j(f7);
                }
                i++;
            }
            v7 = v7.f674m;
        }
        q0[] q0VarArr = this.f644q;
        int length2 = q0VarArr.length;
        while (i < length2) {
            q0 q0Var = q0VarArr[i];
            AbstractC0020g abstractC0020g = q0Var.f879a;
            float f8 = h8.f17159a;
            abstractC0020g.x(f3, f8);
            AbstractC0020g abstractC0020g2 = q0Var.f881c;
            if (abstractC0020g2 != null) {
                abstractC0020g2.x(f3, f8);
            }
            i++;
        }
    }

    public final void v0(u0.S s8, L0.C c3, u0.S s9, L0.C c8, long j8, boolean z8) {
        if (!m0(s8, c3)) {
            u0.H h8 = c3.b() ? u0.H.f17158d : this.f620R.f828o;
            C0026m c0026m = this.D;
            if (c0026m.b().equals(h8)) {
                return;
            }
            this.f651x.d(16);
            c0026m.a(h8);
            v(this.f620R.f828o, h8.f17159a, false, false);
            return;
        }
        Object obj = c3.f3625a;
        u0.P p3 = this.f606B;
        int i = s8.g(obj, p3).f17177c;
        u0.Q q8 = this.f605A;
        s8.n(i, q8);
        C1583t c1583t = q8.f17192j;
        C0023j c0023j = this.f612J;
        c0023j.getClass();
        c0023j.f803c = x0.v.L(c1583t.f17379a);
        c0023j.f806f = x0.v.L(c1583t.f17380b);
        c0023j.f807g = x0.v.L(c1583t.f17381c);
        float f3 = c1583t.f17382d;
        if (f3 == -3.4028235E38f) {
            f3 = 0.97f;
        }
        c0023j.f809j = f3;
        float f7 = c1583t.f17383e;
        if (f7 == -3.4028235E38f) {
            f7 = 1.03f;
        }
        c0023j.i = f7;
        if (f3 == 1.0f && f7 == 1.0f) {
            c0023j.f803c = -9223372036854775807L;
        }
        c0023j.a();
        if (j8 != -9223372036854775807L) {
            c0023j.f804d = i(s8, obj, j8);
            c0023j.a();
            return;
        }
        if (!Objects.equals(!s9.p() ? s9.m(s9.g(c8.f3625a, p3).f17177c, q8, 0L).f17184a : null, q8.f17184a) || z8) {
            c0023j.f804d = -9223372036854775807L;
            c0023j.a();
        }
    }

    public final j0 w(L0.C c3, long j8, long j9, long j10, boolean z8, int i) {
        C3.W wG;
        boolean z9;
        int i5;
        this.f637j0 = (!this.f637j0 && j8 == this.f620R.f832s && c3.equals(this.f620R.f816b)) ? false : true;
        N();
        j0 j0Var = this.f620R;
        L0.n0 n0Var = j0Var.f822h;
        O0.v vVar = j0Var.i;
        List list = j0Var.f823j;
        if (this.f611I.f791b) {
            V v7 = this.H.i;
            n0Var = v7 == null ? L0.n0.f3882d : v7.f675n;
            vVar = v7 == null ? this.f648u : v7.f676o;
            O0.s[] sVarArr = vVar.f4911c;
            C3.D d8 = new C3.D(4);
            boolean z10 = false;
            for (O0.s sVar : sVarArr) {
                if (sVar != null) {
                    u0.D d9 = sVar.h(0).f17356l;
                    if (d9 == null) {
                        d8.a(new u0.D(new u0.C[0]));
                    } else {
                        d8.a(d9);
                        z10 = true;
                    }
                }
            }
            int i8 = 1;
            if (z10) {
                wG = d8.g();
            } else {
                C3.E e8 = C3.G.f1197r;
                wG = C3.W.f1225u;
            }
            list = wG;
            if (v7 != null) {
                W w4 = v7.f669g;
                if (w4.f680c != j9) {
                    v7.f669g = w4.a(j9);
                }
            }
            Y y8 = this.H;
            V v8 = y8.i;
            if (v8 == y8.f699j && v8 != null) {
                O0.v vVar2 = v8.f676o;
                int i9 = 0;
                int i10 = 0;
                while (true) {
                    q0[] q0VarArr = this.f644q;
                    if (i9 >= q0VarArr.length) {
                        z9 = true;
                        break;
                    }
                    if (vVar2.b(i9)) {
                        i5 = i8;
                        if (q0VarArr[i9].f879a.f757r != i5) {
                            z9 = false;
                            break;
                        }
                        if (vVar2.f4910b[i9].f870a != 0) {
                            i10 = i5;
                        }
                    } else {
                        i5 = i8;
                    }
                    i9 += i5;
                    i8 = i5;
                }
                boolean z11 = i10 != 0 && z9;
                if (z11 != this.f631d0) {
                    this.f631d0 = z11;
                    if (!z11 && this.f620R.f829p) {
                        this.f651x.e(2);
                    }
                }
            }
        } else if (!c3.equals(j0Var.f816b)) {
            n0Var = L0.n0.f3882d;
            vVar = this.f648u;
            list = C3.W.f1225u;
        }
        L0.n0 n0Var2 = n0Var;
        O0.v vVar3 = vVar;
        List list2 = list;
        if (z8) {
            A1.x xVar = this.f621S;
            if (!xVar.f359d || xVar.f360e == 5) {
                xVar.f357b = true;
                xVar.f359d = true;
                xVar.f360e = i;
            } else {
                AbstractC1709a.d(i == 5);
            }
        }
        j0 j0Var2 = this.f620R;
        return j0Var2.d(c3, j8, j9, j10, l(j0Var2.f830q), n0Var2, vVar3, list2);
    }

    public final void w0(boolean z8, boolean z9) {
        long jElapsedRealtime;
        this.f625W = z8;
        if (!z8 || z9) {
            jElapsedRealtime = -9223372036854775807L;
        } else {
            this.f609F.getClass();
            jElapsedRealtime = SystemClock.elapsedRealtime();
        }
        this.X = jElapsedRealtime;
    }

    public final synchronized void x0(B3.l lVar, long j8) {
        this.f609F.getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime() + j8;
        boolean z8 = false;
        while (!((Boolean) lVar.get()).booleanValue() && j8 > 0) {
            try {
                this.f609F.getClass();
                wait(j8);
            } catch (InterruptedException unused) {
                z8 = true;
            }
            this.f609F.getClass();
            j8 = jElapsedRealtime - SystemClock.elapsedRealtime();
        }
        if (z8) {
            Thread.currentThread().interrupt();
        }
    }

    public final boolean y() {
        V v7 = this.H.i;
        long j8 = v7.f669g.f682e;
        if (v7.f667e) {
            return j8 == -9223372036854775807L || this.f620R.f832s < j8 || !l0();
        }
        return false;
    }

    /* JADX WARN: Type inference failed for: r1v16, types: [L0.A, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r1v23, types: [L0.e0, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r7v1, types: [L0.e0, java.lang.Object] */
    public final void z() {
        boolean zC;
        if (x(this.H.f701l)) {
            V v7 = this.H.f701l;
            long jL = l(!v7.f667e ? 0L : v7.f663a.r());
            V v8 = this.H.i;
            long j8 = m0(this.f620R.f815a, v7.f669g.f678a) ? this.f612J.f808h : -9223372036854775807L;
            C0.l lVar = this.f614L;
            u0.S s8 = this.f620R.f815a;
            float f3 = this.D.b().f17159a;
            boolean z8 = this.f620R.f825l;
            Q q8 = new Q(lVar, jL, f3, this.f625W, j8);
            zC = this.f649v.c(q8);
            V v9 = this.H.i;
            if (!zC && v9.f667e && jL < 500000 && this.f607C > 0) {
                v9.f663a.q(this.f620R.f832s);
                zC = this.f649v.c(q8);
            }
        } else {
            zC = false;
        }
        this.f626Y = zC;
        if (zC) {
            V v10 = this.H.f701l;
            v10.getClass();
            S s9 = new S();
            s9.f657a = this.f634g0 - v10.f677p;
            float f7 = this.D.b().f17159a;
            AbstractC1709a.d(f7 > 0.0f || f7 == -3.4028235E38f);
            s9.f658b = f7;
            long j9 = this.X;
            AbstractC1709a.d(j9 >= 0 || j9 == -9223372036854775807L);
            s9.f659c = j9;
            T t6 = new T(s9);
            AbstractC1709a.j(v10.f674m == null);
            v10.f663a.f(t6);
        }
        q0();
    }
}
