package c.i.a.c.v1; import android.media.AudioTrack; import android.os.SystemClock; import androidx.annotation.Nullable; import c.i.a.c.i2.f0; import java.lang.reflect.Method; import java.util.Objects; /* compiled from: AudioTrackPositionTracker */ public final class s { public long A; public long B; public long C; public boolean D; public long E; public long F; public final a a; public final long[] b; @Nullable /* renamed from: c reason: collision with root package name */ public AudioTrack f998c; public int d; public int e; @Nullable public r f; public int g; public boolean h; public long i; public float j; public boolean k; public long l; public long m; @Nullable public Method n; public long o; public boolean p; public boolean q; public long r; /* renamed from: s reason: collision with root package name */ public long f999s; public long t; public long u; public int v; public int w; /* renamed from: x reason: collision with root package name */ public long f1000x; /* renamed from: y reason: collision with root package name */ public long f1001y; /* renamed from: z reason: collision with root package name */ public long f1002z; /* compiled from: AudioTrackPositionTracker */ public interface a { void a(long j); void b(int i, long j); void c(long j); void d(long j, long j2, long j3, long j4); void e(long j, long j2, long j3, long j4); } public s(a aVar) { this.a = aVar; if (f0.a >= 18) { try { this.n = AudioTrack.class.getMethod("getLatency", null); } catch (NoSuchMethodException unused) { } } this.b = new long[10]; } public final long a(long j) { return (j * 1000000) / ((long) this.g); } public final long b() { AudioTrack audioTrack = this.f998c; Objects.requireNonNull(audioTrack); if (this.f1000x != -9223372036854775807L) { return Math.min(this.A, this.f1002z + ((((SystemClock.elapsedRealtime() * 1000) - this.f1000x) * ((long) this.g)) / 1000000)); } int playState = audioTrack.getPlayState(); if (playState == 1) { return 0; } long playbackHeadPosition = 4294967295L & ((long) audioTrack.getPlaybackHeadPosition()); if (this.h) { if (playState == 2 && playbackHeadPosition == 0) { this.u = this.f999s; } playbackHeadPosition += this.u; } if (f0.a <= 29) { if (playbackHeadPosition == 0 && this.f999s > 0 && playState == 3) { if (this.f1001y == -9223372036854775807L) { this.f1001y = SystemClock.elapsedRealtime(); } return this.f999s; } this.f1001y = -9223372036854775807L; } if (this.f999s > playbackHeadPosition) { this.t++; } this.f999s = playbackHeadPosition; return playbackHeadPosition + (this.t << 32); } /* JADX WARNING: Removed duplicated region for block: B:12:? A[RETURN, SYNTHETIC] */ public boolean c(long j) { boolean z2; if (j <= b()) { if (this.h) { AudioTrack audioTrack = this.f998c; Objects.requireNonNull(audioTrack); if (audioTrack.getPlayState() == 2 && b() == 0) { z2 = true; if (z2) { return false; } } } z2 = false; if (z2) { } } return true; } public void d() { this.l = 0; this.w = 0; this.v = 0; this.m = 0; this.C = 0; this.F = 0; this.k = false; this.f998c = null; this.f = null; } /* JADX WARNING: Code restructure failed: missing block: B:10:0x0026, code lost: if ((c.i.a.c.i2.f0.a < 23 && (r5 == 5 || r5 == 6)) != false) goto L_0x002a; */ public void e(AudioTrack audioTrack, boolean z2, int i, int i2, int i3) { this.f998c = audioTrack; this.d = i2; this.e = i3; this.f = new r(audioTrack); this.g = audioTrack.getSampleRate(); boolean z3 = true; if (z2) { } z3 = false; this.h = z3; boolean z4 = f0.z(i); this.q = z4; this.i = z4 ? a((long) (i3 / i2)) : -9223372036854775807L; this.f999s = 0; this.t = 0; this.u = 0; this.p = false; this.f1000x = -9223372036854775807L; this.f1001y = -9223372036854775807L; this.r = 0; this.o = 0; this.j = 1.0f; } }