package B1;

import T0.F;
import T0.j;
import T0.o;
import java.math.RoundingMode;
import u0.C1578n;
import u0.C1579o;
import u0.E;
import x0.v;

/* JADX INFO: loaded from: classes.dex */
public final class c implements b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final o f941a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final F f942b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final e f943c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final C1579o f944d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final int f945e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public long f946f;

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public long f948h;

    public c(o oVar, F f3, e eVar, String str, int i) throws u0.F {
        this.f941a = oVar;
        this.f942b = f3;
        this.f943c = eVar;
        int i5 = eVar.f959t;
        int i8 = eVar.f956q;
        int i9 = (i5 * i8) / 8;
        int i10 = eVar.f958s;
        if (i10 != i9) {
            throw u0.F.a(null, "Expected block size: " + i9 + "; got: " + i10);
        }
        int i11 = eVar.f957r;
        int i12 = i11 * i9;
        int i13 = i12 * 8;
        int iMax = Math.max(i9, i12 / 10);
        this.f945e = iMax;
        C1578n c1578n = new C1578n();
        c1578n.f17319l = E.m("audio/wav");
        c1578n.f17320m = E.m(str);
        c1578n.f17316h = i13;
        c1578n.i = i13;
        c1578n.f17321n = iMax;
        c1578n.f17301C = i8;
        c1578n.D = i11;
        c1578n.f17302E = i;
        this.f944d = new C1579o(c1578n);
    }

    @Override // B1.b
    public final void a(long j8) {
        this.f946f = j8;
        this.f947g = 0;
        this.f948h = 0L;
    }

    @Override // B1.b
    public final void b(long j8, int i) {
        this.f941a.v(new g(this.f943c, 1, i, j8));
        this.f942b.e(this.f944d);
    }

    @Override // B1.b
    public final boolean c(j jVar, long j8) {
        int i;
        int i5;
        long j9 = j8;
        while (j9 > 0 && (i = this.f947g) < (i5 = this.f945e)) {
            int iF = this.f942b.f(jVar, (int) Math.min(i5 - i, j9), true);
            if (iF == -1) {
                j9 = 0;
            } else {
                this.f947g += iF;
                j9 -= (long) iF;
            }
        }
        e eVar = this.f943c;
        int i8 = this.f947g;
        int i9 = eVar.f958s;
        int i10 = i8 / i9;
        if (i10 > 0) {
            long j10 = this.f946f;
            long j11 = this.f948h;
            long j12 = eVar.f957r;
            int i11 = v.f18553a;
            long jS = j10 + v.S(j11, 1000000L, j12, RoundingMode.DOWN);
            int i12 = i10 * i9;
            int i13 = this.f947g - i12;
            this.f942b.a(jS, 1, i12, i13, null);
            this.f948h += (long) i10;
            this.f947g = i13;
        }
        return j9 <= 0;
    }
}
