package defpackage;

import androidx.media3.exoplayer.drm.DrmSession$DrmSessionException;
import androidx.media3.exoplayer.hls.SampleQueueMappingException;
import androidx.media3.exoplayer.source.BehindLiveWindowException;
import java.util.ArrayList;

/* renamed from: ᵙᵤ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2606 implements InterfaceC0772 {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final C1755 f10087;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final int f10088;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public int f10089 = -1;

    public C2606(C1755 c1755, int i) {
        this.f10087 = c1755;
        this.f10088 = i;
    }

    @Override // defpackage.InterfaceC0772
    /* renamed from: ˇʼʤˎ */
    public final int mo1125(C2720 c2720, C2441 c2441, int i) {
        C3446 c3446;
        if (this.f10089 == -3) {
            c2441.m9874(4);
            return -4;
        }
        if (m6556()) {
            int i2 = this.f10089;
            C1755 c1755 = this.f10087;
            ArrayList arrayList = c1755.f7022;
            if (!c1755.m4986()) {
                int i3 = 0;
                if (!arrayList.isEmpty()) {
                    int i4 = 0;
                    loop0: while (i4 < arrayList.size() - 1) {
                        int i5 = ((C3508) arrayList.get(i4)).f13148;
                        int length = c1755.f7009.length;
                        for (int i6 = 0; i6 < length; i6++) {
                            if (c1755.f7011[i6] && c1755.f7009[i6].m4764() == i5) {
                                break loop0;
                            }
                        }
                        i4++;
                    }
                    AbstractC3558.m8102(arrayList, 0, i4);
                    C3508 c3508 = (C3508) arrayList.get(0);
                    C3446 c34462 = c3508.f15966;
                    if (!c34462.equals(c1755.f7014)) {
                        c1755.f7040.m10098(c1755.f7031, c34462, c3508.f15964, c3508.f15962, c3508.f15959);
                    }
                    c1755.f7014 = c34462;
                }
                if (arrayList.isEmpty() || ((C3508) arrayList.get(0)).m8021()) {
                    int iM4780 = c1755.f7009[i2].m4780(c2720, c2441, i, c1755.f7003);
                    if (iM4780 == -5) {
                        C3446 c3446M7831 = (C3446) c2720.f10550;
                        c3446M7831.getClass();
                        if (i2 == c1755.f7013) {
                            int i7 = ˁˈᵸ.ˎˏʜʾ(c1755.f7009[i2].m4764());
                            while (i3 < arrayList.size() && ((C3508) arrayList.get(i3)).f13148 != i7) {
                                i3++;
                            }
                            if (i3 < arrayList.size()) {
                                c3446 = ((C3508) arrayList.get(i3)).f15966;
                            } else {
                                c3446 = c1755.f7007;
                                c3446.getClass();
                            }
                            c3446M7831 = c3446M7831.m7831(c3446);
                        }
                        c2720.f10550 = c3446M7831;
                    }
                    return iM4780;
                }
            }
        }
        return -3;
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x0042  */
    @Override // defpackage.InterfaceC0772
    /* renamed from: ˌᵜᵹᵩ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final int mo1126(long r4) {
        /*
            r3 = this;
            boolean r0 = r3.m6556()
            if (r0 == 0) goto L5e
            int r0 = r3.f10089
            ˎᵟ r3 = r3.f10087
            boolean r1 = r3.m4986()
            if (r1 == 0) goto L11
            goto L5e
        L11:
            ˌﹶ[] r1 = r3.f7009
            r1 = r1[r0]
            boolean r2 = r3.f7003
            int r4 = r1.m4789(r2, r4)
            java.util.ArrayList r3 = r3.f7022
            if (r3 == 0) goto L2c
            boolean r5 = r3.isEmpty()
            if (r5 == 0) goto L26
            goto L42
        L26:
            r5 = 1
            java.lang.Object r3 = defpackage.AbstractC1327.m4111(r5, r3)
            goto L43
        L2c:
            java.util.Iterator r3 = r3.iterator()
            boolean r5 = r3.hasNext()
            if (r5 == 0) goto L42
        L36:
            java.lang.Object r5 = r3.next()
            boolean r2 = r3.hasNext()
            if (r2 != 0) goto L36
            r3 = r5
            goto L43
        L42:
            r3 = 0
        L43:
            ᵥˑ r3 = (defpackage.C3508) r3
            if (r3 == 0) goto L5a
            boolean r5 = r3.m8021()
            if (r5 != 0) goto L5a
            int r5 = r1.m4777()
            int r3 = r3.m8020(r0)
            int r3 = r3 - r5
            int r4 = java.lang.Math.min(r4, r3)
        L5a:
            r1.m4768(r4)
            return r4
        L5e:
            r3 = 0
            return r3
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C2606.mo1126(long):int");
    }

    /* JADX WARN: Removed duplicated region for block: B:11:0x002f  */
    /* renamed from: ˏᵙ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void m6555() {
        /*
            r6 = this;
            int r0 = r6.f10089
            r1 = 1
            r2 = -1
            if (r0 != r2) goto L8
            r0 = r1
            goto L9
        L8:
            r0 = 0
        L9:
            ᵛᵾˏ.ᵯٴᵦ(r0)
            ˎᵟ r0 = r6.f10087
            r0.m4989()
            int[] r3 = r0.f7005
            r3.getClass()
            int[] r3 = r0.f7005
            int r4 = r6.f10088
            r3 = r3[r4]
            r5 = -2
            if (r3 != r2) goto L31
            java.util.Set r1 = r0.f7026
            ʼˋ r0 = r0.f7017
            ᵬʢ r0 = r0.m1103(r4)
            boolean r0 = r1.contains(r0)
            if (r0 == 0) goto L2f
            r3 = -3
            goto L3a
        L2f:
            r3 = r5
            goto L3a
        L31:
            boolean[] r0 = r0.f7011
            boolean r2 = r0[r3]
            if (r2 == 0) goto L38
            goto L2f
        L38:
            r0[r3] = r1
        L3a:
            r6.f10089 = r3
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C2606.m6555():void");
    }

    @Override // defpackage.InterfaceC0772
    /* renamed from: ᵥᵯˎ */
    public final boolean mo1128() {
        if (this.f10089 == -3) {
            return true;
        }
        if (!m6556()) {
            return false;
        }
        int i = this.f10089;
        C1755 c1755 = this.f10087;
        return !c1755.m4986() && c1755.f7009[i].m4773(c1755.f7003);
    }

    @Override // defpackage.InterfaceC0772
    /* renamed from: ᵴᵳ */
    public final void mo1129() throws BehindLiveWindowException, DrmSession$DrmSessionException, SampleQueueMappingException {
        int i = this.f10089;
        C1755 c1755 = this.f10087;
        if (i == -2) {
            c1755.m4989();
            throw new SampleQueueMappingException(AbstractC4486.m9550("Unable to bind a sample queue to TrackGroup with MIME type ", c1755.f7017.m1103(this.f10088).f15079[0].f12929, "."));
        }
        if (i == -1) {
            c1755.m4983();
        } else if (i != -3) {
            c1755.m4983();
            c1755.f7009[i].m4772();
        }
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final boolean m6556() {
        int i = this.f10089;
        return (i == -1 || i == -3 || i == -2) ? false : true;
    }
}
