package L0;

import android.util.SparseArray;
import d3.R0;
import java.io.EOFException;
import java.util.Objects;
import u0.C1575k;
import u0.C1578n;
import u0.C1579o;
import u0.InterfaceC1571g;
import x0.AbstractC1709a;

/* JADX INFO: loaded from: classes.dex */
public class b0 implements T0.F {

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public C1579o f3763A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public C1579o f3764B;

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

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

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

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Y f3769a;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final E0.h f3772d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final E0.e f3773e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public Object f3774f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public C1579o f3775g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public K4.c f3776h;

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

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

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

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

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final H0.g f3770b = new H0.g();
    public int i = 1000;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public long[] f3777j = new long[1000];

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public long[] f3778k = new long[1000];

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public long[] f3781n = new long[1000];

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int[] f3780m = new int[1000];

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int[] f3779l = new int[1000];

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public T0.E[] f3782o = new T0.E[1000];

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final A1.H f3771c = new A1.H(new I3.y(4));

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public long f3787t = Long.MIN_VALUE;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public long f3788u = Long.MIN_VALUE;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public long f3789v = Long.MIN_VALUE;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public boolean f3792y = true;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public boolean f3791x = true;
    public boolean D = true;

    public b0(P0.e eVar, E0.h hVar, E0.e eVar2) {
        this.f3772d = hVar;
        this.f3773e = eVar2;
        this.f3769a = new Y(eVar);
    }

    public final synchronized void A() {
        this.f3786s = 0;
        Y y8 = this.f3769a;
        y8.f3751e = y8.f3750d;
    }

    public final synchronized boolean B(int i) {
        A();
        int i5 = this.f3784q;
        if (i >= i5 && i <= this.f3783p + i5) {
            this.f3787t = Long.MIN_VALUE;
            this.f3786s = i - i5;
            return true;
        }
        return false;
    }

    public final synchronized boolean C(long j8, boolean z8) throws Throwable {
        Throwable th;
        b0 b0Var;
        long j9;
        int iL;
        try {
            try {
                A();
                int iR = r(this.f3786s);
                int i = this.f3786s;
                int i5 = this.f3783p;
                if (!(i != i5) || j8 < this.f3781n[iR] || (j8 > this.f3789v && !z8)) {
                    return false;
                }
                if (this.D) {
                    int i8 = i5 - i;
                    int i9 = 0;
                    while (true) {
                        if (i9 < i8) {
                            try {
                                if (this.f3781n[iR] >= j8) {
                                    i8 = i9;
                                    break;
                                }
                                iR++;
                                if (iR == this.i) {
                                    iR = 0;
                                }
                                i9++;
                            } catch (Throwable th2) {
                                th = th2;
                            }
                        } else if (!z8) {
                            i8 = -1;
                        }
                    }
                    j9 = j8;
                    iL = i8;
                    b0Var = this;
                } else {
                    int i10 = i5 - i;
                    b0Var = this;
                    j9 = j8;
                    iL = b0Var.l(iR, i10, j9, true);
                }
                if (iL == -1) {
                    return false;
                }
                b0Var.f3787t = j9;
                b0Var.f3786s += iL;
                return true;
            } catch (Throwable th3) {
                th = th3;
            }
        } catch (Throwable th4) {
            th = th4;
        }
        th = th;
        throw th;
    }

    /* JADX WARN: Removed duplicated region for block: B:9:0x000e  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final synchronized void D(int i) {
        boolean z8;
        if (i >= 0) {
            try {
                z8 = this.f3786s + i <= this.f3783p;
            } catch (Throwable th) {
                throw th;
            }
        }
        AbstractC1709a.d(z8);
        this.f3786s += i;
    }

    /* JADX WARN: Removed duplicated region for block: B:24:0x004e  */
    @Override // T0.F
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void a(long j8, int i, int i5, int i8, T0.E e8) {
        int i9;
        if (this.f3793z) {
            C1579o c1579o = this.f3763A;
            AbstractC1709a.k(c1579o);
            e(c1579o);
        }
        int i10 = i & 1;
        boolean z8 = i10 != 0;
        if (this.f3791x) {
            if (!z8) {
                return;
            } else {
                this.f3791x = false;
            }
        }
        long j9 = this.f3767F + j8;
        if (!this.D) {
            i9 = i;
        } else {
            if (j9 < this.f3787t) {
                return;
            }
            if (i10 == 0) {
                if (!this.f3766E) {
                    AbstractC1709a.B("SampleQueue", "Overriding unexpected non-sync sample for format: " + this.f3764B);
                    this.f3766E = true;
                }
                i9 = i | 1;
            }
        }
        if (this.f3768G) {
            if (!z8) {
                return;
            }
            synchronized (this) {
                if (this.f3783p == 0) {
                    z = j9 > this.f3788u;
                } else if (o() >= j9) {
                    z = false;
                } else {
                    int i11 = this.f3783p;
                    int iR = r(i11 - 1);
                    while (i11 > this.f3786s && this.f3781n[iR] >= j9) {
                        i11--;
                        iR--;
                        if (iR == -1) {
                            iR = this.i - 1;
                        }
                    }
                    k(this.f3784q + i11);
                }
            }
            if (!z) {
                return;
            } else {
                this.f3768G = false;
            }
        }
        g(j9, i9, (this.f3769a.f3753g - ((long) i5)) - ((long) i8), i5, e8);
    }

    @Override // T0.F
    public final void b(x0.o oVar, int i, int i5) {
        while (true) {
            Y y8 = this.f3769a;
            if (i <= 0) {
                y8.getClass();
                return;
            }
            int iC = y8.c(i);
            X x8 = y8.f3752f;
            P0.a aVar = (P0.a) x8.f3745s;
            oVar.e(aVar.f5254a, ((int) (y8.f3753g - x8.f3743q)) + aVar.f5255b, iC);
            i -= iC;
            long j8 = y8.f3753g + ((long) iC);
            y8.f3753g = j8;
            X x9 = y8.f3752f;
            if (j8 == x9.f3744r) {
                y8.f3752f = (X) x9.f3746t;
            }
        }
    }

    @Override // T0.F
    public final void c(int i, x0.o oVar) {
        b(oVar, i, 0);
    }

    @Override // T0.F
    public final int d(InterfaceC1571g interfaceC1571g, int i, boolean z8) throws EOFException {
        Y y8 = this.f3769a;
        int iC = y8.c(i);
        X x8 = y8.f3752f;
        P0.a aVar = (P0.a) x8.f3745s;
        int iP = interfaceC1571g.p(aVar.f5254a, ((int) (y8.f3753g - x8.f3743q)) + aVar.f5255b, iC);
        if (iP == -1) {
            if (z8) {
                return -1;
            }
            throw new EOFException();
        }
        long j8 = y8.f3753g + ((long) iP);
        y8.f3753g = j8;
        X x9 = y8.f3752f;
        if (j8 == x9.f3744r) {
            y8.f3752f = (X) x9.f3746t;
        }
        return iP;
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x0059 A[Catch: all -> 0x0057, TryCatch #0 {all -> 0x0057, blocks: (B:4:0x000a, B:8:0x0016, B:13:0x0028, B:15:0x0041, B:19:0x005b, B:18:0x0059), top: B:29:0x000a }] */
    /* JADX WARN: Type inference failed for: r5v26, types: [L0.a0, java.lang.Object] */
    @Override // T0.F
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void e(C1579o c1579o) {
        C1579o c1579oM = m(c1579o);
        boolean z8 = false;
        this.f3793z = false;
        this.f3763A = c1579o;
        synchronized (this) {
            try {
                this.f3792y = false;
                if (!Objects.equals(c1579oM, this.f3764B)) {
                    if (!(((SparseArray) this.f3771c.f66s).size() == 0)) {
                        SparseArray sparseArray = (SparseArray) this.f3771c.f66s;
                        if (((Z) sparseArray.valueAt(sparseArray.size() - 1)).f3754a.equals(c1579oM)) {
                            SparseArray sparseArray2 = (SparseArray) this.f3771c.f66s;
                            this.f3764B = ((Z) sparseArray2.valueAt(sparseArray2.size() - 1)).f3754a;
                        } else {
                            this.f3764B = c1579oM;
                        }
                        boolean z9 = this.D;
                        C1579o c1579o2 = this.f3764B;
                        this.D = z9 & u0.E.a(c1579o2.f17358n, c1579o2.f17355k);
                        this.f3766E = false;
                        z8 = true;
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        ?? r52 = this.f3774f;
        if (r52 == 0 || !z8) {
            return;
        }
        r52.m();
    }

    @Override // T0.F
    public final int f(InterfaceC1571g interfaceC1571g, int i, boolean z8) {
        return d(interfaceC1571g, i, z8);
    }

    /* JADX WARN: Removed duplicated region for block: B:23:0x0082 A[Catch: all -> 0x0021, TryCatch #0 {all -> 0x0021, blocks: (B:3:0x0001, B:5:0x0007, B:9:0x001d, B:12:0x0024, B:16:0x002c, B:21:0x0067, B:44:0x00e3, B:46:0x00ec, B:23:0x0082, B:25:0x008b, B:27:0x0094, B:29:0x00a9, B:33:0x00b2, B:34:0x00b7, B:36:0x00bd, B:40:0x00cb, B:42:0x00d0, B:43:0x00e0, B:26:0x0092), top: B:51:0x0001 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final synchronized void g(long j8, int i, long j9, int i5, T0.E e8) {
        try {
            int i8 = this.f3783p;
            if (i8 > 0) {
                int iR = r(i8 - 1);
                AbstractC1709a.d(this.f3778k[iR] + ((long) this.f3779l[iR]) <= j9);
            }
            this.f3790w = (536870912 & i) != 0;
            this.f3789v = Math.max(this.f3789v, j8);
            int iR2 = r(this.f3783p);
            this.f3781n[iR2] = j8;
            this.f3778k[iR2] = j9;
            this.f3779l[iR2] = i5;
            this.f3780m[iR2] = i;
            this.f3782o[iR2] = e8;
            this.f3777j[iR2] = this.f3765C;
            if (!(((SparseArray) this.f3771c.f66s).size() == 0)) {
                SparseArray sparseArray = (SparseArray) this.f3771c.f66s;
                if (!((Z) sparseArray.valueAt(sparseArray.size() - 1)).f3754a.equals(this.f3764B)) {
                    C1579o c1579o = this.f3764B;
                    c1579o.getClass();
                    E0.h hVar = this.f3772d;
                    E0.g gVarD = hVar != null ? hVar.d(this.f3773e, c1579o) : E0.g.f1974a;
                    A1.H h8 = this.f3771c;
                    int i9 = this.f3784q + this.f3783p;
                    Z z8 = new Z(c1579o, gVarD);
                    int i10 = h8.f65r;
                    SparseArray sparseArray2 = (SparseArray) h8.f66s;
                    if (i10 == -1) {
                        AbstractC1709a.j(sparseArray2.size() == 0);
                        h8.f65r = 0;
                    }
                    if (sparseArray2.size() > 0) {
                        int iKeyAt = sparseArray2.keyAt(sparseArray2.size() - 1);
                        AbstractC1709a.d(i9 >= iKeyAt);
                        if (iKeyAt == i9) {
                            ((I3.y) h8.f67t).a(sparseArray2.valueAt(sparseArray2.size() - 1));
                        }
                    }
                    sparseArray2.append(i9, z8);
                }
            }
            int i11 = this.f3783p + 1;
            this.f3783p = i11;
            int i12 = this.i;
            if (i11 == i12) {
                int i13 = i12 + 1000;
                long[] jArr = new long[i13];
                long[] jArr2 = new long[i13];
                long[] jArr3 = new long[i13];
                int[] iArr = new int[i13];
                int[] iArr2 = new int[i13];
                T0.E[] eArr = new T0.E[i13];
                int i14 = this.f3785r;
                int i15 = i12 - i14;
                System.arraycopy(this.f3778k, i14, jArr2, 0, i15);
                System.arraycopy(this.f3781n, this.f3785r, jArr3, 0, i15);
                System.arraycopy(this.f3780m, this.f3785r, iArr, 0, i15);
                System.arraycopy(this.f3779l, this.f3785r, iArr2, 0, i15);
                System.arraycopy(this.f3782o, this.f3785r, eArr, 0, i15);
                System.arraycopy(this.f3777j, this.f3785r, jArr, 0, i15);
                int i16 = this.f3785r;
                System.arraycopy(this.f3778k, 0, jArr2, i15, i16);
                System.arraycopy(this.f3781n, 0, jArr3, i15, i16);
                System.arraycopy(this.f3780m, 0, iArr, i15, i16);
                System.arraycopy(this.f3779l, 0, iArr2, i15, i16);
                System.arraycopy(this.f3782o, 0, eArr, i15, i16);
                System.arraycopy(this.f3777j, 0, jArr, i15, i16);
                this.f3778k = jArr2;
                this.f3781n = jArr3;
                this.f3780m = iArr;
                this.f3779l = iArr2;
                this.f3782o = eArr;
                this.f3777j = jArr;
                this.f3785r = 0;
                this.i = i13;
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    public final long h(int i) {
        this.f3788u = Math.max(this.f3788u, p(i));
        this.f3783p -= i;
        int i5 = this.f3784q + i;
        this.f3784q = i5;
        int i8 = this.f3785r + i;
        this.f3785r = i8;
        int i9 = this.i;
        if (i8 >= i9) {
            this.f3785r = i8 - i9;
        }
        int i10 = this.f3786s - i;
        this.f3786s = i10;
        int i11 = 0;
        if (i10 < 0) {
            this.f3786s = 0;
        }
        while (true) {
            A1.H h8 = this.f3771c;
            SparseArray sparseArray = (SparseArray) h8.f66s;
            if (i11 >= sparseArray.size() - 1) {
                break;
            }
            int i12 = i11 + 1;
            if (i5 < sparseArray.keyAt(i12)) {
                break;
            }
            ((I3.y) h8.f67t).a(sparseArray.valueAt(i11));
            sparseArray.removeAt(i11);
            int i13 = h8.f65r;
            if (i13 > 0) {
                h8.f65r = i13 - 1;
            }
            i11 = i12;
        }
        if (this.f3783p != 0) {
            return this.f3778k[this.f3785r];
        }
        int i14 = this.f3785r;
        if (i14 == 0) {
            i14 = this.i;
        }
        int i15 = i14 - 1;
        return this.f3778k[i15] + ((long) this.f3779l[i15]);
    }

    /* JADX WARN: Removed duplicated region for block: B:9:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void i(long j8, boolean z8) throws Throwable {
        Throwable th;
        Y y8 = this.f3769a;
        synchronized (this) {
            try {
                try {
                    int i = this.f3783p;
                    long jH = -1;
                    if (i != 0) {
                        long[] jArr = this.f3781n;
                        int i5 = this.f3785r;
                        if (j8 >= jArr[i5]) {
                            if (z8) {
                                try {
                                    int i8 = this.f3786s;
                                    if (i8 != i) {
                                        i = i8 + 1;
                                    }
                                } catch (Throwable th2) {
                                    th = th2;
                                    throw th;
                                }
                            }
                            int iL = l(i5, i, j8, false);
                            if (iL != -1) {
                                jH = h(iL);
                            }
                        }
                    }
                    y8.b(jH);
                } catch (Throwable th3) {
                    th = th3;
                    th = th;
                    throw th;
                }
            } catch (Throwable th4) {
                th = th4;
                th = th;
                throw th;
            }
        }
    }

    public final void j() {
        long jH;
        Y y8 = this.f3769a;
        synchronized (this) {
            int i = this.f3783p;
            jH = i == 0 ? -1L : h(i);
        }
        y8.b(jH);
    }

    public final long k(int i) {
        int i5 = this.f3784q;
        int i8 = this.f3783p;
        int i9 = (i5 + i8) - i;
        boolean z8 = false;
        AbstractC1709a.d(i9 >= 0 && i9 <= i8 - this.f3786s);
        int i10 = this.f3783p - i9;
        this.f3783p = i10;
        this.f3789v = Math.max(this.f3788u, p(i10));
        if (i9 == 0 && this.f3790w) {
            z8 = true;
        }
        this.f3790w = z8;
        A1.H h8 = this.f3771c;
        SparseArray sparseArray = (SparseArray) h8.f66s;
        for (int size = sparseArray.size() - 1; size >= 0 && i < sparseArray.keyAt(size); size--) {
            ((I3.y) h8.f67t).a(sparseArray.valueAt(size));
            sparseArray.removeAt(size);
        }
        h8.f65r = sparseArray.size() > 0 ? Math.min(h8.f65r, sparseArray.size() - 1) : -1;
        int i11 = this.f3783p;
        if (i11 == 0) {
            return 0L;
        }
        int iR = r(i11 - 1);
        return this.f3778k[iR] + ((long) this.f3779l[iR]);
    }

    public final int l(int i, int i5, long j8, boolean z8) {
        int i8 = -1;
        for (int i9 = 0; i9 < i5; i9++) {
            long j9 = this.f3781n[i];
            if (j9 > j8) {
                break;
            }
            if (!z8 || (this.f3780m[i] & 1) != 0) {
                if (j9 == j8) {
                    return i9;
                }
                i8 = i9;
            }
            i++;
            if (i == this.i) {
                i = 0;
            }
        }
        return i8;
    }

    public C1579o m(C1579o c1579o) {
        if (this.f3767F == 0 || c1579o.f17363s == Long.MAX_VALUE) {
            return c1579o;
        }
        C1578n c1578nA = c1579o.a();
        c1578nA.f17325r = c1579o.f17363s + this.f3767F;
        return new C1579o(c1578nA);
    }

    public final synchronized long n() {
        return this.f3789v;
    }

    public final synchronized long o() {
        return Math.max(this.f3788u, p(this.f3786s));
    }

    public final long p(int i) {
        long jMax = Long.MIN_VALUE;
        if (i == 0) {
            return Long.MIN_VALUE;
        }
        int iR = r(i - 1);
        for (int i5 = 0; i5 < i; i5++) {
            jMax = Math.max(jMax, this.f3781n[iR]);
            if ((this.f3780m[iR] & 1) != 0) {
                return jMax;
            }
            iR--;
            if (iR == -1) {
                iR = this.i - 1;
            }
        }
        return jMax;
    }

    public final int q() {
        return this.f3784q + this.f3786s;
    }

    public final int r(int i) {
        int i5 = this.f3785r + i;
        int i8 = this.i;
        return i5 < i8 ? i5 : i5 - i8;
    }

    public final synchronized int s(long j8, boolean z8) {
        try {
            try {
                int iR = r(this.f3786s);
                int i = this.f3786s;
                int i5 = this.f3783p;
                if (!(i != i5) || j8 < this.f3781n[iR]) {
                    return 0;
                }
                if (j8 > this.f3789v && z8) {
                    return i5 - i;
                }
                int iL = l(iR, i5 - i, j8, true);
                if (iL == -1) {
                    return 0;
                }
                return iL;
            } catch (Throwable th) {
                th = th;
            }
        } catch (Throwable th2) {
            th = th2;
        }
        throw th;
    }

    public final synchronized C1579o t() {
        return this.f3792y ? null : this.f3764B;
    }

    public final synchronized boolean u(boolean z8) {
        C1579o c1579o;
        boolean z9 = false;
        if (this.f3786s != this.f3783p) {
            if (((Z) this.f3771c.g(q())).f3754a != this.f3775g) {
                return true;
            }
            return v(r(this.f3786s));
        }
        if (z8 || this.f3790w || ((c1579o = this.f3764B) != null && c1579o != this.f3775g)) {
            z9 = true;
        }
        return z9;
    }

    public final boolean v(int i) {
        K4.c cVar = this.f3776h;
        if (cVar == null || cVar.A() == 4) {
            return true;
        }
        if ((this.f3780m[i] & 1073741824) != 0) {
            return false;
        }
        this.f3776h.getClass();
        return false;
    }

    public final void w(C1579o c1579o, R0 r02) {
        C1579o c1579o2;
        C1579o c1579o3 = this.f3775g;
        boolean z8 = c1579o3 == null;
        C1575k c1575k = c1579o3 == null ? null : c1579o3.f17362r;
        this.f3775g = c1579o;
        C1575k c1575k2 = c1579o.f17362r;
        E0.h hVar = this.f3772d;
        if (hVar != null) {
            int iO = hVar.o(c1579o);
            C1578n c1578nA = c1579o.a();
            c1578nA.f17308L = iO;
            c1579o2 = new C1579o(c1578nA);
        } else {
            c1579o2 = c1579o;
        }
        r02.f11693s = c1579o2;
        r02.f11692r = this.f3776h;
        if (hVar == null) {
            return;
        }
        if (z8 || !Objects.equals(c1575k, c1575k2)) {
            K4.c cVar = this.f3776h;
            E0.e eVar = this.f3773e;
            K4.c cVarN = hVar.n(eVar, c1579o);
            this.f3776h = cVarN;
            r02.f11692r = cVarN;
            if (cVar != null) {
                cVar.J(eVar);
            }
        }
    }

    public final synchronized long x() {
        try {
        } catch (Throwable th) {
            throw th;
        }
        return this.f3786s != this.f3783p ? this.f3777j[r(this.f3786s)] : this.f3765C;
    }

    public final int y(R0 r02, A0.h hVar, int i, boolean z8) {
        int i5;
        boolean z9 = (i & 2) != 0;
        H0.g gVar = this.f3770b;
        synchronized (this) {
            try {
                hVar.f19v = false;
                i5 = -3;
                if (this.f3786s != this.f3783p) {
                    C1579o c1579o = ((Z) this.f3771c.g(q())).f3754a;
                    if (!z9 && c1579o == this.f3775g) {
                        int iR = r(this.f3786s);
                        if (v(iR)) {
                            hVar.f6r = this.f3780m[iR];
                            if (this.f3786s == this.f3783p - 1 && (z8 || this.f3790w)) {
                                hVar.a(536870912);
                            }
                            hVar.f20w = this.f3781n[iR];
                            gVar.f3049a = this.f3779l[iR];
                            gVar.f3050b = this.f3778k[iR];
                            gVar.f3051c = this.f3782o[iR];
                            i5 = -4;
                        } else {
                            hVar.f19v = true;
                        }
                    }
                    w(c1579o, r02);
                    i5 = -5;
                } else {
                    if (!z8 && !this.f3790w) {
                        C1579o c1579o2 = this.f3764B;
                        if (c1579o2 == null || (!z9 && c1579o2 == this.f3775g)) {
                        }
                        w(c1579o2, r02);
                        i5 = -5;
                    }
                    hVar.f6r = 4;
                    hVar.f20w = Long.MIN_VALUE;
                    i5 = -4;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        if (i5 == -4 && !hVar.d(4)) {
            boolean z10 = (i & 1) != 0;
            if ((i & 4) == 0) {
                if (z10) {
                    Y y8 = this.f3769a;
                    Y.f(y8.f3751e, hVar, this.f3770b, y8.f3749c);
                } else {
                    Y y9 = this.f3769a;
                    y9.f3751e = Y.f(y9.f3751e, hVar, this.f3770b, y9.f3749c);
                }
            }
            if (!z10) {
                this.f3786s++;
            }
        }
        return i5;
    }

    public final void z(boolean z8) {
        A1.H h8;
        SparseArray sparseArray;
        Y y8 = this.f3769a;
        y8.a(y8.f3750d);
        X x8 = y8.f3750d;
        int i = 0;
        AbstractC1709a.j(((P0.a) x8.f3745s) == null);
        x8.f3743q = 0L;
        x8.f3744r = y8.f3748b;
        X x9 = y8.f3750d;
        y8.f3751e = x9;
        y8.f3752f = x9;
        y8.f3753g = 0L;
        y8.f3747a.b();
        this.f3783p = 0;
        this.f3784q = 0;
        this.f3785r = 0;
        this.f3786s = 0;
        this.f3791x = true;
        this.f3787t = Long.MIN_VALUE;
        this.f3788u = Long.MIN_VALUE;
        this.f3789v = Long.MIN_VALUE;
        this.f3790w = false;
        while (true) {
            h8 = this.f3771c;
            sparseArray = (SparseArray) h8.f66s;
            if (i >= sparseArray.size()) {
                break;
            }
            ((I3.y) h8.f67t).a(sparseArray.valueAt(i));
            i++;
        }
        h8.f65r = -1;
        sparseArray.clear();
        if (z8) {
            this.f3763A = null;
            this.f3764B = null;
            this.f3792y = true;
            this.D = true;
        }
    }
}
