package defpackage;

import java.util.concurrent.locks.ReentrantLock;

/* renamed from: ᵲˆᵺ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4473 implements InterfaceC3226 {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public long f16690;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final C3882 f16691;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public boolean f16692;

    public C4473(C3882 c3882, long j) {
        this.f16691 = c3882;
        this.f16690 = j;
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
        C3882 c3882 = this.f16691;
        if (this.f16692) {
            return;
        }
        this.f16692 = true;
        ReentrantLock reentrantLock = c3882.f14433;
        reentrantLock.lock();
        try {
            int i = c3882.f14430 - 1;
            c3882.f14430 = i;
            if (i == 0) {
                if (c3882.f14431) {
                    synchronized (c3882) {
                        c3882.f14432.close();
                    }
                }
            }
        } finally {
            reentrantLock.unlock();
        }
    }

    @Override // defpackage.InterfaceC3226
    /* renamed from: ᵝᵵᵺ */
    public final C3948 mo2227() {
        return C3948.f14904;
    }

    @Override // defpackage.InterfaceC3226
    /* renamed from: ᵳٴᵶ */
    public final long mo2229(C0963 c0963, long j) {
        long j2;
        long j3;
        int i;
        if (this.f16692) {
            ᵹˉᵞ.ᵳٴᵶ("closed");
            return 0L;
        }
        C3882 c3882 = this.f16691;
        long j4 = this.f16690;
        long j5 = 8192 + j4;
        long j6 = j4;
        while (true) {
            if (j6 >= j5) {
                j2 = -1;
                break;
            }
            C3514 c3514M3279 = c0963.m3279(1);
            byte[] bArr = c3514M3279.f13189;
            int i2 = c3514M3279.f13188;
            j2 = -1;
            int iMin = (int) Math.min(j5 - j6, 8192 - i2);
            synchronized (c3882) {
                c3882.f14432.seek(j6);
                i = 0;
                while (true) {
                    if (i >= iMin) {
                        break;
                    }
                    int i3 = c3882.f14432.read(bArr, i2, iMin - i);
                    if (i3 != -1) {
                        i += i3;
                    } else if (i == 0) {
                        i = -1;
                    }
                }
            }
            if (i == -1) {
                if (c3514M3279.f13190 == c3514M3279.f13188) {
                    c0963.f4315 = c3514M3279.m8039();
                    AbstractC3467.m7895(c3514M3279);
                }
                if (j4 == j6) {
                    j3 = -1;
                }
            } else {
                c3514M3279.f13188 += i;
                long j7 = i;
                j6 += j7;
                c0963.f4314 += j7;
            }
        }
        j3 = j6 - j4;
        if (j3 != j2) {
            this.f16690 += j3;
        }
        return j3;
    }
}
