package com.applovin.impl; import android.media.AudioTimestamp; import android.media.AudioTrack; import androidx.work.WorkRequest; import com.mbridge.msdk.playercommon.exoplayer2.C; /* loaded from: classes.dex */ final class t1 { private final a a; private int b; private long c; private long d; private long e; private long f; public boolean d() { return this.b == 2; } public t1(AudioTrack audioTrack) { if (xp.a >= 19) { this.a = new a(audioTrack); f(); } else { this.a = null; a(3); } } public void e() { a(4); } public void a() { if (this.b == 4) { f(); } } public void f() { if (this.a != null) { a(0); } } public long c() { a aVar = this.a; return aVar != null ? aVar.b() : C.TIME_UNSET; } public long b() { a aVar = this.a; if (aVar != null) { return aVar.a(); } return -1L; } public static final class a { private final AudioTrack a; private final AudioTimestamp b = new AudioTimestamp(); private long c; private long d; private long e; public long a() { return this.e; } public a(AudioTrack audioTrack) { this.a = audioTrack; } public boolean c() { boolean timestamp = this.a.getTimestamp(this.b); if (timestamp) { long j = this.b.framePosition; if (this.d > j) { this.c++; } this.d = j; this.e = j + (this.c << 32); } return timestamp; } public long b() { return this.b.nanoTime / 1000; } } public boolean a(long j) { a aVar = this.a; if (aVar == null || j - this.e < this.d) { return false; } this.e = j; boolean c = aVar.c(); int i = this.b; if (i != 0) { if (i != 1) { if (i != 2) { if (i != 3) { if (i != 4) { throw new IllegalStateException(); } } else if (c) { f(); } } else if (!c) { f(); } } else if (!c) { f(); } else if (this.a.a() > this.f) { a(2); } } else if (c) { if (this.a.b() < this.c) { return false; } this.f = this.a.a(); a(1); } else if (j - this.c > 500000) { a(3); } return c; } private void a(int i) { this.b = i; if (i == 0) { this.e = 0L; this.f = -1L; this.c = System.nanoTime() / 1000; this.d = WorkRequest.MIN_BACKOFF_MILLIS; return; } if (i == 1) { this.d = WorkRequest.MIN_BACKOFF_MILLIS; return; } if (i == 2 || i == 3) { this.d = 10000000L; } else { if (i != 4) { throw new IllegalStateException(); } this.d = 500000L; } } }