package o;

import com.google.android.gms.common.api.Api;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class MF implements T90 {
    public final InterfaceC1687kf l;
    public int m;
    public int n;

    /* renamed from: o, reason: collision with root package name */
    public int f229o;
    public int p;
    public int q;

    public MF(InterfaceC1687kf interfaceC1687kf) {
        this.l = interfaceC1687kf;
    }

    @Override // o.T90
    public final long C(long j, C0732af c0732af) throws IOException {
        int i;
        int i2;
        do {
            int i3 = this.p;
            InterfaceC1687kf interfaceC1687kf = this.l;
            if (i3 == 0) {
                interfaceC1687kf.skip(this.q);
                this.q = 0;
                if ((this.n & 4) == 0) {
                    i = this.f229o;
                    int iS = AbstractC2264qi0.s(interfaceC1687kf);
                    this.p = iS;
                    this.m = iS;
                    int i4 = interfaceC1687kf.readByte() & 255;
                    this.n = interfaceC1687kf.readByte() & 255;
                    Logger logger = NF.f253o;
                    if (logger.isLoggable(Level.FINE)) {
                        C0135Ff c0135Ff = AF.a;
                        logger.fine(AF.a(true, this.f229o, this.m, i4, this.n));
                    }
                    i2 = interfaceC1687kf.readInt() & Api.BaseClientBuilder.API_PRIORITY_OTHER;
                    this.f229o = i2;
                    if (i4 != 9) {
                        throw new IOException(i4 + " != TYPE_CONTINUATION");
                    }
                }
            } else {
                long jC = interfaceC1687kf.C(Math.min(j, i3), c0732af);
                if (jC != -1) {
                    this.p -= (int) jC;
                    return jC;
                }
            }
            return -1L;
        } while (i2 == i);
        throw new IOException("TYPE_CONTINUATION streamId changed");
    }

    @Override // o.T90
    public final Cf0 a() {
        return this.l.a();
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
    }
}
