package S0;

import java.util.Arrays;
import x0.AbstractC1709a;

/* JADX INFO: loaded from: classes.dex */
public final class f {

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object f6217c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Object f6218d;

    public f() {
        this.f6217c = new long[10];
        this.f6218d = new Object[10];
    }

    public synchronized void a(long j8, Object obj) {
        if (this.f6216b > 0) {
            if (j8 <= ((long[]) this.f6217c)[((this.f6215a + r0) - 1) % ((Object[]) this.f6218d).length]) {
                b();
            }
        }
        c();
        int i = this.f6215a;
        int i5 = this.f6216b;
        Object[] objArr = (Object[]) this.f6218d;
        int length = (i + i5) % objArr.length;
        ((long[]) this.f6217c)[length] = j8;
        objArr[length] = obj;
        this.f6216b = i5 + 1;
    }

    public synchronized void b() {
        this.f6215a = 0;
        this.f6216b = 0;
        Arrays.fill((Object[]) this.f6218d, (Object) null);
    }

    public void c() {
        int length = ((Object[]) this.f6218d).length;
        if (this.f6216b < length) {
            return;
        }
        int i = length * 2;
        long[] jArr = new long[i];
        Object[] objArr = new Object[i];
        int i5 = this.f6215a;
        int i8 = length - i5;
        System.arraycopy((long[]) this.f6217c, i5, jArr, 0, i8);
        System.arraycopy((Object[]) this.f6218d, this.f6215a, objArr, 0, i8);
        int i9 = this.f6215a;
        if (i9 > 0) {
            System.arraycopy((long[]) this.f6217c, 0, jArr, i8, i9);
            System.arraycopy((Object[]) this.f6218d, 0, objArr, i8, this.f6215a);
        }
        this.f6217c = jArr;
        this.f6218d = objArr;
        this.f6215a = 0;
    }

    public Object d(long j8, boolean z8) {
        Object objG = null;
        long j9 = Long.MAX_VALUE;
        while (this.f6216b > 0) {
            long j10 = j8 - ((long[]) this.f6217c)[this.f6215a];
            if (j10 < 0 && (z8 || (-j10) >= j9)) {
                break;
            }
            objG = g();
            j9 = j10;
        }
        return objG;
    }

    public synchronized Object e() {
        return this.f6216b == 0 ? null : g();
    }

    public synchronized Object f(long j8) {
        return d(j8, true);
    }

    public Object g() {
        AbstractC1709a.j(this.f6216b > 0);
        Object[] objArr = (Object[]) this.f6218d;
        int i = this.f6215a;
        Object obj = objArr[i];
        objArr[i] = null;
        this.f6215a = (i + 1) % objArr.length;
        this.f6216b--;
        return obj;
    }

    public synchronized int h() {
        return this.f6216b;
    }

    public f(int i, float[] fArr, float[] fArr2, int i5) {
        this.f6215a = i;
        AbstractC1709a.d(((long) fArr.length) * 2 == ((long) fArr2.length) * 3);
        this.f6217c = fArr;
        this.f6218d = fArr2;
        this.f6216b = i5;
    }

    public f(f fVar) {
        float[] fArr = (float[]) fVar.f6217c;
        this.f6215a = fArr.length / 3;
        this.f6217c = AbstractC1709a.m(fArr);
        this.f6218d = AbstractC1709a.m((float[]) fVar.f6218d);
        int i = fVar.f6216b;
        if (i == 1) {
            this.f6216b = 5;
        } else if (i != 2) {
            this.f6216b = 4;
        } else {
            this.f6216b = 6;
        }
    }
}
