package com.google.android.exoplayer2.source;

import android.net.Uri;
import com.google.android.exoplayer2.c.e;
import com.google.android.exoplayer2.c.f;
import com.google.android.exoplayer2.c.g;
import com.google.android.exoplayer2.i.v;
import com.tencent.matrix.trace.core.AppMethodBeat;
import java.io.EOFException;

final class f$b {
    private final g aTn;
    private final e[] bhi;
    e bhj;

    public f$b(e[] eVarArr, g gVar) {
        this.bhi = eVarArr;
        this.aTn = gVar;
    }

    public final e a(f fVar, Uri uri) {
        AppMethodBeat.i(95482);
        e eVar;
        if (this.bhj != null) {
            eVar = this.bhj;
            AppMethodBeat.o(95482);
            return eVar;
        }
        e[] eVarArr = this.bhi;
        int length = eVarArr.length;
        int i = 0;
        while (i < length) {
            e eVar2 = eVarArr[i];
            try {
                if (eVar2.a(fVar)) {
                    this.bhj = eVar2;
                    fVar.qY();
                    break;
                }
                fVar.qY();
                i++;
            } catch (EOFException e) {
                fVar.qY();
            } catch (Throwable th) {
                fVar.qY();
                AppMethodBeat.o(95482);
            }
        }
        if (this.bhj == null) {
            q qVar = new q("None of the available extractors (" + v.d(this.bhi) + ") could read the stream.", uri);
            AppMethodBeat.o(95482);
            throw qVar;
        }
        this.bhj.a(this.aTn);
        eVar = this.bhj;
        AppMethodBeat.o(95482);
        return eVar;
    }
}
