package defpackage;

import android.media.AudioTrack;
import android.os.SystemClock;
import java.lang.reflect.Method;
import java.math.RoundingMode;

/* renamed from: ˋːᵩ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C1481 {

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public long f5941;

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final int f5942;

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public long f5943;

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public long f5944;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final boolean f5945;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final long f5946;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final long[] f5947;

    /* renamed from: ˑᵱ, reason: contains not printable characters */
    public long f5948;

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public float f5949;

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public int f5950;

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public long f5951;

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public boolean f5952;

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

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public long f5954;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final ˊᵘʛ f5955;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public long f5956;

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public int f5957;

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public long f5958;

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public Method f5959;

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public long f5960;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final C1875 f5961;

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public long f5962;

    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public long f5963;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public long f5964;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final C3841 f5965;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final AudioTrack f5966;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public long f5967;

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

    public C1481(ˊᵘʛ r3, C1875 c1875, AudioTrack audioTrack, int i, int i2, int i3) {
        this.f5955 = r3;
        this.f5961 = c1875;
        this.f5966 = audioTrack;
        try {
            this.f5959 = AudioTrack.class.getMethod("getLatency", null);
        } catch (NoSuchMethodException unused) {
        }
        this.f5947 = new long[10];
        this.f5954 = -9223372036854775807L;
        this.f5967 = -9223372036854775807L;
        this.f5965 = new C3841(audioTrack, r3);
        int sampleRate = audioTrack.getSampleRate();
        this.f5942 = sampleRate;
        boolean zM8107 = AbstractC3558.m8107(i);
        this.f5945 = zM8107;
        this.f5946 = zM8107 ? AbstractC3558.m8110(i3 / i2, sampleRate) : -9223372036854775807L;
        this.f5951 = 0L;
        this.f5963 = 0L;
        this.f5952 = false;
        this.f5941 = 0L;
        this.f5948 = -9223372036854775807L;
        this.f5956 = -9223372036854775807L;
        this.f5960 = 0L;
        this.f5958 = 0L;
        this.f5949 = 1.0f;
        this.f5962 = -9223372036854775807L;
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final long m4397() {
        if (this.f5966.getPlayState() == 2) {
            return this.f5953;
        }
        this.f5961.getClass();
        return this.f5953 + AbstractC3558.m8115(AbstractC3558.m8122(AbstractC3558.m8133(SystemClock.elapsedRealtime()) - this.f5948, this.f5949), this.f5942, 1000000L, RoundingMode.UP);
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x0064  */
    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final long m4398() {
        /*
            r12 = this;
            long r0 = r12.f5948
            r2 = -9223372036854775807(0x8000000000000001, double:-4.9E-324)
            int r0 = (r0 > r2 ? 1 : (r0 == r2 ? 0 : -1))
            if (r0 == 0) goto L16
            long r0 = r12.m4397()
            long r2 = r12.f5968
            long r0 = java.lang.Math.min(r2, r0)
            return r0
        L16:
            ˏᵡʽ r0 = r12.f5961
            r0.getClass()
            long r0 = android.os.SystemClock.elapsedRealtime()
            long r4 = r12.f5943
            long r4 = r0 - r4
            r6 = 5
            int r4 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1))
            if (r4 < 0) goto L7c
            android.media.AudioTrack r4 = r12.f5966
            int r5 = r4.getPlayState()
            r6 = 1
            if (r5 != r6) goto L33
            goto L7a
        L33:
            int r4 = r4.getPlaybackHeadPosition()
            long r6 = (long) r4
            r8 = 4294967295(0xffffffff, double:2.1219957905E-314)
            long r6 = r6 & r8
            int r4 = android.os.Build.VERSION.SDK_INT
            r8 = 29
            if (r4 > r8) goto L5e
            r8 = 0
            int r4 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1))
            if (r4 != 0) goto L5c
            long r10 = r12.f5951
            int r4 = (r10 > r8 ? 1 : (r10 == r8 ? 0 : -1))
            if (r4 <= 0) goto L5c
            r4 = 3
            if (r5 != r4) goto L5c
            long r4 = r12.f5956
            int r2 = (r4 > r2 ? 1 : (r4 == r2 ? 0 : -1))
            if (r2 != 0) goto L7a
            r12.f5956 = r0
            goto L7a
        L5c:
            r12.f5956 = r2
        L5e:
            long r2 = r12.f5951
            int r4 = (r2 > r6 ? 1 : (r2 == r6 ? 0 : -1))
            if (r4 <= 0) goto L78
            boolean r4 = r12.f5952
            if (r4 == 0) goto L71
            long r4 = r12.f5941
            long r4 = r4 + r2
            r12.f5941 = r4
            r2 = 0
            r12.f5952 = r2
            goto L78
        L71:
            long r2 = r12.f5963
            r4 = 1
            long r2 = r2 + r4
            r12.f5963 = r2
        L78:
            r12.f5951 = r6
        L7a:
            r12.f5943 = r0
        L7c:
            long r0 = r12.f5951
            long r2 = r12.f5941
            long r0 = r0 + r2
            long r2 = r12.f5963
            r12 = 32
            long r2 = r2 << r12
            long r0 = r0 + r2
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C1481.m4398():long");
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final long m4399(long j) {
        int i = this.f5957;
        int i2 = this.f5942;
        long jMax = Math.max(0L, (i == 0 ? this.f5948 != -9223372036854775807L ? AbstractC3558.m8110(m4397(), i2) : AbstractC3558.m8110(m4398(), i2) : AbstractC3558.m8122(j + this.f5964, this.f5949)) - this.f5958);
        return this.f5948 != -9223372036854775807L ? Math.min(AbstractC3558.m8110(this.f5968, i2), jMax) : jMax;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final void m4400(long j) {
        long j2 = this.f5962;
        if (j2 == -9223372036854775807L || j < j2) {
            return;
        }
        long jM8155 = AbstractC3558.m8155(j - j2, this.f5949);
        this.f5961.getClass();
        final long jCurrentTimeMillis = System.currentTimeMillis() - AbstractC3558.m8161(jM8155);
        this.f5962 = -9223372036854775807L;
        C5128 c5128 = ((C2361) this.f5955.ᵢˇᵭ).f9272;
        c5128.getClass();
        if (Thread.currentThread() == c5128.f19101) {
            c5128.m10590(-1, new InterfaceC2230() { // from class: ᵚᵽᵲ
                @Override // defpackage.InterfaceC2230
                /* renamed from: ᵴᵳ */
                public final void mo1599(Object obj) {
                    InterfaceC5159 interfaceC5159;
                    C5551 c5551 = (C5551) obj;
                    C0646 c0646 = c5551.f20831;
                    if (c5551 == c0646.f3216 && (interfaceC5159 = c0646.f3208) != null) {
                        interfaceC5159.m10640(jCurrentTimeMillis);
                    }
                }
            });
        }
    }
}
