package com.google.android.gms.internal.ads;

import android.net.Uri;
import androidx.annotation.Nullable;
import java.io.EOFException;
import java.util.Iterator;
import java.util.Map;

/* JADX INFO: loaded from: classes2.dex */
public final class ho2 implements pp2 {

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

    @Nullable
    private o2 zzb;

    @Nullable
    private p2 zzc;

    public ho2(t2 t2Var) {
        this.f12216a = t2Var;
    }

    public final void a(sv1 sv1Var, Uri uri, Map map, long j10, long j11, q2 q2Var) throws zzyo {
        boolean z10;
        h2 h2Var = new h2(sv1Var, j10, j11);
        this.zzc = h2Var;
        if (this.zzb != null) {
            return;
        }
        o2[] o2VarArrH = this.f12216a.h(uri, map);
        int length = o2VarArrH.length;
        as1 as1VarW = zzguf.w(length);
        boolean z11 = true;
        if (length == 1) {
            this.zzb = o2VarArrH[0];
        } else {
            int i10 = 0;
            while (true) {
                if (i10 >= length) {
                    break;
                }
                o2 o2Var = o2VarArrH[i10];
                try {
                    if (o2Var.a(h2Var)) {
                        this.zzb = o2Var;
                        h2Var.f11992f = 0;
                        break;
                    } else {
                        as1VarW.b(o2Var.zzb());
                        z10 = this.zzb != null || h2Var.f11990d == j10;
                    }
                } catch (EOFException unused) {
                    z10 = this.zzb != null || h2Var.f11990d == j10;
                } catch (Throwable th) {
                    if (this.zzb == null && h2Var.f11990d != j10) {
                        z11 = false;
                    }
                    ih1.b1(z11);
                    h2Var.f11992f = 0;
                    throw th;
                }
                ih1.b1(z10);
                h2Var.f11992f = 0;
                i10++;
            }
            if (this.zzb == null) {
                Iterator it = za2.z(zzguf.t(o2VarArrH), go2.f11819a).iterator();
                StringBuilder sb = new StringBuilder();
                ih1.v0(sb, it, ", ");
                String string = sb.toString();
                throw new zzyo(defpackage.e.p(new StringBuilder(string.length() + 58), "None of the available extractors (", string, ") could read the stream."), as1VarW.g());
            }
        }
        this.zzb.b(q2Var);
    }

    public final void b() {
        o2 o2Var = this.zzb;
        if (o2Var != null) {
            o2Var.zzf();
            this.zzb = null;
        }
        this.zzc = null;
    }

    public final void c() {
        o2 o2Var = this.zzb;
        if (o2Var != null && (o2Var instanceof m6)) {
            ((m6) o2Var).f13977o = true;
        }
    }

    public final long d() {
        p2 p2Var = this.zzc;
        if (p2Var != null) {
            return p2Var.zzn();
        }
        return -1L;
    }

    public final void e(long j10, long j11) {
        o2 o2Var = this.zzb;
        o2Var.getClass();
        o2Var.d(j10, j11);
    }

    public final int f(androidx.media3.extractor.f0 f0Var) {
        p2 p2Var;
        o2 o2Var = this.zzb;
        if (o2Var == null || (p2Var = this.zzc) == null) {
            throw null;
        }
        return o2Var.c(p2Var, f0Var);
    }
}
