package okio;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@kotlin.Metadata(d1 = {"\u0000$\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\b\n\u0018\u00002\u00020\u0001J\u001f\u0010\u0006\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u0006\u0010\u0007J\u000f\u0010\t\u001a\u00020\bH\u0016¢\u0006\u0004\b\t\u0010\nJ\u000f\u0010\f\u001a\u00020\u000bH\u0016¢\u0006\u0004\b\f\u0010\rR\u0014\u0010\f\u001a\u00020\u000b8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u000e\u0010\u000f¨\u0006\u0010"}, d2 = {"okio/Pipe$source$1", "Lokio/Source;", "Lokio/Buffer;", "sink", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "byteCount", "read", "(Lokio/Buffer;J)J", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "close", "()V", "Lokio/Timeout;", "timeout", "()Lokio/Timeout;", "a", "Lokio/Timeout;", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public final class Pipe$source$1 implements okio.Source {

    /* JADX INFO: renamed from: a, reason: from kotlin metadata */
    private final okio.Timeout timeout;
    final /* synthetic */ okio.Pipe b;

    @Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        java.util.concurrent.locks.ReentrantLock lock = this.b.getLock();
        okio.Pipe pipe = this.b;
        lock.lock();
        try {
            pipe.j(true);
            pipe.getCondition().signalAll();
            kotlin.Unit unit = kotlin.Unit.a;
        } finally {
            lock.unlock();
        }
    }

    @Override // okio.Source
    public long read(okio.Buffer sink, long byteCount) {
        kotlin.jvm.internal.Intrinsics.l(sink, "sink");
        java.util.concurrent.locks.ReentrantLock lock = this.b.getLock();
        okio.Pipe pipe = this.b;
        lock.lock();
        try {
            if (pipe.getSourceClosed()) {
                throw new java.lang.IllegalStateException("closed");
            }
            if (pipe.getCanceled()) {
                throw new java.io.IOException("canceled");
            }
            while (pipe.getBuffer().getSize() == 0) {
                if (pipe.getSinkClosed()) {
                    lock.unlock();
                    return -1L;
                }
                this.timeout.awaitSignal(pipe.getCondition());
                if (pipe.getCanceled()) {
                    throw new java.io.IOException("canceled");
                }
            }
            long j = pipe.getBuffer().read(sink, byteCount);
            pipe.getCondition().signalAll();
            lock.unlock();
            return j;
        } catch (java.lang.Throwable th) {
            lock.unlock();
            throw th;
        }
    }

    @Override // okio.Source
    /* JADX INFO: renamed from: timeout, reason: from getter */
    public okio.Timeout getTimeout() {
        return this.timeout;
    }
}
