package com.applovin.impl; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Message; import android.os.SystemClock; import android.util.Pair; import com.applovin.exoplayer2.common.base.Supplier; import com.applovin.impl.be; import com.applovin.impl.bf; import com.applovin.impl.eb; import com.applovin.impl.fe; import com.applovin.impl.fo; import com.applovin.impl.h6; import com.applovin.impl.qi; import com.applovin.impl.rh; import com.applovin.impl.td; import com.applovin.impl.vo; import com.applovin.impl.wd; import com.applovin.impl.z6; import com.google.android.gms.auth.api.proxy.AuthApiStatusCodes; import com.mbridge.msdk.playercommon.exoplayer2.C; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; /* loaded from: classes.dex */ final class e8 implements Handler.Callback, wd.a, vo.a, fe.d, h6.a, rh.a { private boolean A; private boolean B; private boolean C; private boolean D; private boolean E; private int F; private boolean G; private boolean H; private boolean I; private boolean J; private int K; private h L; private long M; private int N; private boolean O; private a8 P; private long Q; private final qi[] a; private final Set b; private final ri[] c; private final vo d; private final wo f; private final lc g; private final y1 h; private final ja i; private final HandlerThread j; private final Looper k; private final fo.d l; private final fo.b m; private final long n; private final boolean o; private final h6 p; private final ArrayList q; private final l3 r; private final f s; private final ae t; private final fe u; private final kc v; private final long w; private jj x; private oh y; private e z; public static class c { } public interface f { void a(e eVar); } private void a(jj jjVar) { this.x = jjVar; } public void a(long j) { this.Q = j; } public Looper g() { return this.k; } public static final class e { private boolean a; public oh b; public int c; public boolean d; public int e; public boolean f; public int g; public void a(int i) { this.a |= i > 0; this.c += i; } public void a(oh ohVar) { this.a |= this.b != ohVar; this.b = ohVar; } public void b(int i) { this.a = true; this.f = true; this.g = i; } public e(oh ohVar) { this.b = ohVar; } public void c(int i) { if (this.d && this.e != 5) { b1.a(i == 5); return; } this.a = true; this.d = true; this.e = i; } } public e8(qi[] qiVarArr, vo voVar, wo woVar, lc lcVar, y1 y1Var, int i, boolean z, r0 r0Var, jj jjVar, kc kcVar, long j, boolean z2, Looper looper, l3 l3Var, f fVar) { this.s = fVar; this.a = qiVarArr; this.d = voVar; this.f = woVar; this.g = lcVar; this.h = y1Var; this.F = i; this.G = z; this.x = jjVar; this.v = kcVar; this.w = j; this.Q = j; this.B = z2; this.r = l3Var; this.n = lcVar.d(); this.o = lcVar.a(); oh a2 = oh.a(woVar); this.y = a2; this.z = new e(a2); this.c = new ri[qiVarArr.length]; for (int i2 = 0; i2 < qiVarArr.length; i2++) { qiVarArr[i2].b(i2); this.c[i2] = qiVarArr[i2].n(); } this.p = new h6(this, l3Var); this.q = new ArrayList(); this.b = rj.b(); this.l = new fo.d(); this.m = new fo.b(); voVar.a(this, y1Var); this.O = true; Handler handler = new Handler(looper); this.t = new ae(r0Var, handler); this.u = new fe(this, r0Var, handler); HandlerThread handlerThread = new HandlerThread("ExoPlayer:Playback", -16); this.j = handlerThread; handlerThread.start(); Looper looper2 = handlerThread.getLooper(); this.k = looper2; this.i = l3Var.a(looper2, this); } private void a(wj wjVar) { this.z.a(1); a(this.u.a(wjVar), false); } public void v() { this.i.d(0).a(); } public void G() { this.i.d(6).a(); } public synchronized boolean x() { if (!this.A && this.j.isAlive()) { this.i.c(7); a(new Supplier() { // from class: com.applovin.impl.e8$$ExternalSyntheticLambda1 @Override // com.applovin.exoplayer2.common.base.Supplier public final Object get() { Boolean l; l = e8.this.l(); return l; } }, this.w); return this.A; } return true; } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ Boolean l() { return Boolean.valueOf(this.A); } @Override // android.os.Handler.Callback public boolean handleMessage(Message message) { xd f2; try { switch (message.what) { case 0: w(); break; case 1: a(message.arg1 != 0, message.arg2, true, 1); break; case 2: c(); break; case 3: a((h) message.obj); break; case 4: b((ph) message.obj); break; case 5: a((jj) message.obj); break; case 6: a(false, true); break; case 7: y(); return true; case 8: c((wd) message.obj); break; case 9: b((wd) message.obj); break; case 10: A(); break; case 11: b(message.arg1); break; case 12: g(message.arg1 != 0); break; case 13: a(message.arg1 != 0, (AtomicBoolean) message.obj); break; case 14: d((rh) message.obj); break; case 15: f((rh) message.obj); break; case 16: a((ph) message.obj, false); break; case 17: a((b) message.obj); break; case 18: a((b) message.obj, message.arg1); break; case 19: d8.a(message.obj); a((c) null); break; case 20: a(message.arg1, message.arg2, (wj) message.obj); break; case 21: a((wj) message.obj); break; case 22: s(); break; case 23: e(message.arg1 != 0); break; case 24: d(message.arg1 == 1); break; case 25: b(); break; default: return false; } } catch (a8 e2) { e = e2; if (e.d == 1 && (f2 = this.t.f()) != null) { e = e.a(f2.f.a); } if (e.k && this.P == null) { pc.c("ExoPlayerImplInternal", "Recoverable renderer error", e); this.P = e; ja jaVar = this.i; jaVar.a(jaVar.a(25, e)); } else { a8 a8Var = this.P; if (a8Var != null) { a8Var.addSuppressed(e); e = this.P; } pc.a("ExoPlayerImplInternal", "Playback error", e); a(true, false); this.y = this.y.a(e); } } catch (dh e3) { int i = e3.b; if (i == 1) { r2 = e3.a ? 3001 : AuthApiStatusCodes.AUTH_API_SERVER_ERROR; } else if (i == 4) { r2 = e3.a ? 3002 : AuthApiStatusCodes.AUTH_TOKEN_ERROR; } a(e3, r2); } catch (j5 e4) { a(e4, e4.a); } catch (z6.a e5) { a(e5, e5.a); } catch (IOException e6) { a(e6, 2000); } catch (RuntimeException e7) { a8 a2 = a8.a(e7, ((e7 instanceof IllegalStateException) || (e7 instanceof IllegalArgumentException)) ? 1004 : 1000); pc.a("ExoPlayerImplInternal", "Playback error", a2); a(true, false); this.y = this.y.a(a2); } n(); return true; } private void n() { this.z.a(this.y); if (this.z.a) { this.s.a(this.z); this.z = new e(this.y); } } private void w() { this.z.a(1); a(false, false, false, true); this.g.f(); c(this.y.a.c() ? 4 : 2); this.u.a(this.h.a()); this.i.c(2); } private void s() { a(this.u.a(), true); } private void a(b bVar, int i) { this.z.a(1); fe feVar = this.u; if (i == -1) { i = feVar.c(); } a(feVar.a(i, bVar.a, bVar.b), false); } private void F() { this.D = false; this.p.b(); for (qi qiVar : this.a) { if (c(qiVar)) { qiVar.start(); } } } private void H() { this.p.c(); for (qi qiVar : this.a) { if (c(qiVar)) { b(qiVar); } } } private void b() { c(true); } private void K() { xd e2 = this.t.e(); if (e2 == null) { return; } long h2 = e2.d ? e2.a.h() : -9223372036854775807L; if (h2 != C.TIME_UNSET) { c(h2); if (h2 != this.y.s) { oh ohVar = this.y; this.y = a(ohVar.b, h2, ohVar.c, h2, true, 5); } } else { long b2 = this.p.b(e2 != this.t.f()); this.M = b2; long d2 = e2.d(b2); b(this.y.s, d2); this.y.s = d2; } this.y.q = this.t.d().c(); this.y.r = h(); oh ohVar2 = this.y; if (ohVar2.l && ohVar2.e == 3 && a(ohVar2.a, ohVar2.b) && this.y.n.a == 1.0f) { float a2 = this.v.a(e(), h()); if (this.p.a().a != a2) { this.p.a(this.y.n.a(a2)); a(this.y.n, this.p.a().a, false, false); } } } private void u() { for (xd e2 = this.t.e(); e2 != null; e2 = e2.d()) { for (h8 h8Var : e2.i().c) { if (h8Var != null) { h8Var.k(); } } } } private void c() { boolean z; boolean z2; int i; boolean z3; long a2 = this.r.a(); J(); int i2 = this.y.e; if (i2 != 1 && i2 != 4) { xd e2 = this.t.e(); if (e2 == null) { c(a2, 10L); return; } ko.a("doSomeWork"); K(); if (e2.d) { long elapsedRealtime = SystemClock.elapsedRealtime() * 1000; e2.a.a(this.y.s - this.n, this.o); z = true; z2 = true; int i3 = 0; while (true) { qi[] qiVarArr = this.a; if (i3 >= qiVarArr.length) { break; } qi qiVar = qiVarArr[i3]; if (c(qiVar)) { qiVar.a(this.M, elapsedRealtime); z = z && qiVar.c(); boolean z4 = e2.c[i3] != qiVar.o(); boolean z5 = z4 || (!z4 && qiVar.j()) || qiVar.d() || qiVar.c(); z2 = z2 && z5; if (!z5) { qiVar.h(); } } i3++; } } else { e2.a.f(); z = true; z2 = true; } long j = e2.f.e; boolean z6 = z && e2.d && (j == C.TIME_UNSET || j <= this.y.s); if (z6 && this.C) { this.C = false; a(false, this.y.m, false, 5); } if (z6 && e2.f.i) { c(4); H(); } else if (this.y.e == 2 && h(z2)) { c(3); this.P = null; if (E()) { F(); } } else if (this.y.e == 3 && (this.K != 0 ? !z2 : !k())) { this.D = E(); c(2); if (this.D) { u(); this.v.a(); } H(); } if (this.y.e == 2) { int i4 = 0; while (true) { qi[] qiVarArr2 = this.a; if (i4 >= qiVarArr2.length) { break; } if (c(qiVarArr2[i4]) && this.a[i4].o() == e2.c[i4]) { this.a[i4].h(); } i4++; } oh ohVar = this.y; if (!ohVar.g && ohVar.r < 500000 && j()) { throw new IllegalStateException("Playback stuck buffering and not loading"); } } boolean z7 = this.J; oh ohVar2 = this.y; if (z7 != ohVar2.o) { this.y = ohVar2.b(z7); } if ((E() && this.y.e == 3) || (i = this.y.e) == 2) { z3 = !a(a2, 10L); } else { if (this.K != 0 && i != 4) { c(a2, 1000L); } else { this.i.b(2); } z3 = false; } oh ohVar3 = this.y; if (ohVar3.p != z3) { this.y = ohVar3.c(z3); } this.I = false; ko.a(); return; } this.i.b(2); } private long e() { oh ohVar = this.y; return a(ohVar.a, ohVar.b.a, ohVar.s); } private void g(boolean z) { this.G = z; if (!this.t.a(this.y.a, z)) { c(true); } a(false); } private void y() { a(true, false, true, false); this.g.e(); c(1); this.j.quit(); synchronized (this) { this.A = true; notifyAll(); } } private boolean a(fo foVar, be.a aVar) { if (aVar.a() || foVar.c()) { return false; } foVar.a(foVar.a(aVar.a, this.m).c, this.l); if (!this.l.e()) { return false; } fo.d dVar = this.l; return dVar.j && dVar.g != C.TIME_UNSET; } private void A() { float f2 = this.p.a().a; xd f3 = this.t.f(); boolean z = true; for (xd e2 = this.t.e(); e2 != null && e2.d; e2 = e2.d()) { wo b2 = e2.b(f2, this.y.a); if (!b2.a(e2.i())) { if (z) { xd e3 = this.t.e(); boolean a2 = this.t.a(e3); boolean[] zArr = new boolean[this.a.length]; long a3 = e3.a(b2, this.y.s, a2, zArr); oh ohVar = this.y; boolean z2 = (ohVar.e == 4 || a3 == ohVar.s) ? false : true; oh ohVar2 = this.y; this.y = a(ohVar2.b, a3, ohVar2.c, ohVar2.d, z2, 5); if (z2) { c(a3); } boolean[] zArr2 = new boolean[this.a.length]; int i = 0; while (true) { qi[] qiVarArr = this.a; if (i >= qiVarArr.length) { break; } qi qiVar = qiVarArr[i]; boolean c2 = c(qiVar); zArr2[i] = c2; cj cjVar = e3.c[i]; if (c2) { if (cjVar != qiVar.o()) { a(qiVar); } else if (zArr[i]) { qiVar.a(this.M); } } i++; } a(zArr2); } else { this.t.a(e2); if (e2.d) { e2.a(b2, Math.max(e2.f.b, e2.d(this.M)), false); } } a(true); if (this.y.e != 4) { m(); K(); this.i.c(2); return; } return; } if (e2 == f3) { z = false; } } } private void t() { for (xd e2 = this.t.e(); e2 != null; e2 = e2.d()) { for (h8 h8Var : e2.i().c) { if (h8Var != null) { h8Var.j(); } } } } private boolean k() { xd e2 = this.t.e(); long j = e2.f.e; return e2.d && (j == C.TIME_UNSET || this.y.s < j || !E()); } private long f() { xd f2 = this.t.f(); if (f2 == null) { return 0L; } long f3 = f2.f(); if (!f2.d) { return f3; } int i = 0; while (true) { qi[] qiVarArr = this.a; if (i >= qiVarArr.length) { return f3; } if (c(qiVarArr[i]) && this.a[i].o() == f2.c[i]) { long i2 = this.a[i].i(); if (i2 == Long.MIN_VALUE) { return Long.MIN_VALUE; } f3 = Math.max(i2, f3); } i++; } } private void J() { if (this.y.a.c() || !this.u.d()) { return; } o(); q(); r(); p(); } private void o() { zd a2; this.t.a(this.M); if (this.t.h() && (a2 = this.t.a(this.M, this.y)) != null) { xd a3 = this.t.a(this.c, this.d, this.g.b(), this.u, a2, this.f); a3.a.a(this, a2.b); if (this.t.e() == a3) { c(a3.g()); } a(false); } if (this.E) { this.E = j(); I(); } else { m(); } } private void q() { xd f2 = this.t.f(); if (f2 == null) { return; } int i = 0; if (f2.d() != null && !this.C) { if (i()) { if (f2.d().d || this.M >= f2.d().g()) { wo i2 = f2.i(); xd b2 = this.t.b(); wo i3 = b2.i(); if (b2.d && b2.a.h() != C.TIME_UNSET) { d(b2.g()); return; } for (int i4 = 0; i4 < this.a.length; i4++) { boolean a2 = i2.a(i4); boolean a3 = i3.a(i4); if (a2 && !this.a[i4].k()) { boolean z = this.c[i4].e() == -2; si siVar = i2.b[i4]; si siVar2 = i3.b[i4]; if (!a3 || !siVar2.equals(siVar) || z) { a(this.a[i4], b2.g()); } } } return; } return; } return; } if (!f2.f.i && !this.C) { return; } while (true) { qi[] qiVarArr = this.a; if (i >= qiVarArr.length) { return; } qi qiVar = qiVarArr[i]; cj cjVar = f2.c[i]; if (cjVar != null && qiVar.o() == cjVar && qiVar.j()) { long j = f2.f.e; a(qiVar, (j == C.TIME_UNSET || j == Long.MIN_VALUE) ? -9223372036854775807L : f2.f() + f2.f.e); } i++; } } private void r() { xd f2 = this.t.f(); if (f2 == null || this.t.e() == f2 || f2.g || !z()) { return; } d(); } private boolean z() { xd f2 = this.t.f(); wo i = f2.i(); int i2 = 0; boolean z = false; while (true) { qi[] qiVarArr = this.a; if (i2 >= qiVarArr.length) { return !z; } qi qiVar = qiVarArr[i2]; if (c(qiVar)) { boolean z2 = qiVar.o() != f2.c[i2]; if (!i.a(i2) || z2) { if (!qiVar.k()) { qiVar.a(a(i.c[i2]), f2.c[i2], f2.g(), f2.f()); } else if (qiVar.c()) { a(qiVar); } else { z = true; } } } i2++; } } private void p() { boolean z = false; while (C()) { if (z) { n(); } xd e2 = this.t.e(); xd a2 = this.t.a(); zd zdVar = a2.f; be.a aVar = zdVar.a; long j = zdVar.b; oh a3 = a(aVar, j, zdVar.c, j, true, 0); this.y = a3; fo foVar = a3.a; a(foVar, a2.f.a, foVar, e2.f.a, C.TIME_UNSET); B(); K(); z = true; } } private void B() { xd e2 = this.t.e(); this.C = e2 != null && e2.f.h && this.B; } private boolean C() { xd e2; xd d2; return E() && !this.C && (e2 = this.t.e()) != null && (d2 = e2.d()) != null && this.M >= d2.g() && d2.g; } private boolean i() { xd f2 = this.t.f(); if (!f2.d) { return false; } int i = 0; while (true) { qi[] qiVarArr = this.a; if (i >= qiVarArr.length) { return true; } qi qiVar = qiVarArr[i]; cj cjVar = f2.c[i]; if (qiVar.o() != cjVar || (cjVar != null && !qiVar.j() && !a(qiVar, f2))) { break; } i++; } return false; } private void m() { boolean D = D(); this.E = D; if (D) { this.t.d().a(this.M); } I(); } private boolean D() { long d2; if (!j()) { return false; } xd d3 = this.t.d(); long b2 = b(d3.e()); if (d3 == this.t.e()) { d2 = d3.d(this.M); } else { d2 = d3.d(this.M) - d3.f.b; } return this.g.a(d2, b2, this.p.a().a); } private boolean j() { xd d2 = this.t.d(); return (d2 == null || d2.e() == Long.MIN_VALUE) ? false : true; } private void I() { xd d2 = this.t.d(); boolean z = this.E || (d2 != null && d2.a.a()); oh ohVar = this.y; if (z != ohVar.g) { this.y = ohVar.a(z); } } private void d() { a(new boolean[this.a.length]); } private void b(rh rhVar) { if (rhVar.i()) { return; } try { rhVar.e().a(rhVar.g(), rhVar.c()); } finally { rhVar.a(true); } } public class a implements qi.a { public a() { } @Override // com.applovin.impl.qi.a public void a(long j) { if (j >= 2000) { e8.this.I = true; } } @Override // com.applovin.impl.qi.a public void a() { e8.this.i.c(2); } } private long h() { return b(this.y.q); } private void a(qi qiVar) { if (c(qiVar)) { this.p.a(qiVar); b(qiVar); qiVar.f(); this.K--; } } private boolean E() { oh ohVar = this.y; return ohVar.l && ohVar.m == 0; } private void e(rh rhVar) { if (rhVar.b() == this.k) { b(rhVar); int i = this.y.e; if (i == 3 || i == 2) { this.i.c(2); return; } return; } this.i.a(15, rhVar).a(); } private void a(boolean z, boolean z2) { a(z || !this.H, false, true, false); this.z.a(z2 ? 1 : 0); this.g.c(); c(1); } @Override // com.applovin.impl.pj.a /* renamed from: d, reason: merged with bridge method [inline-methods] */ public void a(wd wdVar) { this.i.a(9, wdVar).a(); } public static final class h { public final fo a; public final int b; public final long c; public h(fo foVar, int i, long j) { this.a = foVar; this.b = i; this.c = j; } } public static final class g { public final be.a a; public final long b; public final long c; public final boolean d; public final boolean e; public final boolean f; public g(be.a aVar, long j, long j2, boolean z, boolean z2, boolean z3) { this.a = aVar; this.b = j; this.c = j2; this.d = z; this.e = z2; this.f = z3; } } public static final class d implements Comparable { public final rh a; public int b; public long c; public Object d; public void a(int i, long j, Object obj) { this.b = i; this.c = j; this.d = obj; } public d(rh rhVar) { this.a = rhVar; } @Override // java.lang.Comparable /* renamed from: a, reason: merged with bridge method [inline-methods] */ public int compareTo(d dVar) { Object obj = this.d; if ((obj == null) != (dVar.d == null)) { return obj != null ? -1 : 1; } if (obj == null) { return 0; } int i = this.b - dVar.b; return i != 0 ? i : xp.a(this.c, dVar.c); } } public static final class b { private final List a; private final wj b; private final int c; private final long d; private b(List list, wj wjVar, int i, long j) { this.a = list; this.b = wjVar; this.c = i; this.d = j; } public /* synthetic */ b(List list, wj wjVar, int i, long j, a aVar) { this(list, wjVar, i, j); } } private void c(wd wdVar) { if (this.t.a(wdVar)) { xd d2 = this.t.d(); d2.a(this.p.a().a, this.y.a); a(d2.h(), d2.i()); if (d2 == this.t.e()) { c(d2.f.b); d(); oh ohVar = this.y; be.a aVar = ohVar.b; long j = d2.f.b; this.y = a(aVar, j, ohVar.c, j, false, 5); } m(); } } private void e(boolean z) { this.B = z; B(); if (!this.C || this.t.f() == this.t.e()) { return; } c(true); a(false); } private void f(final rh rhVar) { Looper b2 = rhVar.b(); if (!b2.getThread().isAlive()) { pc.d("TAG", "Trying to send message on a dead thread."); rhVar.a(false); } else { this.r.a(b2, null).a(new Runnable() { // from class: com.applovin.impl.e8$$ExternalSyntheticLambda0 @Override // java.lang.Runnable public final void run() { e8.this.c(rhVar); } }); } } public void f(boolean z) { this.i.a(12, z ? 1 : 0, 0).a(); } private void b(qi qiVar) { if (qiVar.b() == 2) { qiVar.stop(); } } private boolean h(boolean z) { if (this.K == 0) { return k(); } if (!z) { return false; } oh ohVar = this.y; if (!ohVar.g) { return true; } long b2 = a(ohVar.a, this.t.e().f.a) ? this.v.b() : C.TIME_UNSET; xd d2 = this.t.d(); return (d2.j() && d2.f.i) || (d2.f.a.a() && !d2.d) || this.g.a(h(), this.p.a().a, this.D, b2); } private void d(rh rhVar) { if (rhVar.d() == C.TIME_UNSET) { e(rhVar); return; } if (this.y.a.c()) { this.q.add(new d(rhVar)); return; } d dVar = new d(rhVar); fo foVar = this.y.a; if (a(dVar, foVar, foVar, this.F, this.G, this.l, this.m)) { this.q.add(dVar); Collections.sort(this.q); } else { rhVar.a(false); } } private void a(fo foVar, be.a aVar, fo foVar2, be.a aVar2, long j) { if (!foVar.c() && a(foVar, aVar)) { foVar.a(foVar.a(aVar.a, this.m).c, this.l); this.v.a((td.f) xp.a(this.l.l)); if (j != C.TIME_UNSET) { this.v.a(a(foVar, aVar.a, j)); return; } if (xp.a(!foVar2.c() ? foVar2.a(foVar2.a(aVar2.a, this.m).c, this.l).a : null, this.l.a)) { return; } this.v.a(C.TIME_UNSET); return; } float f2 = this.p.a().a; ph phVar = this.y.n; if (f2 != phVar.a) { this.p.a(phVar); } } private void a(int i, boolean z) { qi qiVar = this.a[i]; if (c(qiVar)) { return; } xd f2 = this.t.f(); boolean z2 = f2 == this.t.e(); wo i2 = f2.i(); si siVar = i2.b[i]; f9[] a2 = a(i2.c[i]); boolean z3 = E() && this.y.e == 3; boolean z4 = !z && z3; this.K++; this.b.add(qiVar); qiVar.a(siVar, a2, f2.c[i], this.M, z4, z2, f2.g(), f2.f()); qiVar.a(11, new a()); this.p.b(qiVar); if (z3) { qiVar.start(); } } private static boolean c(qi qiVar) { return qiVar.b() != 0; } private void d(long j) { for (qi qiVar : this.a) { if (qiVar.o() != null) { a(qiVar, j); } } } private long b(long j) { xd d2 = this.t.d(); if (d2 == null) { return 0L; } return Math.max(0L, j - d2.d(this.M)); } private void a(po poVar, wo woVar) { this.g.a(this.a, poVar, woVar.c); } private void d(boolean z) { if (z == this.J) { return; } this.J = z; oh ohVar = this.y; int i = ohVar.e; if (!z && i != 4 && i != 1) { this.i.c(2); } else { this.y = ohVar.b(z); } } private void a(boolean[] zArr) { xd f2 = this.t.f(); wo i = f2.i(); for (int i2 = 0; i2 < this.a.length; i2++) { if (!i.a(i2) && this.b.remove(this.a[i2])) { this.a[i2].reset(); } } for (int i3 = 0; i3 < this.a.length; i3++) { if (i.a(i3)) { a(i3, zArr[i3]); } } f2.g = true; } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void c(rh rhVar) { try { b(rhVar); } catch (a8 e2) { pc.a("ExoPlayerImplInternal", "Unexpected error delivering message on external thread.", e2); throw new RuntimeException(e2); } } private void b(wd wdVar) { if (this.t.a(wdVar)) { this.t.a(this.M); m(); } } private void a(float f2) { for (xd e2 = this.t.e(); e2 != null; e2 = e2.d()) { for (h8 h8Var : e2.i().c) { if (h8Var != null) { h8Var.a(f2); } } } } private void c(long j) { xd e2 = this.t.e(); if (e2 != null) { j = e2.e(j); } this.M = j; this.p.a(j); for (qi qiVar : this.a) { if (c(qiVar)) { qiVar.a(this.M); } } t(); } private synchronized void a(Supplier supplier, long j) { long c2 = this.r.c() + j; boolean z = false; while (!((Boolean) supplier.get()).booleanValue() && j > 0) { try { this.r.b(); wait(j); } catch (InterruptedException unused) { z = true; } j = c2 - this.r.c(); } if (z) { Thread.currentThread().interrupt(); } } private eb a(h8[] h8VarArr) { eb.a aVar = new eb.a(); boolean z = false; for (h8 h8Var : h8VarArr) { if (h8Var != null) { bf bfVar = h8Var.a(0).k; if (bfVar == null) { aVar.b(new bf(new bf.b[0])); } else { aVar.b(bfVar); z = true; } } } return z ? aVar.a() : eb.h(); } private void c(long j, long j2) { this.i.b(2); this.i.a(2, j + j2); } private void b(long j, long j2) { e8 e8Var; d dVar; if (this.q.isEmpty() || this.y.b.a()) { return; } if (this.O) { j--; this.O = false; } oh ohVar = this.y; int a2 = ohVar.a.a(ohVar.b.a); int min = Math.min(this.N, this.q.size()); d dVar2 = min > 0 ? (d) this.q.get(min - 1) : null; while (dVar2 != null) { int i = dVar2.b; if (i <= a2 && (i != a2 || dVar2.c <= j)) { break; } int i2 = min - 1; dVar2 = i2 > 0 ? (d) this.q.get(min - 2) : null; min = i2; } if (min < this.q.size()) { dVar = (d) this.q.get(min); e8Var = this; } else { e8Var = this; dVar = null; } while (dVar != null && dVar.d != null) { int i3 = dVar.b; if (i3 >= a2 && (i3 != a2 || dVar.c > j)) { break; } min++; if (min < e8Var.q.size()) { dVar = (d) e8Var.q.get(min); } else { e8Var = e8Var; dVar = null; } } while (dVar != null && dVar.d != null && dVar.b == a2) { long j3 = dVar.c; if (j3 <= j || j3 > j2) { break; } try { e8Var.e(dVar.a); if (dVar.a.a() || dVar.a.i()) { e8Var.q.remove(min); } else { min++; } dVar = min < e8Var.q.size() ? (d) e8Var.q.get(min) : null; } catch (Throwable th) { if (dVar.a.a() || dVar.a.i()) { e8Var.q.remove(min); } throw th; } } e8Var.N = min; } private void c(boolean z) { be.a aVar = this.t.e().f.a; long a2 = a(aVar, this.y.s, true, false); if (a2 != this.y.s) { oh ohVar = this.y; this.y = a(aVar, a2, ohVar.c, ohVar.d, z, 5); } } private void b(boolean z) { for (xd e2 = this.t.e(); e2 != null; e2 = e2.d()) { for (h8 h8Var : e2.i().c) { if (h8Var != null) { h8Var.a(z); } } } } public void b(int i, int i2, wj wjVar) { this.i.a(20, i, i2, wjVar).a(); } private void c(int i) { oh ohVar = this.y; if (ohVar.e != i) { this.y = ohVar.a(i); } } private void b(ph phVar) { this.p.a(phVar); a(this.p.a(), true); } private static f9[] a(h8 h8Var) { int b2 = h8Var != null ? h8Var.b() : 0; f9[] f9VarArr = new f9[b2]; for (int i = 0; i < b2; i++) { f9VarArr[i] = h8Var.a(i); } return f9VarArr; } private void b(int i) { this.F = i; if (!this.t.a(this.y.a, i)) { c(true); } a(false); } private long a(fo foVar, Object obj, long j) { foVar.a(foVar.a(obj, this.m).c, this.l); fo.d dVar = this.l; if (dVar.g != C.TIME_UNSET && dVar.e()) { fo.d dVar2 = this.l; if (dVar2.j) { return t2.a(dVar2.a() - this.l.g) - (j + this.m.e()); } } return C.TIME_UNSET; } private Pair a(fo foVar) { long j = 0; if (foVar.c()) { return Pair.create(oh.a(), 0L); } Pair a2 = foVar.a(this.l, this.m, foVar.a(this.G), C.TIME_UNSET); be.a a3 = this.t.a(foVar, a2.first, 0L); long longValue = ((Long) a2.second).longValue(); if (a3.a()) { foVar.a(a3.a, this.m); if (a3.c == this.m.d(a3.b)) { j = this.m.b(); } } else { j = longValue; } return Pair.create(a3, Long.valueOf(j)); } private void a(IOException iOException, int i) { a8 a2 = a8.a(iOException, i); xd e2 = this.t.e(); if (e2 != null) { a2 = a2.a(e2.f.a); } pc.a("ExoPlayerImplInternal", "Playback error", a2); a(false, false); this.y = this.y.a(a2); } private void a(boolean z) { long c2; xd d2 = this.t.d(); be.a aVar = d2 == null ? this.y.b : d2.f.a; boolean z2 = !this.y.k.equals(aVar); if (z2) { this.y = this.y.a(aVar); } oh ohVar = this.y; if (d2 == null) { c2 = ohVar.s; } else { c2 = d2.c(); } ohVar.q = c2; this.y.r = h(); if ((z2 || z) && d2 != null && d2.d) { a(d2.h(), d2.i()); } } private void a(fo foVar, boolean z) { int i; int i2; boolean z2; g a2 = a(foVar, this.y, this.L, this.t, this.F, this.G, this.l, this.m); be.a aVar = a2.a; long j = a2.c; boolean z3 = a2.d; long j2 = a2.b; boolean z4 = (this.y.b.equals(aVar) && j2 == this.y.s) ? false : true; h hVar = null; long j3 = C.TIME_UNSET; try { if (a2.e) { if (this.y.e != 1) { c(4); } a(false, false, false, true); } try { if (!z4) { try { try { i2 = 4; z2 = false; if (!this.t.a(foVar, this.M, f())) { c(false); } } catch (Throwable th) { th = th; i = 4; hVar = null; oh ohVar = this.y; fo foVar2 = ohVar.a; be.a aVar2 = ohVar.b; if (a2.f) { j3 = j2; } h hVar2 = hVar; a(foVar, aVar, foVar2, aVar2, j3); if (z4 || j != this.y.c) { oh ohVar2 = this.y; Object obj = ohVar2.b.a; fo foVar3 = ohVar2.a; this.y = a(aVar, j2, j, this.y.d, z4 && z && !foVar3.c() && !foVar3.a(obj, this.m).g, foVar.a(obj) == -1 ? i : 3); } B(); a(foVar, this.y.a); this.y = this.y.a(foVar); if (!foVar.c()) { this.L = hVar2; } a(false); throw th; } } catch (Throwable th2) { th = th2; i = 4; } } else { i2 = 4; z2 = false; if (!foVar.c()) { for (xd e2 = this.t.e(); e2 != null; e2 = e2.d()) { if (e2.f.a.equals(aVar)) { e2.f = this.t.a(foVar, e2.f); e2.m(); } } j2 = a(aVar, j2, z3); } } oh ohVar3 = this.y; a(foVar, aVar, ohVar3.a, ohVar3.b, a2.f ? j2 : -9223372036854775807L); if (z4 || j != this.y.c) { oh ohVar4 = this.y; Object obj2 = ohVar4.b.a; fo foVar4 = ohVar4.a; this.y = a(aVar, j2, j, this.y.d, (!z4 || !z || foVar4.c() || foVar4.a(obj2, this.m).g) ? z2 : true, foVar.a(obj2) == -1 ? i2 : 3); } B(); a(foVar, this.y.a); this.y = this.y.a(foVar); if (!foVar.c()) { this.L = null; } a(z2); } catch (Throwable th3) { th = th3; } } catch (Throwable th4) { th = th4; i = 4; } } private void a(ph phVar, float f2, boolean z, boolean z2) { if (z) { if (z2) { this.z.a(1); } this.y = this.y.a(phVar); } a(phVar.a); for (qi qiVar : this.a) { if (qiVar != null) { qiVar.a(f2, phVar.a); } } } private void a(ph phVar, boolean z) { a(phVar, phVar.a, true, z); } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r1v4, types: [java.util.List] */ private oh a(be.a aVar, long j, long j2, long j3, boolean z, int i) { eb ebVar; po poVar; wo woVar; po h2; this.O = (!this.O && j == this.y.s && aVar.equals(this.y.b)) ? false : true; B(); oh ohVar = this.y; po poVar2 = ohVar.h; wo woVar2 = ohVar.i; ?? r1 = ohVar.j; if (this.u.d()) { xd e2 = this.t.e(); if (e2 == null) { h2 = po.d; } else { h2 = e2.h(); } wo i2 = e2 == null ? this.f : e2.i(); eb a2 = a(i2.c); if (e2 != null) { zd zdVar = e2.f; if (zdVar.c != j2) { e2.f = zdVar.a(j2); } } poVar = h2; woVar = i2; ebVar = a2; } else if (aVar.equals(this.y.b)) { ebVar = r1; poVar = poVar2; woVar = woVar2; } else { poVar = po.d; woVar = this.f; ebVar = eb.h(); } if (z) { this.z.c(i); } return this.y.a(aVar, j, j2, j3, h(), poVar, woVar, ebVar); } private boolean a(qi qiVar, xd xdVar) { xd d2 = xdVar.d(); return xdVar.f.f && d2.d && ((qiVar instanceof bo) || qiVar.i() >= d2.g()); } private static boolean a(oh ohVar, fo.b bVar) { be.a aVar = ohVar.b; fo foVar = ohVar.a; return foVar.c() || foVar.a(aVar.a, bVar).g; } private boolean a(long j, long j2) { if (this.J && this.I) { return false; } c(j, j2); return true; } private void a(c cVar) { this.z.a(1); throw null; } @Override // com.applovin.impl.h6.a public void a(ph phVar) { this.i.a(16, phVar).a(); } @Override // com.applovin.impl.fe.d public void a() { this.i.c(22); } @Override // com.applovin.impl.wd.a public void a(wd wdVar) { this.i.a(8, wdVar).a(); } private void a(int i, int i2, wj wjVar) { this.z.a(1); a(this.u.a(i, i2, wjVar), false); } /* JADX WARN: Removed duplicated region for block: B:44:0x00be */ /* JADX WARN: Removed duplicated region for block: B:47:0x00c7 */ /* JADX WARN: Removed duplicated region for block: B:50:0x00d0 */ /* JADX WARN: Removed duplicated region for block: B:54:0x00fe */ /* JADX WARN: Removed duplicated region for block: B:57:? A[RETURN, SYNTHETIC] */ /* JADX WARN: Removed duplicated region for block: B:58:0x00d7 */ /* JADX WARN: Removed duplicated region for block: B:59:0x00cb */ /* JADX WARN: Removed duplicated region for block: B:60:0x00c2 */ /* JADX WARN: Removed duplicated region for block: B:61:0x00b8 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private void a(boolean r30, boolean r31, boolean r32, boolean r33) { /* Method dump skipped, instructions count: 260 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.e8.a(boolean, boolean, boolean, boolean):void"); } private static void a(fo foVar, d dVar, fo.d dVar2, fo.b bVar) { int i = foVar.a(foVar.a(dVar.d, bVar).c, dVar2).q; Object obj = foVar.a(i, bVar, true).b; long j = bVar.d; dVar.a(i, j != C.TIME_UNSET ? j - 1 : Long.MAX_VALUE, obj); } private static boolean a(d dVar, fo foVar, fo foVar2, int i, boolean z, fo.d dVar2, fo.b bVar) { Object obj = dVar.d; if (obj == null) { Pair a2 = a(foVar, new h(dVar.a.f(), dVar.a.h(), dVar.a.d() == Long.MIN_VALUE ? C.TIME_UNSET : t2.a(dVar.a.d())), false, i, z, dVar2, bVar); if (a2 == null) { return false; } dVar.a(foVar.a(a2.first), ((Long) a2.second).longValue(), a2.first); if (dVar.a.d() == Long.MIN_VALUE) { a(foVar, dVar, dVar2, bVar); } return true; } int a3 = foVar.a(obj); if (a3 == -1) { return false; } if (dVar.a.d() == Long.MIN_VALUE) { a(foVar, dVar, dVar2, bVar); return true; } dVar.b = a3; foVar2.a(dVar.d, bVar); if (bVar.g && foVar2.a(bVar.c, dVar2).p == foVar2.a(dVar.d)) { Pair a4 = foVar.a(dVar2, bVar, foVar.a(dVar.d, bVar).c, dVar.c + bVar.e()); dVar.a(foVar.a(a4.first), ((Long) a4.second).longValue(), a4.first); } return true; } private void a(fo foVar, fo foVar2) { if (foVar.c() && foVar2.c()) { return; } for (int size = this.q.size() - 1; size >= 0; size--) { if (!a((d) this.q.get(size), foVar, foVar2, this.F, this.G, this.l, this.m)) { ((d) this.q.get(size)).a.a(false); this.q.remove(size); } } Collections.sort(this.q); } /* JADX WARN: Removed duplicated region for block: B:18:0x015a */ /* JADX WARN: Removed duplicated region for block: B:21:0x0184 */ /* JADX WARN: Removed duplicated region for block: B:28:0x019a */ /* JADX WARN: Removed duplicated region for block: B:36:0x01b2 A[ADDED_TO_REGION] */ /* JADX WARN: Removed duplicated region for block: B:49:0x01d8 A[ADDED_TO_REGION] */ /* JADX WARN: Removed duplicated region for block: B:52:0x01e1 */ /* JADX WARN: Removed duplicated region for block: B:65:0x0178 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static com.applovin.impl.e8.g a(com.applovin.impl.fo r30, com.applovin.impl.oh r31, com.applovin.impl.e8.h r32, com.applovin.impl.ae r33, int r34, boolean r35, com.applovin.impl.fo.d r36, com.applovin.impl.fo.b r37) { /* Method dump skipped, instructions count: 525 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.e8.a(com.applovin.impl.fo, com.applovin.impl.oh, com.applovin.impl.e8$h, com.applovin.impl.ae, int, boolean, com.applovin.impl.fo$d, com.applovin.impl.fo$b):com.applovin.impl.e8$g"); } private static Pair a(fo foVar, h hVar, boolean z, int i, boolean z2, fo.d dVar, fo.b bVar) { Pair a2; Object a3; fo foVar2 = hVar.a; if (foVar.c()) { return null; } fo foVar3 = foVar2.c() ? foVar : foVar2; try { a2 = foVar3.a(dVar, bVar, hVar.b, hVar.c); } catch (IndexOutOfBoundsException unused) { } if (foVar.equals(foVar3)) { return a2; } if (foVar.a(a2.first) != -1) { return (foVar3.a(a2.first, bVar).g && foVar3.a(bVar.c, dVar).p == foVar3.a(a2.first)) ? foVar.a(dVar, bVar, foVar.a(a2.first, bVar).c, hVar.c) : a2; } if (z && (a3 = a(dVar, bVar, i, z2, a2.first, foVar3, foVar)) != null) { return foVar.a(dVar, bVar, foVar.a(a3, bVar).c, C.TIME_UNSET); } return null; } public static Object a(fo.d dVar, fo.b bVar, int i, boolean z, Object obj, fo foVar, fo foVar2) { int a2 = foVar.a(obj); int a3 = foVar.a(); int i2 = a2; int i3 = -1; for (int i4 = 0; i4 < a3 && i3 == -1; i4++) { i2 = foVar.a(i2, bVar, dVar, i, z); if (i2 == -1) { break; } i3 = foVar2.a(foVar.b(i2)); } if (i3 == -1) { return null; } return foVar2.b(i3); } public void a(fo foVar, int i, long j) { this.i.a(3, new h(foVar, i, j)).a(); } private void a(h hVar) { long j; long j2; boolean z; be.a aVar; long j3; long j4; long j5; oh ohVar; int i; this.z.a(1); Pair a2 = a(this.y.a, hVar, true, this.F, this.G, this.l, this.m); if (a2 == null) { Pair a3 = a(this.y.a); aVar = (be.a) a3.first; long longValue = ((Long) a3.second).longValue(); z = !this.y.a.c(); j = longValue; j2 = -9223372036854775807L; } else { Object obj = a2.first; long longValue2 = ((Long) a2.second).longValue(); long j6 = hVar.c == C.TIME_UNSET ? -9223372036854775807L : longValue2; be.a a4 = this.t.a(this.y.a, obj, longValue2); if (a4.a()) { this.y.a.a(a4.a, this.m); longValue2 = this.m.d(a4.b) == a4.c ? this.m.b() : 0L; } else if (hVar.c != C.TIME_UNSET) { j = longValue2; j2 = j6; z = false; aVar = a4; } j = longValue2; j2 = j6; aVar = a4; z = true; } try { if (this.y.a.c()) { this.L = hVar; } else if (a2 == null) { if (this.y.e != 1) { c(4); } a(false, true, false, true); } else { if (aVar.equals(this.y.b)) { xd e2 = this.t.e(); j4 = (e2 == null || !e2.d || j == 0) ? j : e2.a.a(j, this.x); if (t2.b(j4) == t2.b(this.y.s) && ((i = (ohVar = this.y).e) == 2 || i == 3)) { long j7 = ohVar.s; this.y = a(aVar, j7, j2, j7, z, 2); return; } } else { j4 = j; } long a5 = a(aVar, j4, this.y.e == 4); boolean z2 = (j != a5) | z; try { oh ohVar2 = this.y; fo foVar = ohVar2.a; a(foVar, aVar, foVar, ohVar2.b, j2); z = z2; j5 = a5; this.y = a(aVar, j5, j2, j5, z, 2); } catch (Throwable th) { th = th; z = z2; j3 = a5; this.y = a(aVar, j3, j2, j3, z, 2); throw th; } } j5 = j; this.y = a(aVar, j5, j2, j5, z, 2); } catch (Throwable th2) { th = th2; j3 = j; } } private long a(be.a aVar, long j, boolean z) { return a(aVar, j, this.t.e() != this.t.f(), z); } private long a(be.a aVar, long j, boolean z, boolean z2) { H(); this.D = false; if (z2 || this.y.e == 3) { c(2); } xd e2 = this.t.e(); xd xdVar = e2; while (xdVar != null && !aVar.equals(xdVar.f.a)) { xdVar = xdVar.d(); } if (z || e2 != xdVar || (xdVar != null && xdVar.e(j) < 0)) { for (qi qiVar : this.a) { a(qiVar); } if (xdVar != null) { while (this.t.e() != xdVar) { this.t.a(); } this.t.a(xdVar); xdVar.c(0L); d(); } } if (xdVar != null) { this.t.a(xdVar); if (!xdVar.d) { xdVar.f = xdVar.f.b(j); } else if (xdVar.e) { j = xdVar.a.a(j); xdVar.a.a(j - this.n, this.o); } c(j); m(); } else { this.t.c(); c(j); } a(false); this.i.c(2); return j; } @Override // com.applovin.impl.rh.a public synchronized void a(rh rhVar) { if (!this.A && this.j.isAlive()) { this.i.a(14, rhVar).a(); return; } pc.d("ExoPlayerImplInternal", "Ignoring messages sent after release."); rhVar.a(false); } private void a(qi qiVar, long j) { qiVar.g(); if (qiVar instanceof bo) { ((bo) qiVar).c(j); } } private void a(boolean z, AtomicBoolean atomicBoolean) { if (this.H != z) { this.H = z; if (!z) { for (qi qiVar : this.a) { if (!c(qiVar) && this.b.remove(qiVar)) { qiVar.reset(); } } } } if (atomicBoolean != null) { synchronized (this) { atomicBoolean.set(true); notifyAll(); } } } private void a(b bVar) { this.z.a(1); if (bVar.c != -1) { this.L = new h(new sh(bVar.a, bVar.b), bVar.c, bVar.d); } a(this.u.a(bVar.a, bVar.b), false); } public void a(List list, int i, long j, wj wjVar) { this.i.a(17, new b(list, wjVar, i, j, null)).a(); } public void a(boolean z, int i) { this.i.a(1, z ? 1 : 0, i).a(); } private void a(boolean z, int i, boolean z2, int i2) { this.z.a(z2 ? 1 : 0); this.z.b(i2); this.y = this.y.a(z, i); this.D = false; b(z); if (!E()) { H(); K(); return; } int i3 = this.y.e; if (i3 == 3) { F(); this.i.c(2); } else if (i3 == 2) { this.i.c(2); } } public void a(int i) { this.i.a(11, i, 0).a(); } }