package uc; import ai.clova.cic.clientlib.builtins.audio.echocanceller.AcousticEchoCanceller; import ai.clova.cic.clientlib.exoplayer2.C; import android.content.Context; import android.media.AudioManager; import android.media.AudioTrack; import android.net.wifi.WifiManager; import android.os.Handler; import android.os.PowerManager; import android.util.SparseBooleanArray; import android.view.Surface; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.UUID; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.TimeoutException; import o32.a; public final class h5 extends g2 { /* renamed from: b reason: collision with root package name */ public final a5[] f156733b; /* renamed from: c reason: collision with root package name */ public final u6 f156734c = new u6(s6.f161688a); /* renamed from: d reason: collision with root package name */ public final d3 f156735d; /* renamed from: e reason: collision with root package name */ public final f5 f156736e; /* renamed from: f reason: collision with root package name */ public final g5 f156737f; /* renamed from: g reason: collision with root package name */ public final CopyOnWriteArraySet<t4> f156738g; /* renamed from: h reason: collision with root package name */ public final an0 f156739h; /* renamed from: i reason: collision with root package name */ public final f2 f156740i; /* renamed from: j reason: collision with root package name */ public final k5 f156741j; /* renamed from: k reason: collision with root package name */ public AudioTrack f156742k; /* renamed from: l reason: collision with root package name */ public Object f156743l; /* renamed from: m reason: collision with root package name */ public Surface f156744m; /* renamed from: n reason: collision with root package name */ public int f156745n; /* renamed from: o reason: collision with root package name */ public int f156746o; /* renamed from: p reason: collision with root package name */ public int f156747p; /* renamed from: q reason: collision with root package name */ public int f156748q; /* renamed from: r reason: collision with root package name */ public za2 f156749r; /* renamed from: s reason: collision with root package name */ public float f156750s; /* renamed from: t reason: collision with root package name */ public boolean f156751t; /* renamed from: u reason: collision with root package name */ public List f156752u; /* renamed from: v reason: collision with root package name */ public boolean f156753v; /* renamed from: w reason: collision with root package name */ public boolean f156754w; /* renamed from: x reason: collision with root package name */ public o2 f156755x; public h5(e5 e5Var) { h5 h5Var; Throwable th4; d3 d3Var; int i14; try { Context applicationContext = e5Var.f155564a.getApplicationContext(); this.f156739h = e5Var.f155571h; this.f156749r = e5Var.f155573j; this.f156745n = 1; this.f156751t = false; f5 f5Var = new f5(this); this.f156736e = f5Var; this.f156737f = new g5(); this.f156738g = new CopyOnWriteArraySet<>(); Handler handler = new Handler(e5Var.f155572i); this.f156733b = e5Var.f155565b.d(handler, f5Var, f5Var, f5Var, f5Var); this.f156750s = 1.0f; if (d8.f155212a < 21) { AudioTrack audioTrack = this.f156742k; if (!(audioTrack == null || audioTrack.getAudioSessionId() == 0)) { this.f156742k.release(); this.f156742k = null; } if (this.f156742k == null) { this.f156742k = new AudioTrack(3, AcousticEchoCanceller.SAMPLE_RATE_HZ_MIN, 4, 2, 2, 0, 0); } this.f156748q = this.f156742k.getAudioSessionId(); } else { UUID uuid = i2.f157161a; int i15 = d8.f155212a; AudioManager audioManager = (AudioManager) applicationContext.getSystemService("audio"); if (audioManager == null) { i14 = -1; } else { i14 = audioManager.generateAudioSessionId(); } this.f156748q = i14; } this.f156752u = Collections.emptyList(); this.f156753v = true; SparseBooleanArray sparseBooleanArray = new SparseBooleanArray(); int[] iArr = {20, 21, 22, 23, 24, 25, 26, 27}; for (int i16 = 0; i16 < 8; i16++) { int i17 = iArr[i16]; r52.e(!false); sparseBooleanArray.append(i17, true); } r52.e(!false); try { d3Var = new d3(this.f156733b, e5Var.f155567d, e5Var.f155568e, e5Var.f155569f, e5Var.f155570g, this.f156739h, true, e5Var.f155574k, e5Var.f155576m, false, e5Var.f155566c, e5Var.f155572i, this, new r4(new a7(sparseBooleanArray)), null); h5Var = this; } catch (Throwable th5) { th4 = th5; h5Var = this; h5Var.f156734c.a(); throw th4; } try { h5Var.f156735d = d3Var; d3Var.f155174i.a(h5Var.f156736e); d3Var.f155175j.add(h5Var.f156736e); new b2(e5Var.f155564a, handler, h5Var.f156736e); h5Var.f156740i = new f2(e5Var.f155564a, handler, h5Var.f156736e); d8.l(null, null); k5 k5Var = new k5(e5Var.f155564a, handler, h5Var.f156736e); h5Var.f156741j = k5Var; Objects.requireNonNull(h5Var.f156749r); k5Var.a(3); PowerManager powerManager = (PowerManager) e5Var.f155564a.getApplicationContext().getSystemService("power"); WifiManager wifiManager = (WifiManager) e5Var.f155564a.getApplicationContext().getSystemService("wifi"); h5Var.f156755x = N(k5Var); h5Var.M(1, 10, Integer.valueOf(h5Var.f156748q)); h5Var.M(2, 10, Integer.valueOf(h5Var.f156748q)); h5Var.M(1, 3, h5Var.f156749r); h5Var.M(2, 4, Integer.valueOf(h5Var.f156745n)); h5Var.M(2, 5, 0); h5Var.M(1, 9, Boolean.valueOf(h5Var.f156751t)); h5Var.M(2, 7, h5Var.f156737f); h5Var.M(6, 8, h5Var.f156737f); h5Var.f156734c.a(); } catch (Throwable th6) { th4 = th6; h5Var.f156734c.a(); throw th4; } } catch (Throwable th7) { th4 = th7; h5Var = this; h5Var.f156734c.a(); throw th4; } } public static void H(h5 h5Var) { int F = h5Var.F(); if (F == 2 || F == 3) { h5Var.L(); boolean z14 = h5Var.f156735d.f155190y.f160262p; h5Var.G(); h5Var.G(); } } public static o2 N(k5 k5Var) { Objects.requireNonNull(k5Var); return new o2(d8.f155212a >= 28 ? k5Var.f157980d.getStreamMinVolume(k5Var.f157982f) : 0, k5Var.f157980d.getStreamMaxVolume(k5Var.f157982f)); } public static int O(boolean z14, int i14) { return (!z14 || i14 == 1) ? 1 : 2; } @Override // uc.g2 public final int B() { L(); return this.f156735d.B(); } @Override // uc.g2 public final int C() { L(); return this.f156735d.C(); } @Override // uc.g2 public final long D() { L(); return this.f156735d.D(); } @Override // uc.g2 public final long E() { L(); return i2.a(this.f156735d.f155190y.f160264r); } public final int F() { L(); return this.f156735d.f155190y.f160251e; } public final boolean G() { L(); return this.f156735d.f155190y.f160258l; } public final void I(Object obj) { boolean z14; ArrayList arrayList = new ArrayList(); a5[] a5VarArr = this.f156733b; int length = a5VarArr.length; int i14 = 0; while (true) { z14 = true; if (i14 >= 2) { break; } a5 a5Var = a5VarArr[i14]; if (a5Var.u() == 2) { x4 P = this.f156735d.P(a5Var); r52.e(!P.f163543f); P.f163540c = 1; r52.e(true ^ P.f163543f); P.f163541d = obj; P.b(); arrayList.add(P); } i14++; } Object obj2 = this.f156743l; if (obj2 == null || obj2 == obj) { z14 = false; } else { try { Iterator it3 = arrayList.iterator(); while (it3.hasNext()) { ((x4) it3.next()).d(); } } catch (InterruptedException unused) { Thread.currentThread().interrupt(); } catch (TimeoutException unused2) { } z14 = false; Object obj3 = this.f156743l; Surface surface = this.f156744m; if (obj3 == surface) { surface.release(); this.f156744m = null; } } this.f156743l = obj; if (z14) { this.f156735d.O(false, p2.a(new n3(3), a.d.TYPE)); } } public final void J(int i14, int i15) { if (i14 != this.f156746o || i15 != this.f156747p) { this.f156746o = i14; this.f156747p = i15; this.f156739h.f(i14, i15); Iterator<t4> it3 = this.f156738g.iterator(); while (it3.hasNext()) { it3.next().f(i14, i15); } } } public final void K(boolean z14, int i14, int i15) { int i16 = 0; boolean z15 = z14 && i14 != -1; if (z15 && i14 != 1) { i16 = 1; } d3 d3Var = this.f156735d; p4 p4Var = d3Var.f155190y; if (p4Var.f160258l != z15 || p4Var.f160259m != i16) { d3Var.f155184s++; p4 g14 = p4Var.g(z15, i16); z7 z7Var = (z7) d3Var.f155173h.f158356i; Objects.requireNonNull(z7Var); y7 g15 = z7.g(); Handler handler = z7Var.f164303a; int i17 = z15 ? 1 : 0; int i18 = z15 ? 1 : 0; int i19 = z15 ? 1 : 0; g15.f163885a = handler.obtainMessage(1, i17, i16); g15.a(); d3Var.H(g14, 0, i15, false, false, 5, C.TIME_UNSET, -1); } } public final void L() { IllegalStateException illegalStateException; u6 u6Var = this.f156734c; synchronized (u6Var) { boolean z14 = false; while (!u6Var.f162514a) { try { u6Var.wait(); } catch (InterruptedException unused) { z14 = true; } } if (z14) { Thread.currentThread().interrupt(); } } if (Thread.currentThread() != this.f156735d.f155181p.getThread()) { String t14 = d8.t("Player is accessed on the wrong thread.\nCurrent thread: '%s'\nExpected thread: '%s'\nSee https://exoplayer.dev/issues/player-accessed-on-wrong-thread", Thread.currentThread().getName(), this.f156735d.f155181p.getThread().getName()); if (!this.f156753v) { if (this.f156754w) { illegalStateException = null; } else { illegalStateException = new IllegalStateException(); } dz.a.D(t14, illegalStateException); this.f156754w = true; return; } throw new IllegalStateException(t14); } } public final void M(int i14, int i15, Object obj) { a5[] a5VarArr = this.f156733b; int length = a5VarArr.length; for (int i16 = 0; i16 < 2; i16++) { a5 a5Var = a5VarArr[i16]; if (a5Var.u() == i14) { x4 P = this.f156735d.P(a5Var); r52.e(!P.f163543f); P.f163540c = i15; r52.e(!P.f163543f); P.f163541d = obj; P.b(); } } } @Override // uc.g2 public final boolean a() { L(); return this.f156735d.a(); } @Override // uc.g2 public final int b() { L(); return this.f156735d.b(); } @Override // uc.g2 public final int c() { L(); return this.f156735d.c(); } @Override // uc.g2 public final long d() { L(); return this.f156735d.d(); } @Override // uc.g2 public final o5 e() { L(); return this.f156735d.f155190y.f160247a; } }