package h;

import java.io.IOException;
import java.io.OutputStream;

/* JADX INFO: loaded from: classes.dex */
public final class o implements w {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ y f6562b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ OutputStream f6563c;

    public o(y yVar, OutputStream outputStream) {
        this.f6562b = yVar;
        this.f6563c = outputStream;
    }

    @Override // h.w, java.io.Closeable, java.lang.AutoCloseable
    public void close() throws IOException {
        this.f6563c.close();
    }

    @Override // h.w
    public y e() {
        return this.f6562b;
    }

    @Override // h.w, java.io.Flushable
    public void flush() throws IOException {
        this.f6563c.flush();
    }

    @Override // h.w
    public void h(f fVar, long j2) throws IOException {
        z.b(fVar.f6543d, 0L, j2);
        while (j2 > 0) {
            this.f6562b.f();
            t tVar = fVar.f6542c;
            int iMin = (int) Math.min(j2, tVar.f6576c - tVar.f6575b);
            this.f6563c.write(tVar.f6574a, tVar.f6575b, iMin);
            int i2 = tVar.f6575b + iMin;
            tVar.f6575b = i2;
            long j3 = iMin;
            j2 -= j3;
            fVar.f6543d -= j3;
            if (i2 == tVar.f6576c) {
                fVar.f6542c = tVar.a();
                u.a(tVar);
            }
        }
    }

    public String toString() {
        StringBuilder sbC = a.b.c.a.a.C("sink(");
        sbC.append(this.f6563c);
        sbC.append(")");
        return sbC.toString();
    }
}
