package n;

import android.util.Log;
import b0.AbstractC0399d;
import java.nio.ByteBuffer;

/* JADX INFO: renamed from: n.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
final class C0635a extends C0633A {

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private final C0633A f5487h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private boolean f5488i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private long f5489j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private int f5490k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private int f5491l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private boolean f5492m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    private final String f5493n;

    public C0635a() {
        super(1);
        this.f5490k = 0;
        this.f5492m = false;
        this.f5493n = "BatchBuffer";
        this.f5487h = new C0633A(1);
        k();
    }

    private boolean j(C0633A c0633a) {
        ByteBuffer byteBuffer;
        if (s()) {
            return true;
        }
        if (c0633a.e() != e()) {
            return false;
        }
        ByteBuffer byteBuffer2 = c0633a.f5409b;
        return byteBuffer2 == null || (byteBuffer = this.f5409b) == null || byteBuffer.position() + byteBuffer2.limit() < 6291456;
    }

    private void l() {
        super.a();
        this.f5490k = 0;
        this.f5489j = -1L;
        this.f5412e = -1L;
        this.f5492m = false;
    }

    private void v(C0633A c0633a) {
        ByteBuffer byteBuffer;
        if (c0633a == null || (byteBuffer = c0633a.f5409b) == null) {
            Log.e("BatchBuffer", "putsampleHolder invalid argument");
            return;
        }
        c0633a.d();
        c(byteBuffer.remaining());
        this.f5409b.put(byteBuffer);
        int i2 = this.f5490k + 1;
        this.f5490k = i2;
        long j2 = c0633a.f5412e;
        this.f5412e = j2;
        if (i2 == 1) {
            this.f5489j = j2;
        }
        c0633a.a();
    }

    public void i() {
        l();
        if (this.f5488i) {
            v(this.f5487h);
            this.f5488i = false;
        }
    }

    public void k() {
        n();
        this.f5491l = 32;
    }

    public void m() {
        C0633A c0633a = this.f5487h;
        if (j(c0633a)) {
            v(c0633a);
        } else {
            this.f5488i = true;
        }
    }

    public void n() {
        l();
        this.f5487h.a();
        this.f5488i = false;
    }

    public long o() {
        C0633A c0633a = this.f5487h;
        if (c0633a == null) {
            return -1L;
        }
        return c0633a.f5412e;
    }

    public long p() {
        return this.f5489j;
    }

    public long q() {
        return this.f5412e;
    }

    public C0633A r() {
        return this.f5487h;
    }

    public boolean s() {
        return this.f5490k == 0;
    }

    protected boolean t() {
        return this.f5492m;
    }

    public boolean u() {
        ByteBuffer byteBuffer;
        return this.f5490k >= this.f5491l || ((byteBuffer = this.f5409b) != null && byteBuffer.position() >= 6291456) || this.f5488i;
    }

    protected void w() {
        this.f5492m = true;
    }

    public void x(int i2) {
        AbstractC0399d.a(i2 > 0);
        this.f5491l = i2;
    }
}
