package R4;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import r4.AbstractC0983h;

/* JADX INFO: loaded from: classes.dex */
public final class t implements X4.u {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final X4.o f2735k;

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

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

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

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

    public t(X4.o oVar) {
        AbstractC0983h.e("source", oVar);
        this.f2735k = oVar;
    }

    @Override // X4.u
    public final X4.w d() {
        return this.f2735k.f3341k.d();
    }

    @Override // X4.u
    public final long p(X4.e eVar, long j5) throws IOException {
        int i;
        int iK;
        AbstractC0983h.e("sink", eVar);
        do {
            int i5 = this.f2739o;
            X4.o oVar = this.f2735k;
            if (i5 == 0) {
                oVar.t(this.p);
                this.p = 0;
                if ((this.f2737m & 4) == 0) {
                    i = this.f2738n;
                    int iQ = L4.b.q(oVar);
                    this.f2739o = iQ;
                    this.f2736l = iQ;
                    int iF = oVar.f() & 255;
                    this.f2737m = oVar.f() & 255;
                    Logger logger = u.f2740n;
                    if (logger.isLoggable(Level.FINE)) {
                        X4.h hVar = g.f2679a;
                        logger.fine(g.a(true, this.f2738n, this.f2736l, iF, this.f2737m));
                    }
                    iK = oVar.k() & Integer.MAX_VALUE;
                    this.f2738n = iK;
                    if (iF != 9) {
                        throw new IOException(iF + " != TYPE_CONTINUATION");
                    }
                }
            } else {
                long jP = oVar.p(eVar, Math.min(8192L, i5));
                if (jP != -1) {
                    this.f2739o -= (int) jP;
                    return jP;
                }
            }
            return -1L;
        } while (iK == i);
        throw new IOException("TYPE_CONTINUATION streamId changed");
    }

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