package okhttp3.internal.http2;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@kotlin.Metadata(d1 = {"\u0000\u008a\u0001\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\t\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0010\u0002\n\u0002\b\f\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0006\u0018\u0000 _2\u00020\u0001:\u0004_`abB1\b\u0000\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\u0006\u0010\b\u001a\u00020\u0007\u0012\b\u0010\t\u001a\u0004\u0018\u00010\n¢\u0006\u0002\u0010\u000bJ\u000e\u0010@\u001a\u00020A2\u0006\u0010B\u001a\u00020#J\r\u0010C\u001a\u00020AH\u0000¢\u0006\u0002\bDJ\r\u0010E\u001a\u00020AH\u0000¢\u0006\u0002\bFJ\u0018\u0010G\u001a\u00020A2\u0006\u0010H\u001a\u00020\u000f2\b\u0010\u0014\u001a\u0004\u0018\u00010\u0015J\u001a\u0010I\u001a\u00020\u00072\u0006\u0010\u000e\u001a\u00020\u000f2\b\u0010\u0014\u001a\u0004\u0018\u00010\u0015H\u0002J\u000e\u0010J\u001a\u00020A2\u0006\u0010\u000e\u001a\u00020\u000fJ\u000e\u0010K\u001a\u00020A2\u0006\u0010L\u001a\u00020\nJ\u0006\u0010M\u001a\u00020NJ\u0006\u0010O\u001a\u00020PJ\u0006\u0010,\u001a\u00020QJ\u0016\u0010R\u001a\u00020A2\u0006\u00104\u001a\u00020S2\u0006\u0010T\u001a\u00020\u0003J\u0016\u0010U\u001a\u00020A2\u0006\u0010\t\u001a\u00020\n2\u0006\u0010\b\u001a\u00020\u0007J\u000e\u0010V\u001a\u00020A2\u0006\u0010\u000e\u001a\u00020\u000fJ\u0006\u0010W\u001a\u00020\nJ\u0006\u0010L\u001a\u00020\nJ\r\u0010X\u001a\u00020AH\u0000¢\u0006\u0002\bYJ$\u0010Z\u001a\u00020A2\f\u0010[\u001a\b\u0012\u0004\u0012\u00020]0\\2\u0006\u0010\u0006\u001a\u00020\u00072\u0006\u0010^\u001a\u00020\u0007J\u0006\u0010>\u001a\u00020QR\u0011\u0010\u0004\u001a\u00020\u0005¢\u0006\b\n\u0000\u001a\u0004\b\f\u0010\rR\u001e\u0010\u000e\u001a\u0004\u0018\u00010\u000f8@X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0010\u0010\u0011\"\u0004\b\u0012\u0010\u0013R\u001c\u0010\u0014\u001a\u0004\u0018\u00010\u0015X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0016\u0010\u0017\"\u0004\b\u0018\u0010\u0019R\u000e\u0010\u001a\u001a\u00020\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u001b\u001a\b\u0012\u0004\u0012\u00020\n0\u001cX\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u001d\u0010\u001eR\u0011\u0010\u001f\u001a\u00020\u00078F¢\u0006\u0006\u001a\u0004\b\u001f\u0010 R\u0011\u0010!\u001a\u00020\u00078F¢\u0006\u0006\u001a\u0004\b!\u0010 R$\u0010$\u001a\u00020#2\u0006\u0010\"\u001a\u00020#@@X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b%\u0010&\"\u0004\b'\u0010(R$\u0010)\u001a\u00020#2\u0006\u0010\"\u001a\u00020#@@X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b*\u0010&\"\u0004\b+\u0010(R\u0018\u0010,\u001a\u00060-R\u00020\u0000X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b.\u0010/R\u0018\u00100\u001a\u000601R\u00020\u0000X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b2\u00103R\u0018\u00104\u001a\u000605R\u00020\u0000X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b6\u00107R$\u00108\u001a\u00020#2\u0006\u0010\"\u001a\u00020#@@X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b9\u0010&\"\u0004\b:\u0010(R$\u0010;\u001a\u00020#2\u0006\u0010\"\u001a\u00020#@@X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b<\u0010&\"\u0004\b=\u0010(R\u0018\u0010>\u001a\u00060-R\u00020\u0000X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b?\u0010/¨\u0006c"}, d2 = {"Lokhttp3/internal/http2/Http2Stream;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "id", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "connection", "Lokhttp3/internal/http2/Http2Connection;", "outFinished", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "inFinished", "headers", "Lokhttp3/Headers;", "(ILokhttp3/internal/http2/Http2Connection;ZZLokhttp3/Headers;)V", "getConnection", "()Lokhttp3/internal/http2/Http2Connection;", "errorCode", "Lokhttp3/internal/http2/ErrorCode;", "getErrorCode$okhttp", "()Lokhttp3/internal/http2/ErrorCode;", "setErrorCode$okhttp", "(Lokhttp3/internal/http2/ErrorCode;)V", "errorException", "Ljava/io/IOException;", "getErrorException$okhttp", "()Ljava/io/IOException;", "setErrorException$okhttp", "(Ljava/io/IOException;)V", "hasResponseHeaders", "headersQueue", "Ljava/util/ArrayDeque;", "getId", "()I", "isLocallyInitiated", "()Z", "isOpen", "<set-?>", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "readBytesAcknowledged", "getReadBytesAcknowledged", "()J", "setReadBytesAcknowledged$okhttp", "(J)V", "readBytesTotal", "getReadBytesTotal", "setReadBytesTotal$okhttp", "readTimeout", "Lokhttp3/internal/http2/Http2Stream$StreamTimeout;", "getReadTimeout$okhttp", "()Lokhttp3/internal/http2/Http2Stream$StreamTimeout;", "sink", "Lokhttp3/internal/http2/Http2Stream$FramingSink;", "getSink$okhttp", "()Lokhttp3/internal/http2/Http2Stream$FramingSink;", "source", "Lokhttp3/internal/http2/Http2Stream$FramingSource;", "getSource$okhttp", "()Lokhttp3/internal/http2/Http2Stream$FramingSource;", "writeBytesMaximum", "getWriteBytesMaximum", "setWriteBytesMaximum$okhttp", "writeBytesTotal", "getWriteBytesTotal", "setWriteBytesTotal$okhttp", "writeTimeout", "getWriteTimeout$okhttp", "addBytesToWriteWindow", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "delta", "cancelStreamIfNecessary", "cancelStreamIfNecessary$okhttp", "checkOutNotClosed", "checkOutNotClosed$okhttp", "close", "rstStatusCode", "closeInternal", "closeLater", "enqueueTrailers", "trailers", "getSink", "Lokio/Sink;", "getSource", "Lokio/Source;", "Lokio/Timeout;", "receiveData", "Lokio/BufferedSource;", "length", "receiveHeaders", "receiveRstStream", "takeHeaders", "waitForIo", "waitForIo$okhttp", "writeHeaders", "responseHeaders", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "Lokhttp3/internal/http2/Header;", "flushHeaders", "Companion", "FramingSink", "FramingSource", "StreamTimeout", "okhttp"}, k = 1, mv = {1, 8, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public final class Http2Stream {
    public static final long EMIT_BUFFER_SIZE = 16384;

    @org.jetbrains.annotations.NotNull
    private final okhttp3.internal.http2.Http2Connection connection;

    @org.jetbrains.annotations.Nullable
    private okhttp3.internal.http2.ErrorCode errorCode;

    @org.jetbrains.annotations.Nullable
    private java.io.IOException errorException;
    private boolean hasResponseHeaders;

    @org.jetbrains.annotations.NotNull
    private final java.util.ArrayDeque<okhttp3.Headers> headersQueue;
    private final int id;
    private long readBytesAcknowledged;
    private long readBytesTotal;

    @org.jetbrains.annotations.NotNull
    private final okhttp3.internal.http2.Http2Stream.StreamTimeout readTimeout;

    @org.jetbrains.annotations.NotNull
    private final okhttp3.internal.http2.Http2Stream.FramingSink sink;

    @org.jetbrains.annotations.NotNull
    private final okhttp3.internal.http2.Http2Stream.FramingSource source;
    private long writeBytesMaximum;
    private long writeBytesTotal;

    @org.jetbrains.annotations.NotNull
    private final okhttp3.internal.http2.Http2Stream.StreamTimeout writeTimeout;

    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(d1 = {"\u0000@\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u000b\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0086\u0004\u0018\u00002\u00020\u0001B\u0017\b\u0000\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\b\u0010\u001a\u001a\u00020\u001bH\u0016J\u0018\u0010\u001c\u001a\u00020\u00032\u0006\u0010\u001d\u001a\u00020\u000f2\u0006\u0010\u001e\u001a\u00020\u0003H\u0016J\u001d\u0010\u001f\u001a\u00020\u001b2\u0006\u0010 \u001a\u00020!2\u0006\u0010\u001e\u001a\u00020\u0003H\u0000¢\u0006\u0002\b\"J\b\u0010#\u001a\u00020$H\u0016J\u0010\u0010%\u001a\u00020\u001b2\u0006\u0010\u001c\u001a\u00020\u0003H\u0002R\u001a\u0010\u0007\u001a\u00020\u0005X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\b\u0010\t\"\u0004\b\n\u0010\u000bR\u001a\u0010\u0004\u001a\u00020\u0005X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\f\u0010\t\"\u0004\b\r\u0010\u000bR\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u0011\u0010\u000e\u001a\u00020\u000f¢\u0006\b\n\u0000\u001a\u0004\b\u0010\u0010\u0011R\u0011\u0010\u0012\u001a\u00020\u000f¢\u0006\b\n\u0000\u001a\u0004\b\u0013\u0010\u0011R\u001c\u0010\u0014\u001a\u0004\u0018\u00010\u0015X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0016\u0010\u0017\"\u0004\b\u0018\u0010\u0019¨\u0006&"}, d2 = {"Lokhttp3/internal/http2/Http2Stream$FramingSource;", "Lokio/Source;", "maxByteCount", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "finished", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "(Lokhttp3/internal/http2/Http2Stream;JZ)V", "closed", "getClosed$okhttp", "()Z", "setClosed$okhttp", "(Z)V", "getFinished$okhttp", "setFinished$okhttp", "readBuffer", "Lokio/Buffer;", "getReadBuffer", "()Lokio/Buffer;", "receiveBuffer", "getReceiveBuffer", "trailers", "Lokhttp3/Headers;", "getTrailers", "()Lokhttp3/Headers;", "setTrailers", "(Lokhttp3/Headers;)V", "close", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "read", "sink", "byteCount", "receive", "source", "Lokio/BufferedSource;", "receive$okhttp", "timeout", "Lokio/Timeout;", "updateConnectionFlowControl", "okhttp"}, k = 1, mv = {1, 8, 0}, xi = 48)
    @kotlin.jvm.internal.SourceDebugExtension
    public final class FramingSource implements okio.Source {
        private boolean closed;
        private boolean finished;
        private final long maxByteCount;

        @org.jetbrains.annotations.Nullable
        private okhttp3.Headers trailers;

        @org.jetbrains.annotations.NotNull
        private final okio.Buffer receiveBuffer = new okio.Buffer();

        @org.jetbrains.annotations.NotNull
        private final okio.Buffer readBuffer = new okio.Buffer();

        public FramingSource(long j, boolean z) {
            this.maxByteCount = j;
            this.finished = z;
        }

        private final void updateConnectionFlowControl(long read) {
            okhttp3.internal.http2.Http2Stream http2Stream = okhttp3.internal.http2.Http2Stream.this;
            if (!okhttp3.internal.Util.assertionsEnabled || !java.lang.Thread.holdsLock(http2Stream)) {
                okhttp3.internal.http2.Http2Stream.this.getConnection().updateConnectionFlowControl$okhttp(read);
                return;
            }
            throw new java.lang.AssertionError("Thread " + java.lang.Thread.currentThread().getName() + " MUST NOT hold lock on " + http2Stream);
        }

        @Override // okio.Source, java.io.Closeable, java.lang.AutoCloseable
        public void close() throws java.io.IOException {
            long size;
            okhttp3.internal.http2.Http2Stream http2Stream = okhttp3.internal.http2.Http2Stream.this;
            synchronized (http2Stream) {
                this.closed = true;
                size = this.readBuffer.getSize();
                this.readBuffer.clear();
                kotlin.jvm.internal.Intrinsics.j(http2Stream, "null cannot be cast to non-null type java.lang.Object");
                http2Stream.notifyAll();
                kotlin.Unit unit = kotlin.Unit.a;
            }
            if (size > 0) {
                updateConnectionFlowControl(size);
            }
            okhttp3.internal.http2.Http2Stream.this.cancelStreamIfNecessary$okhttp();
        }

        /* JADX INFO: renamed from: getClosed$okhttp, reason: from getter */
        public final boolean getClosed() {
            return this.closed;
        }

        /* JADX INFO: renamed from: getFinished$okhttp, reason: from getter */
        public final boolean getFinished() {
            return this.finished;
        }

        @org.jetbrains.annotations.NotNull
        public final okio.Buffer getReadBuffer() {
            return this.readBuffer;
        }

        @org.jetbrains.annotations.NotNull
        public final okio.Buffer getReceiveBuffer() {
            return this.receiveBuffer;
        }

        @org.jetbrains.annotations.Nullable
        public final okhttp3.Headers getTrailers() {
            return this.trailers;
        }

        @Override // okio.Source
        public long read(@org.jetbrains.annotations.NotNull okio.Buffer sink, long byteCount) throws java.io.IOException {
            java.io.IOException errorException;
            boolean z;
            long j;
            kotlin.jvm.internal.Intrinsics.l(sink, "sink");
            long j2 = 0;
            if (byteCount < 0) {
                throw new java.lang.IllegalArgumentException(("byteCount < 0: " + byteCount).toString());
            }
            while (true) {
                okhttp3.internal.http2.Http2Stream http2Stream = okhttp3.internal.http2.Http2Stream.this;
                synchronized (http2Stream) {
                    http2Stream.getReadTimeout().enter();
                    try {
                        if (http2Stream.getErrorCode$okhttp() == null || this.finished) {
                            errorException = null;
                        } else {
                            errorException = http2Stream.getErrorException();
                            if (errorException == null) {
                                okhttp3.internal.http2.ErrorCode errorCode$okhttp = http2Stream.getErrorCode$okhttp();
                                kotlin.jvm.internal.Intrinsics.i(errorCode$okhttp);
                                errorException = new okhttp3.internal.http2.StreamResetException(errorCode$okhttp);
                            }
                        }
                        if (this.closed) {
                            throw new java.io.IOException("stream closed");
                        }
                        z = false;
                        if (this.readBuffer.getSize() > j2) {
                            okio.Buffer buffer = this.readBuffer;
                            j = buffer.read(sink, java.lang.Math.min(byteCount, buffer.getSize()));
                            http2Stream.setReadBytesTotal$okhttp(http2Stream.getReadBytesTotal() + j);
                            long readBytesTotal = http2Stream.getReadBytesTotal() - http2Stream.getReadBytesAcknowledged();
                            if (errorException == null && readBytesTotal >= http2Stream.getConnection().getOkHttpSettings().getInitialWindowSize() / 2) {
                                http2Stream.getConnection().writeWindowUpdateLater$okhttp(http2Stream.getId(), readBytesTotal);
                                http2Stream.setReadBytesAcknowledged$okhttp(http2Stream.getReadBytesTotal());
                            }
                        } else {
                            if (!this.finished && errorException == null) {
                                http2Stream.waitForIo$okhttp();
                                z = true;
                            }
                            j = -1;
                        }
                        http2Stream.getReadTimeout().exitAndThrowIfTimedOut();
                        kotlin.Unit unit = kotlin.Unit.a;
                    } catch (java.lang.Throwable th) {
                        http2Stream.getReadTimeout().exitAndThrowIfTimedOut();
                        throw th;
                    }
                    throw th;
                }
                if (!z) {
                    if (j != -1) {
                        return j;
                    }
                    if (errorException == null) {
                        return -1L;
                    }
                    throw errorException;
                }
                j2 = 0;
            }
        }

        public final void receive$okhttp(@org.jetbrains.annotations.NotNull okio.BufferedSource source, long byteCount) throws java.io.IOException {
            boolean z;
            boolean z4;
            kotlin.jvm.internal.Intrinsics.l(source, "source");
            okhttp3.internal.http2.Http2Stream http2Stream = okhttp3.internal.http2.Http2Stream.this;
            if (okhttp3.internal.Util.assertionsEnabled && java.lang.Thread.holdsLock(http2Stream)) {
                throw new java.lang.AssertionError("Thread " + java.lang.Thread.currentThread().getName() + " MUST NOT hold lock on " + http2Stream);
            }
            long j = byteCount;
            while (j > 0) {
                synchronized (okhttp3.internal.http2.Http2Stream.this) {
                    z = this.finished;
                    z4 = this.readBuffer.getSize() + j > this.maxByteCount;
                    kotlin.Unit unit = kotlin.Unit.a;
                }
                if (z4) {
                    source.skip(j);
                    okhttp3.internal.http2.Http2Stream.this.closeLater(okhttp3.internal.http2.ErrorCode.FLOW_CONTROL_ERROR);
                    return;
                }
                if (z) {
                    source.skip(j);
                    return;
                }
                long j2 = source.read(this.receiveBuffer, j);
                if (j2 == -1) {
                    throw new java.io.EOFException();
                }
                j -= j2;
                okhttp3.internal.http2.Http2Stream http2Stream2 = okhttp3.internal.http2.Http2Stream.this;
                synchronized (http2Stream2) {
                    try {
                        if (this.closed) {
                            this.receiveBuffer.clear();
                        } else {
                            boolean z5 = this.readBuffer.getSize() == 0;
                            this.readBuffer.L1(this.receiveBuffer);
                            if (z5) {
                                kotlin.jvm.internal.Intrinsics.j(http2Stream2, "null cannot be cast to non-null type java.lang.Object");
                                http2Stream2.notifyAll();
                            }
                        }
                    } catch (java.lang.Throwable th) {
                        throw th;
                    }
                }
            }
            updateConnectionFlowControl(byteCount);
        }

        public final void setClosed$okhttp(boolean z) {
            this.closed = z;
        }

        public final void setFinished$okhttp(boolean z) {
            this.finished = z;
        }

        public final void setTrailers(@org.jetbrains.annotations.Nullable okhttp3.Headers headers) {
            this.trailers = headers;
        }

        @Override // okio.Source
        @org.jetbrains.annotations.NotNull
        /* JADX INFO: renamed from: timeout */
        public okio.Timeout getTimeout() {
            return okhttp3.internal.http2.Http2Stream.this.getReadTimeout();
        }
    }

    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0080\u0004\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0006\u0010\u0003\u001a\u00020\u0004J\u0012\u0010\u0005\u001a\u00020\u00062\b\u0010\u0007\u001a\u0004\u0018\u00010\u0006H\u0014J\b\u0010\b\u001a\u00020\u0004H\u0014¨\u0006\t"}, d2 = {"Lokhttp3/internal/http2/Http2Stream$StreamTimeout;", "Lokio/AsyncTimeout;", "(Lokhttp3/internal/http2/Http2Stream;)V", "exitAndThrowIfTimedOut", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "newTimeoutException", "Ljava/io/IOException;", "cause", "timedOut", "okhttp"}, k = 1, mv = {1, 8, 0}, xi = 48)
    public final class StreamTimeout extends okio.AsyncTimeout {
        public StreamTimeout() {
        }

        public final void exitAndThrowIfTimedOut() throws java.io.IOException {
            if (exit()) {
                throw newTimeoutException(null);
            }
        }

        @Override // okio.AsyncTimeout
        @org.jetbrains.annotations.NotNull
        protected java.io.IOException newTimeoutException(@org.jetbrains.annotations.Nullable java.io.IOException cause) {
            java.net.SocketTimeoutException socketTimeoutException = new java.net.SocketTimeoutException("timeout");
            if (cause != null) {
                socketTimeoutException.initCause(cause);
            }
            return socketTimeoutException;
        }

        @Override // okio.AsyncTimeout
        protected void timedOut() {
            okhttp3.internal.http2.Http2Stream.this.closeLater(okhttp3.internal.http2.ErrorCode.CANCEL);
            okhttp3.internal.http2.Http2Stream.this.getConnection().sendDegradedPingLater$okhttp();
        }
    }

    public Http2Stream(int i, @org.jetbrains.annotations.NotNull okhttp3.internal.http2.Http2Connection http2Connection, boolean z, boolean z4, @org.jetbrains.annotations.Nullable okhttp3.Headers headers) {
        kotlin.jvm.internal.Intrinsics.l(http2Connection, "connection");
        this.id = i;
        this.connection = http2Connection;
        this.writeBytesMaximum = http2Connection.getPeerSettings().getInitialWindowSize();
        java.util.ArrayDeque<okhttp3.Headers> arrayDeque = new java.util.ArrayDeque<>();
        this.headersQueue = arrayDeque;
        this.source = new okhttp3.internal.http2.Http2Stream.FramingSource(http2Connection.getOkHttpSettings().getInitialWindowSize(), z4);
        this.sink = new okhttp3.internal.http2.Http2Stream.FramingSink(z);
        this.readTimeout = new okhttp3.internal.http2.Http2Stream.StreamTimeout();
        this.writeTimeout = new okhttp3.internal.http2.Http2Stream.StreamTimeout();
        if (headers == null) {
            if (!isLocallyInitiated()) {
                throw new java.lang.IllegalStateException("remotely-initiated streams should have headers");
            }
        } else {
            if (isLocallyInitiated()) {
                throw new java.lang.IllegalStateException("locally-initiated streams shouldn't have headers yet");
            }
            arrayDeque.add(headers);
        }
    }

    private final boolean closeInternal(okhttp3.internal.http2.ErrorCode errorCode, java.io.IOException errorException) {
        if (okhttp3.internal.Util.assertionsEnabled && java.lang.Thread.holdsLock(this)) {
            throw new java.lang.AssertionError("Thread " + java.lang.Thread.currentThread().getName() + " MUST NOT hold lock on " + this);
        }
        synchronized (this) {
            if (this.errorCode != null) {
                return false;
            }
            this.errorCode = errorCode;
            this.errorException = errorException;
            kotlin.jvm.internal.Intrinsics.j(this, "null cannot be cast to non-null type java.lang.Object");
            notifyAll();
            if (this.source.getFinished() && this.sink.getFinished()) {
                return false;
            }
            kotlin.Unit unit = kotlin.Unit.a;
            this.connection.removeStream$okhttp(this.id);
            return true;
        }
    }

    public final void addBytesToWriteWindow(long delta) {
        this.writeBytesMaximum += delta;
        if (delta > 0) {
            kotlin.jvm.internal.Intrinsics.j(this, "null cannot be cast to non-null type java.lang.Object");
            notifyAll();
        }
    }

    public final void cancelStreamIfNecessary$okhttp() throws java.io.IOException {
        boolean z;
        boolean zIsOpen;
        if (okhttp3.internal.Util.assertionsEnabled && java.lang.Thread.holdsLock(this)) {
            throw new java.lang.AssertionError("Thread " + java.lang.Thread.currentThread().getName() + " MUST NOT hold lock on " + this);
        }
        synchronized (this) {
            try {
                z = !this.source.getFinished() && this.source.getClosed() && (this.sink.getFinished() || this.sink.getClosed());
                zIsOpen = isOpen();
                kotlin.Unit unit = kotlin.Unit.a;
            } catch (java.lang.Throwable th) {
                throw th;
            }
        }
        if (z) {
            close(okhttp3.internal.http2.ErrorCode.CANCEL, null);
        } else {
            if (zIsOpen) {
                return;
            }
            this.connection.removeStream$okhttp(this.id);
        }
    }

    public final void checkOutNotClosed$okhttp() throws java.io.IOException {
        if (this.sink.getClosed()) {
            throw new java.io.IOException("stream closed");
        }
        if (this.sink.getFinished()) {
            throw new java.io.IOException("stream finished");
        }
        if (this.errorCode != null) {
            java.io.IOException iOException = this.errorException;
            if (iOException != null) {
                throw iOException;
            }
            okhttp3.internal.http2.ErrorCode errorCode = this.errorCode;
            kotlin.jvm.internal.Intrinsics.i(errorCode);
            throw new okhttp3.internal.http2.StreamResetException(errorCode);
        }
    }

    public final void close(@org.jetbrains.annotations.NotNull okhttp3.internal.http2.ErrorCode rstStatusCode, @org.jetbrains.annotations.Nullable java.io.IOException errorException) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(rstStatusCode, "rstStatusCode");
        if (closeInternal(rstStatusCode, errorException)) {
            this.connection.writeSynReset$okhttp(this.id, rstStatusCode);
        }
    }

    public final void closeLater(@org.jetbrains.annotations.NotNull okhttp3.internal.http2.ErrorCode errorCode) {
        kotlin.jvm.internal.Intrinsics.l(errorCode, "errorCode");
        if (closeInternal(errorCode, null)) {
            this.connection.writeSynResetLater$okhttp(this.id, errorCode);
        }
    }

    public final void enqueueTrailers(@org.jetbrains.annotations.NotNull okhttp3.Headers trailers) {
        kotlin.jvm.internal.Intrinsics.l(trailers, "trailers");
        synchronized (this) {
            if (this.sink.getFinished()) {
                throw new java.lang.IllegalStateException("already finished");
            }
            if (trailers.size() == 0) {
                throw new java.lang.IllegalArgumentException("trailers.size() == 0");
            }
            this.sink.setTrailers(trailers);
            kotlin.Unit unit = kotlin.Unit.a;
        }
    }

    @org.jetbrains.annotations.NotNull
    public final okhttp3.internal.http2.Http2Connection getConnection() {
        return this.connection;
    }

    @org.jetbrains.annotations.Nullable
    public final synchronized okhttp3.internal.http2.ErrorCode getErrorCode$okhttp() {
        return this.errorCode;
    }

    @org.jetbrains.annotations.Nullable
    /* JADX INFO: renamed from: getErrorException$okhttp, reason: from getter */
    public final java.io.IOException getErrorException() {
        return this.errorException;
    }

    public final int getId() {
        return this.id;
    }

    public final long getReadBytesAcknowledged() {
        return this.readBytesAcknowledged;
    }

    public final long getReadBytesTotal() {
        return this.readBytesTotal;
    }

    @org.jetbrains.annotations.NotNull
    /* JADX INFO: renamed from: getReadTimeout$okhttp, reason: from getter */
    public final okhttp3.internal.http2.Http2Stream.StreamTimeout getReadTimeout() {
        return this.readTimeout;
    }

    @org.jetbrains.annotations.NotNull
    public final okio.Sink getSink() {
        synchronized (this) {
            try {
                if (!this.hasResponseHeaders && !isLocallyInitiated()) {
                    throw new java.lang.IllegalStateException("reply before requesting the sink");
                }
                kotlin.Unit unit = kotlin.Unit.a;
            } catch (java.lang.Throwable th) {
                throw th;
            }
        }
        return this.sink;
    }

    @org.jetbrains.annotations.NotNull
    /* JADX INFO: renamed from: getSink$okhttp, reason: from getter */
    public final okhttp3.internal.http2.Http2Stream.FramingSink getSink() {
        return this.sink;
    }

    @org.jetbrains.annotations.NotNull
    public final okio.Source getSource() {
        return this.source;
    }

    @org.jetbrains.annotations.NotNull
    /* JADX INFO: renamed from: getSource$okhttp, reason: from getter */
    public final okhttp3.internal.http2.Http2Stream.FramingSource getSource() {
        return this.source;
    }

    public final long getWriteBytesMaximum() {
        return this.writeBytesMaximum;
    }

    public final long getWriteBytesTotal() {
        return this.writeBytesTotal;
    }

    @org.jetbrains.annotations.NotNull
    /* JADX INFO: renamed from: getWriteTimeout$okhttp, reason: from getter */
    public final okhttp3.internal.http2.Http2Stream.StreamTimeout getWriteTimeout() {
        return this.writeTimeout;
    }

    public final boolean isLocallyInitiated() {
        return this.connection.getClient() == ((this.id & 1) == 1);
    }

    public final synchronized boolean isOpen() {
        try {
            if (this.errorCode != null) {
                return false;
            }
            if (this.source.getFinished() || this.source.getClosed()) {
                if ((this.sink.getFinished() || this.sink.getClosed()) && this.hasResponseHeaders) {
                    return false;
                }
            }
            return true;
        } catch (java.lang.Throwable th) {
            throw th;
        }
    }

    @org.jetbrains.annotations.NotNull
    public final okio.Timeout readTimeout() {
        return this.readTimeout;
    }

    public final void receiveData(@org.jetbrains.annotations.NotNull okio.BufferedSource source, int length) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(source, "source");
        if (!okhttp3.internal.Util.assertionsEnabled || !java.lang.Thread.holdsLock(this)) {
            this.source.receive$okhttp(source, length);
            return;
        }
        throw new java.lang.AssertionError("Thread " + java.lang.Thread.currentThread().getName() + " MUST NOT hold lock on " + this);
    }

    public final void receiveHeaders(@org.jetbrains.annotations.NotNull okhttp3.Headers headers, boolean inFinished) {
        boolean zIsOpen;
        kotlin.jvm.internal.Intrinsics.l(headers, "headers");
        if (okhttp3.internal.Util.assertionsEnabled && java.lang.Thread.holdsLock(this)) {
            throw new java.lang.AssertionError("Thread " + java.lang.Thread.currentThread().getName() + " MUST NOT hold lock on " + this);
        }
        synchronized (this) {
            try {
                if (this.hasResponseHeaders && inFinished) {
                    this.source.setTrailers(headers);
                } else {
                    this.hasResponseHeaders = true;
                    this.headersQueue.add(headers);
                }
                if (inFinished) {
                    this.source.setFinished$okhttp(true);
                }
                zIsOpen = isOpen();
                kotlin.jvm.internal.Intrinsics.j(this, "null cannot be cast to non-null type java.lang.Object");
                notifyAll();
                kotlin.Unit unit = kotlin.Unit.a;
            } catch (java.lang.Throwable th) {
                throw th;
            }
        }
        if (zIsOpen) {
            return;
        }
        this.connection.removeStream$okhttp(this.id);
    }

    public final synchronized void receiveRstStream(@org.jetbrains.annotations.NotNull okhttp3.internal.http2.ErrorCode errorCode) {
        kotlin.jvm.internal.Intrinsics.l(errorCode, "errorCode");
        if (this.errorCode == null) {
            this.errorCode = errorCode;
            kotlin.jvm.internal.Intrinsics.j(this, "null cannot be cast to non-null type java.lang.Object");
            notifyAll();
        }
    }

    public final void setErrorCode$okhttp(@org.jetbrains.annotations.Nullable okhttp3.internal.http2.ErrorCode errorCode) {
        this.errorCode = errorCode;
    }

    public final void setErrorException$okhttp(@org.jetbrains.annotations.Nullable java.io.IOException iOException) {
        this.errorException = iOException;
    }

    public final void setReadBytesAcknowledged$okhttp(long j) {
        this.readBytesAcknowledged = j;
    }

    public final void setReadBytesTotal$okhttp(long j) {
        this.readBytesTotal = j;
    }

    public final void setWriteBytesMaximum$okhttp(long j) {
        this.writeBytesMaximum = j;
    }

    public final void setWriteBytesTotal$okhttp(long j) {
        this.writeBytesTotal = j;
    }

    @org.jetbrains.annotations.NotNull
    public final synchronized okhttp3.Headers takeHeaders() throws java.io.IOException {
        okhttp3.Headers headersRemoveFirst;
        this.readTimeout.enter();
        while (this.headersQueue.isEmpty() && this.errorCode == null) {
            try {
                waitForIo$okhttp();
            } catch (java.lang.Throwable th) {
                this.readTimeout.exitAndThrowIfTimedOut();
                throw th;
            }
        }
        this.readTimeout.exitAndThrowIfTimedOut();
        if (this.headersQueue.isEmpty()) {
            java.io.IOException iOException = this.errorException;
            if (iOException != null) {
                throw iOException;
            }
            okhttp3.internal.http2.ErrorCode errorCode = this.errorCode;
            kotlin.jvm.internal.Intrinsics.i(errorCode);
            throw new okhttp3.internal.http2.StreamResetException(errorCode);
        }
        headersRemoveFirst = this.headersQueue.removeFirst();
        kotlin.jvm.internal.Intrinsics.k(headersRemoveFirst, "headersQueue.removeFirst()");
        return headersRemoveFirst;
    }

    @org.jetbrains.annotations.NotNull
    public final synchronized okhttp3.Headers trailers() throws java.io.IOException {
        okhttp3.Headers trailers;
        if (!this.source.getFinished() || !this.source.getReceiveBuffer().m2() || !this.source.getReadBuffer().m2()) {
            if (this.errorCode == null) {
                throw new java.lang.IllegalStateException("too early; can't read the trailers yet");
            }
            java.io.IOException iOException = this.errorException;
            if (iOException != null) {
                throw iOException;
            }
            okhttp3.internal.http2.ErrorCode errorCode = this.errorCode;
            kotlin.jvm.internal.Intrinsics.i(errorCode);
            throw new okhttp3.internal.http2.StreamResetException(errorCode);
        }
        trailers = this.source.getTrailers();
        if (trailers == null) {
            trailers = okhttp3.internal.Util.EMPTY_HEADERS;
        }
        return trailers;
    }

    public final void waitForIo$okhttp() throws java.io.InterruptedIOException {
        try {
            kotlin.jvm.internal.Intrinsics.j(this, "null cannot be cast to non-null type java.lang.Object");
            wait();
        } catch (java.lang.InterruptedException unused) {
            java.lang.Thread.currentThread().interrupt();
            throw new java.io.InterruptedIOException();
        }
    }

    public final void writeHeaders(@org.jetbrains.annotations.NotNull java.util.List<okhttp3.internal.http2.Header> responseHeaders, boolean outFinished, boolean flushHeaders) throws java.io.IOException {
        boolean z;
        kotlin.jvm.internal.Intrinsics.l(responseHeaders, "responseHeaders");
        if (okhttp3.internal.Util.assertionsEnabled && java.lang.Thread.holdsLock(this)) {
            throw new java.lang.AssertionError("Thread " + java.lang.Thread.currentThread().getName() + " MUST NOT hold lock on " + this);
        }
        synchronized (this) {
            try {
                this.hasResponseHeaders = true;
                if (outFinished) {
                    this.sink.setFinished(true);
                }
                kotlin.Unit unit = kotlin.Unit.a;
            } catch (java.lang.Throwable th) {
                throw th;
            }
        }
        if (!flushHeaders) {
            synchronized (this.connection) {
                z = this.connection.getWriteBytesTotal() >= this.connection.getWriteBytesMaximum();
            }
            flushHeaders = z;
        }
        this.connection.writeHeaders$okhttp(this.id, outFinished, responseHeaders);
        if (flushHeaders) {
            this.connection.flush();
        }
    }

    @org.jetbrains.annotations.NotNull
    public final okio.Timeout writeTimeout() {
        return this.writeTimeout;
    }

    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(d1 = {"\u00006\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\t\n\u0000\b\u0080\u0004\u0018\u00002\u00020\u0001B\u000f\u0012\b\b\u0002\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u0014\u001a\u00020\u0015H\u0016J\u0010\u0010\u0016\u001a\u00020\u00152\u0006\u0010\u0017\u001a\u00020\u0003H\u0002J\b\u0010\u0018\u001a\u00020\u0015H\u0016J\b\u0010\u0019\u001a\u00020\u001aH\u0016J\u0018\u0010\u001b\u001a\u00020\u00152\u0006\u0010\u001c\u001a\u00020\r2\u0006\u0010\u001d\u001a\u00020\u001eH\u0016R\u001a\u0010\u0005\u001a\u00020\u0003X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0006\u0010\u0007\"\u0004\b\b\u0010\tR\u001a\u0010\u0002\u001a\u00020\u0003X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\n\u0010\u0007\"\u0004\b\u000b\u0010\tR\u000e\u0010\f\u001a\u00020\rX\u0082\u0004¢\u0006\u0002\n\u0000R\u001c\u0010\u000e\u001a\u0004\u0018\u00010\u000fX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0010\u0010\u0011\"\u0004\b\u0012\u0010\u0013¨\u0006\u001f"}, d2 = {"Lokhttp3/internal/http2/Http2Stream$FramingSink;", "Lokio/Sink;", "finished", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "(Lokhttp3/internal/http2/Http2Stream;Z)V", "closed", "getClosed", "()Z", "setClosed", "(Z)V", "getFinished", "setFinished", "sendBuffer", "Lokio/Buffer;", "trailers", "Lokhttp3/Headers;", "getTrailers", "()Lokhttp3/Headers;", "setTrailers", "(Lokhttp3/Headers;)V", "close", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "emitFrame", "outFinishedOnLastFrame", "flush", "timeout", "Lokio/Timeout;", "write", "source", "byteCount", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "okhttp"}, k = 1, mv = {1, 8, 0}, xi = 48)
    @kotlin.jvm.internal.SourceDebugExtension
    public final class FramingSink implements okio.Sink {
        private boolean closed;
        private boolean finished;

        @org.jetbrains.annotations.NotNull
        private final okio.Buffer sendBuffer;

        @org.jetbrains.annotations.Nullable
        private okhttp3.Headers trailers;

        public FramingSink(boolean z) {
            this.finished = z;
            this.sendBuffer = new okio.Buffer();
        }

        private final void emitFrame(boolean outFinishedOnLastFrame) throws java.io.IOException {
            long jMin;
            boolean z;
            okhttp3.internal.http2.Http2Stream http2Stream = okhttp3.internal.http2.Http2Stream.this;
            synchronized (http2Stream) {
                try {
                    http2Stream.getWriteTimeout().enter();
                    while (http2Stream.getWriteBytesTotal() >= http2Stream.getWriteBytesMaximum() && !this.finished && !this.closed && http2Stream.getErrorCode$okhttp() == null) {
                        try {
                            http2Stream.waitForIo$okhttp();
                        } catch (java.lang.Throwable th) {
                            http2Stream.getWriteTimeout().exitAndThrowIfTimedOut();
                            throw th;
                        }
                    }
                    http2Stream.getWriteTimeout().exitAndThrowIfTimedOut();
                    http2Stream.checkOutNotClosed$okhttp();
                    jMin = java.lang.Math.min(http2Stream.getWriteBytesMaximum() - http2Stream.getWriteBytesTotal(), this.sendBuffer.getSize());
                    http2Stream.setWriteBytesTotal$okhttp(http2Stream.getWriteBytesTotal() + jMin);
                    z = outFinishedOnLastFrame && jMin == this.sendBuffer.getSize();
                    kotlin.Unit unit = kotlin.Unit.a;
                } catch (java.lang.Throwable th2) {
                    throw th2;
                }
            }
            okhttp3.internal.http2.Http2Stream.this.getWriteTimeout().enter();
            try {
                okhttp3.internal.http2.Http2Stream.this.getConnection().writeData(okhttp3.internal.http2.Http2Stream.this.getId(), z, this.sendBuffer, jMin);
            } finally {
                okhttp3.internal.http2.Http2Stream.this.getWriteTimeout().exitAndThrowIfTimedOut();
            }
        }

        @Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
        public void close() throws java.io.IOException {
            okhttp3.internal.http2.Http2Stream http2Stream = okhttp3.internal.http2.Http2Stream.this;
            if (okhttp3.internal.Util.assertionsEnabled && java.lang.Thread.holdsLock(http2Stream)) {
                throw new java.lang.AssertionError("Thread " + java.lang.Thread.currentThread().getName() + " MUST NOT hold lock on " + http2Stream);
            }
            okhttp3.internal.http2.Http2Stream http2Stream2 = okhttp3.internal.http2.Http2Stream.this;
            synchronized (http2Stream2) {
                if (this.closed) {
                    return;
                }
                boolean z = http2Stream2.getErrorCode$okhttp() == null;
                kotlin.Unit unit = kotlin.Unit.a;
                if (!okhttp3.internal.http2.Http2Stream.this.getSink().finished) {
                    boolean z4 = this.sendBuffer.getSize() > 0;
                    if (this.trailers != null) {
                        while (this.sendBuffer.getSize() > 0) {
                            emitFrame(false);
                        }
                        okhttp3.internal.http2.Http2Connection connection = okhttp3.internal.http2.Http2Stream.this.getConnection();
                        int id = okhttp3.internal.http2.Http2Stream.this.getId();
                        okhttp3.Headers headers = this.trailers;
                        kotlin.jvm.internal.Intrinsics.i(headers);
                        connection.writeHeaders$okhttp(id, z, okhttp3.internal.Util.toHeaderList(headers));
                    } else if (z4) {
                        while (this.sendBuffer.getSize() > 0) {
                            emitFrame(true);
                        }
                    } else if (z) {
                        okhttp3.internal.http2.Http2Stream.this.getConnection().writeData(okhttp3.internal.http2.Http2Stream.this.getId(), true, null, 0L);
                    }
                }
                synchronized (okhttp3.internal.http2.Http2Stream.this) {
                    this.closed = true;
                    kotlin.Unit unit2 = kotlin.Unit.a;
                }
                okhttp3.internal.http2.Http2Stream.this.getConnection().flush();
                okhttp3.internal.http2.Http2Stream.this.cancelStreamIfNecessary$okhttp();
            }
        }

        @Override // okio.Sink, java.io.Flushable
        public void flush() throws java.io.IOException {
            okhttp3.internal.http2.Http2Stream http2Stream = okhttp3.internal.http2.Http2Stream.this;
            if (okhttp3.internal.Util.assertionsEnabled && java.lang.Thread.holdsLock(http2Stream)) {
                throw new java.lang.AssertionError("Thread " + java.lang.Thread.currentThread().getName() + " MUST NOT hold lock on " + http2Stream);
            }
            okhttp3.internal.http2.Http2Stream http2Stream2 = okhttp3.internal.http2.Http2Stream.this;
            synchronized (http2Stream2) {
                http2Stream2.checkOutNotClosed$okhttp();
                kotlin.Unit unit = kotlin.Unit.a;
            }
            while (this.sendBuffer.getSize() > 0) {
                emitFrame(false);
                okhttp3.internal.http2.Http2Stream.this.getConnection().flush();
            }
        }

        public final boolean getClosed() {
            return this.closed;
        }

        public final boolean getFinished() {
            return this.finished;
        }

        @org.jetbrains.annotations.Nullable
        public final okhttp3.Headers getTrailers() {
            return this.trailers;
        }

        public final void setClosed(boolean z) {
            this.closed = z;
        }

        public final void setFinished(boolean z) {
            this.finished = z;
        }

        public final void setTrailers(@org.jetbrains.annotations.Nullable okhttp3.Headers headers) {
            this.trailers = headers;
        }

        @Override // okio.Sink
        @org.jetbrains.annotations.NotNull
        /* JADX INFO: renamed from: timeout */
        public okio.Timeout getTimeout() {
            return okhttp3.internal.http2.Http2Stream.this.getWriteTimeout();
        }

        @Override // okio.Sink
        public void write(@org.jetbrains.annotations.NotNull okio.Buffer source, long byteCount) throws java.io.IOException {
            kotlin.jvm.internal.Intrinsics.l(source, "source");
            okhttp3.internal.http2.Http2Stream http2Stream = okhttp3.internal.http2.Http2Stream.this;
            if (!okhttp3.internal.Util.assertionsEnabled || !java.lang.Thread.holdsLock(http2Stream)) {
                this.sendBuffer.write(source, byteCount);
                while (this.sendBuffer.getSize() >= okhttp3.internal.http2.Http2Stream.EMIT_BUFFER_SIZE) {
                    emitFrame(false);
                }
            } else {
                throw new java.lang.AssertionError("Thread " + java.lang.Thread.currentThread().getName() + " MUST NOT hold lock on " + http2Stream);
            }
        }

        public /* synthetic */ FramingSink(okhttp3.internal.http2.Http2Stream http2Stream, boolean z, int i, kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker) {
            this((i & 1) != 0 ? false : z);
        }
    }
}
