discord-jadx/app/src/main/java/c/i/a/c/d2/b0.java

1213 lines
39 KiB
Java

package c.i.a.c.d2;
import android.media.MediaCodec;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import androidx.annotation.Nullable;
import c.i.a.c.a2.h;
import c.i.a.c.a2.i;
import c.i.a.c.a2.j;
import c.i.a.c.a2.t;
import c.i.a.c.a2.w;
import c.i.a.c.d2.d0;
import c.i.a.c.d2.e0;
import c.i.a.c.d2.q;
import c.i.a.c.d2.v;
import c.i.a.c.d2.z;
import c.i.a.c.f2.g;
import c.i.a.c.h0;
import c.i.a.c.h2.f;
import c.i.a.c.h2.l;
import c.i.a.c.h2.m;
import c.i.a.c.h2.r;
import c.i.a.c.h2.u;
import c.i.a.c.i2.f0;
import c.i.a.c.o1;
import c.i.a.c.s0;
import c.i.a.c.x1.b;
import c.i.a.c.z1.q;
import c.i.a.c.z1.s;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.drm.DrmSession;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.icy.IcyHeaders;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.upstream.HttpDataSource$CleartextNotPermittedException;
import com.google.android.exoplayer2.upstream.Loader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
/* compiled from: ProgressiveMediaPeriod */
public final class b0 implements v, j, Loader.b<a>, Loader.f, e0.b {
public static final Map<String, String> i;
public static final Format j;
@Nullable
public v.a A;
@Nullable
public IcyHeaders B;
public e0[] C;
public d[] D;
public boolean E;
public boolean F;
public boolean G;
public e H;
public t I;
public long J;
public boolean K;
public int L;
public boolean M;
public boolean N;
public int O;
public long P;
public long Q;
public long R;
public boolean S;
public int T;
public boolean U;
public boolean V;
public final Uri k;
public final c.i.a.c.h2.j l;
public final s m;
public final u n;
public final z.a o;
public final q.a p;
public final b q;
public final m r;
@Nullable
/* renamed from: s reason: collision with root package name */
public final String f783s;
public final long t;
public final Loader u = new Loader("Loader:ProgressiveMediaPeriod");
public final k v;
public final c.i.a.c.i2.j w;
/* renamed from: x reason: collision with root package name */
public final Runnable f784x;
/* renamed from: y reason: collision with root package name */
public final Runnable f785y;
/* renamed from: z reason: collision with root package name */
public final Handler f786z;
/* compiled from: ProgressiveMediaPeriod */
public final class a implements Loader.e, q.a {
public final long a = r.a.getAndIncrement();
public final Uri b;
/* renamed from: c reason: collision with root package name */
public final c.i.a.c.h2.v f787c;
public final k d;
public final j e;
public final c.i.a.c.i2.j f;
public final c.i.a.c.a2.s g = new c.i.a.c.a2.s();
public volatile boolean h;
public boolean i = true;
public long j;
public l k = a(0);
public long l = -1;
@Nullable
public w m;
public boolean n;
public a(Uri uri, c.i.a.c.h2.j jVar, k kVar, j jVar2, c.i.a.c.i2.j jVar3) {
this.b = uri;
this.f787c = new c.i.a.c.h2.v(jVar);
this.d = kVar;
this.e = jVar2;
this.f = jVar3;
}
public final l a(long j) {
Collections.emptyMap();
Uri uri = this.b;
String str = b0.this.f783s;
Map<String, String> map = b0.i;
AnimatableValueParser.I(uri, "The uri must be set.");
return new l(uri, 0, 1, null, map, j, -1, str, 6, null);
}
public void b() throws IOException {
f fVar;
int i;
int i2 = 0;
while (i2 == 0 && !this.h) {
try {
long j = this.g.a;
l a = a(j);
this.k = a;
long a2 = this.f787c.a(a);
this.l = a2;
if (a2 != -1) {
this.l = a2 + j;
}
b0.this.B = IcyHeaders.a(this.f787c.j());
c.i.a.c.h2.v vVar = this.f787c;
IcyHeaders icyHeaders = b0.this.B;
if (icyHeaders == null || (i = icyHeaders.n) == -1) {
fVar = vVar;
} else {
fVar = new q(vVar, i, this);
w B = b0.this.B(new d(0, true));
this.m = B;
((e0) B).e(b0.j);
}
long j2 = j;
this.d.b(fVar, this.b, this.f787c.j(), j, this.l, this.e);
if (b0.this.B != null) {
h hVar = this.d.b;
if (hVar instanceof c.i.a.c.a2.g0.f) {
((c.i.a.c.a2.g0.f) hVar).f682s = true;
}
}
if (this.i) {
k kVar = this.d;
long j3 = this.j;
h hVar2 = kVar.b;
Objects.requireNonNull(hVar2);
hVar2.g(j2, j3);
this.i = false;
}
while (true) {
while (i2 == 0 && !this.h) {
try {
c.i.a.c.i2.j jVar = this.f;
synchronized (jVar) {
while (!jVar.b) {
jVar.wait();
}
}
k kVar2 = this.d;
c.i.a.c.a2.s sVar = this.g;
h hVar3 = kVar2.b;
Objects.requireNonNull(hVar3);
i iVar = kVar2.f803c;
Objects.requireNonNull(iVar);
i2 = hVar3.e(iVar, sVar);
j2 = this.d.a();
if (j2 > b0.this.t + j2) {
this.f.a();
b0 b0Var = b0.this;
b0Var.f786z.post(b0Var.f785y);
}
} catch (InterruptedException unused) {
throw new InterruptedIOException();
}
}
}
if (i2 == 1) {
i2 = 0;
} else if (this.d.a() != -1) {
this.g.a = this.d.a();
}
c.i.a.c.h2.v vVar2 = this.f787c;
if (vVar2 != null) {
try {
vVar2.a.close();
} catch (IOException unused2) {
}
}
} catch (Throwable th) {
if (!(i2 == 1 || this.d.a() == -1)) {
this.g.a = this.d.a();
}
c.i.a.c.h2.v vVar3 = this.f787c;
int i3 = f0.a;
if (vVar3 != null) {
try {
vVar3.a.close();
} catch (IOException unused3) {
}
}
throw th;
}
}
}
}
/* compiled from: ProgressiveMediaPeriod */
public interface b {
}
/* compiled from: ProgressiveMediaPeriod */
public final class c implements f0 {
public final int a;
public c(int i) {
this.a = i;
}
/* JADX WARNING: Removed duplicated region for block: B:98:0x0233 */
@Override // c.i.a.c.d2.f0
public int a(s0 s0Var, DecoderInputBuffer decoderInputBuffer, boolean z2) {
int i;
int i2;
b0 b0Var;
int i3;
d0 d0Var;
d0.a aVar;
int i4;
int i5;
b0 b0Var2 = b0.this;
int i6 = this.a;
if (b0Var2.D()) {
return -3;
}
b0Var2.y(i6);
e0 e0Var = b0Var2.C[i6];
boolean z3 = b0Var2.U;
e0.a aVar2 = e0Var.b;
synchronized (e0Var) {
decoderInputBuffer.l = false;
i = -5;
if (!e0Var.m()) {
if (!z3) {
if (!e0Var.f794x) {
Format format = e0Var.B;
if (format != null && (z2 || format != e0Var.g)) {
e0Var.p(format, s0Var);
}
}
}
decoderInputBuffer.i = 4;
i = -4;
} else {
int k = e0Var.k(e0Var.t);
if (z2 || e0Var.p[k] != e0Var.g) {
e0Var.p(e0Var.p[k], s0Var);
} else if (!e0Var.o(k)) {
decoderInputBuffer.l = true;
} else {
decoderInputBuffer.i = e0Var.m[k];
long j = e0Var.n[k];
decoderInputBuffer.m = j;
if (j < e0Var.u) {
decoderInputBuffer.j(Integer.MIN_VALUE);
}
aVar2.a = e0Var.l[k];
aVar2.b = e0Var.k[k];
aVar2.f797c = e0Var.o[k];
i = -4;
}
}
i = -3;
}
if (i == -4 && !decoderInputBuffer.n()) {
if (!(decoderInputBuffer.k == null && decoderInputBuffer.o == 0)) {
d0 d0Var2 = e0Var.a;
e0.a aVar3 = e0Var.b;
d0.a aVar4 = d0Var2.e;
c.i.a.c.i2.w wVar = d0Var2.f790c;
if (decoderInputBuffer.t()) {
long j2 = aVar3.b;
wVar.z(1);
d0.a e = d0.e(aVar4, j2, wVar.a, 1);
long j3 = j2 + 1;
byte b = wVar.a[0];
boolean z4 = (b & 128) != 0;
int i7 = b & Byte.MAX_VALUE;
c.i.a.c.x1.b bVar = decoderInputBuffer.j;
byte[] bArr = bVar.a;
if (bArr == null) {
bVar.a = new byte[16];
} else {
Arrays.fill(bArr, (byte) 0);
}
d0.a e2 = d0.e(e, j3, bVar.a, i7);
long j4 = j3 + ((long) i7);
if (z4) {
wVar.z(2);
e2 = d0.e(e2, j4, wVar.a, 2);
j4 += 2;
i4 = wVar.x();
} else {
i4 = 1;
}
int[] iArr = bVar.d;
if (iArr == null || iArr.length < i4) {
iArr = new int[i4];
}
int[] iArr2 = bVar.e;
b0Var = b0Var2;
if (iArr2 == null || iArr2.length < i4) {
iArr2 = new int[i4];
}
if (z4) {
int i8 = i4 * 6;
wVar.z(i8);
e2 = d0.e(e2, j4, wVar.a, i8);
i5 = i6;
j4 += (long) i8;
wVar.D(0);
for (int i9 = 0; i9 < i4; i9++) {
iArr[i9] = wVar.x();
iArr2[i9] = wVar.v();
}
} else {
i5 = i6;
iArr[0] = 0;
iArr2[0] = aVar3.a - ((int) (j4 - aVar3.b));
}
w.a aVar5 = aVar3.f797c;
int i10 = f0.a;
byte[] bArr2 = aVar5.b;
byte[] bArr3 = bVar.a;
i2 = i5;
int i11 = aVar5.a;
i3 = i;
int i12 = aVar5.f759c;
int i13 = aVar5.d;
bVar.f = i4;
bVar.d = iArr;
bVar.e = iArr2;
bVar.b = bArr2;
bVar.a = bArr3;
bVar.f1008c = i11;
bVar.g = i12;
bVar.h = i13;
d0Var = d0Var2;
MediaCodec.CryptoInfo cryptoInfo = bVar.i;
cryptoInfo.numSubSamples = i4;
cryptoInfo.numBytesOfClearData = iArr;
cryptoInfo.numBytesOfEncryptedData = iArr2;
cryptoInfo.key = bArr2;
cryptoInfo.iv = bArr3;
cryptoInfo.mode = i11;
if (f0.a >= 24) {
b.C0094b bVar2 = bVar.j;
Objects.requireNonNull(bVar2);
bVar2.b.set(i12, i13);
bVar2.a.setPattern(bVar2.b);
}
long j5 = aVar3.b;
int i14 = (int) (j4 - j5);
aVar3.b = j5 + ((long) i14);
aVar3.a -= i14;
aVar4 = e2;
} else {
d0Var = d0Var2;
b0Var = b0Var2;
i2 = i6;
i3 = i;
}
if (decoderInputBuffer.l()) {
wVar.z(4);
d0.a e3 = d0.e(aVar4, aVar3.b, wVar.a, 4);
int v = wVar.v();
aVar3.b += 4;
aVar3.a -= 4;
decoderInputBuffer.r(v);
d0.a d = d0.d(e3, aVar3.b, decoderInputBuffer.k, v);
aVar3.b += (long) v;
int i15 = aVar3.a - v;
aVar3.a = i15;
ByteBuffer byteBuffer = decoderInputBuffer.n;
if (byteBuffer == null || byteBuffer.capacity() < i15) {
decoderInputBuffer.n = ByteBuffer.allocate(i15);
} else {
decoderInputBuffer.n.clear();
}
aVar = d0.d(d, aVar3.b, decoderInputBuffer.n, aVar3.a);
} else {
decoderInputBuffer.r(aVar3.a);
aVar = d0.d(aVar4, aVar3.b, decoderInputBuffer.k, aVar3.a);
}
d0Var.e = aVar;
e0Var.t++;
if (i3 == -3) {
b0Var.z(i2);
}
return i3;
}
}
b0Var = b0Var2;
i2 = i6;
i3 = i;
if (i3 == -3) {
}
return i3;
}
@Override // c.i.a.c.d2.f0
public void b() throws IOException {
b0 b0Var = b0.this;
e0 e0Var = b0Var.C[this.a];
DrmSession drmSession = e0Var.h;
if (drmSession == null || drmSession.getState() != 1) {
b0Var.A();
return;
}
DrmSession.DrmSessionException f = e0Var.h.f();
Objects.requireNonNull(f);
throw f;
}
@Override // c.i.a.c.d2.f0
public int c(long j) {
int i;
b0 b0Var = b0.this;
int i2 = this.a;
boolean z2 = false;
if (b0Var.D()) {
return 0;
}
b0Var.y(i2);
e0 e0Var = b0Var.C[i2];
boolean z3 = b0Var.U;
synchronized (e0Var) {
int k = e0Var.k(e0Var.t);
if (e0Var.m()) {
if (j >= e0Var.n[k]) {
if (j <= e0Var.w || !z3) {
i = e0Var.i(k, e0Var.q - e0Var.t, j, true);
if (i == -1) {
i = 0;
}
} else {
i = e0Var.q - e0Var.t;
}
}
}
i = 0;
}
synchronized (e0Var) {
if (i >= 0) {
if (e0Var.t + i <= e0Var.q) {
z2 = true;
}
}
AnimatableValueParser.k(z2);
e0Var.t += i;
}
if (i == 0) {
b0Var.z(i2);
}
return i;
}
@Override // c.i.a.c.d2.f0
public boolean d() {
b0 b0Var = b0.this;
return !b0Var.D() && b0Var.C[this.a].n(b0Var.U);
}
}
/* compiled from: ProgressiveMediaPeriod */
public static final class d {
public final int a;
public final boolean b;
public d(int i, boolean z2) {
this.a = i;
this.b = z2;
}
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || d.class != obj.getClass()) {
return false;
}
d dVar = (d) obj;
return this.a == dVar.a && this.b == dVar.b;
}
public int hashCode() {
return (this.a * 31) + (this.b ? 1 : 0);
}
}
/* compiled from: ProgressiveMediaPeriod */
public static final class e {
public final TrackGroupArray a;
public final boolean[] b;
/* renamed from: c reason: collision with root package name */
public final boolean[] f788c;
public final boolean[] d;
public e(TrackGroupArray trackGroupArray, boolean[] zArr) {
this.a = trackGroupArray;
this.b = zArr;
int i = trackGroupArray.j;
this.f788c = new boolean[i];
this.d = new boolean[i];
}
}
static {
HashMap hashMap = new HashMap();
hashMap.put("Icy-MetaData", "1");
i = Collections.unmodifiableMap(hashMap);
Format.b bVar = new Format.b();
bVar.a = "icy";
bVar.k = "application/x-icy";
j = bVar.a();
}
public b0(Uri uri, c.i.a.c.h2.j jVar, c.i.a.c.a2.l lVar, s sVar, q.a aVar, u uVar, z.a aVar2, b bVar, m mVar, @Nullable String str, int i2) {
this.k = uri;
this.l = jVar;
this.m = sVar;
this.p = aVar;
this.n = uVar;
this.o = aVar2;
this.q = bVar;
this.r = mVar;
this.f783s = str;
this.t = (long) i2;
this.v = new k(lVar);
this.w = new c.i.a.c.i2.j();
this.f784x = new g(this);
this.f785y = new i(this);
this.f786z = f0.j();
this.D = new d[0];
this.C = new e0[0];
this.R = -9223372036854775807L;
this.P = -1;
this.J = -9223372036854775807L;
this.L = 1;
}
public void A() throws IOException {
Loader loader = this.u;
int a2 = ((r) this.n).a(this.L);
IOException iOException = loader.e;
if (iOException == null) {
Loader.d<? extends Loader.e> dVar = loader.d;
if (dVar != null) {
if (a2 == Integer.MIN_VALUE) {
a2 = dVar.i;
}
IOException iOException2 = dVar.m;
if (iOException2 != null && dVar.n > a2) {
throw iOException2;
}
return;
}
return;
}
throw iOException;
}
public final w B(d dVar) {
int length = this.C.length;
for (int i2 = 0; i2 < length; i2++) {
if (dVar.equals(this.D[i2])) {
return this.C[i2];
}
}
m mVar = this.r;
Looper looper = this.f786z.getLooper();
s sVar = this.m;
q.a aVar = this.p;
Objects.requireNonNull(looper);
Objects.requireNonNull(sVar);
Objects.requireNonNull(aVar);
e0 e0Var = new e0(mVar, looper, sVar, aVar);
e0Var.f = this;
int i3 = length + 1;
d[] dVarArr = (d[]) Arrays.copyOf(this.D, i3);
dVarArr[length] = dVar;
int i4 = f0.a;
this.D = dVarArr;
e0[] e0VarArr = (e0[]) Arrays.copyOf(this.C, i3);
e0VarArr[length] = e0Var;
this.C = e0VarArr;
return e0Var;
}
public final void C() {
a aVar = new a(this.k, this.l, this.v, this, this.w);
if (this.F) {
AnimatableValueParser.D(w());
long j2 = this.J;
if (j2 == -9223372036854775807L || this.R <= j2) {
t tVar = this.I;
Objects.requireNonNull(tVar);
long j3 = tVar.h(this.R).a.f758c;
long j4 = this.R;
aVar.g.a = j3;
aVar.j = j4;
aVar.i = true;
aVar.n = false;
for (e0 e0Var : this.C) {
e0Var.u = this.R;
}
this.R = -9223372036854775807L;
} else {
this.U = true;
this.R = -9223372036854775807L;
return;
}
}
this.T = u();
Loader loader = this.u;
int a2 = ((r) this.n).a(this.L);
Objects.requireNonNull(loader);
Looper myLooper = Looper.myLooper();
AnimatableValueParser.H(myLooper);
loader.e = null;
long elapsedRealtime = SystemClock.elapsedRealtime();
new Loader.d(myLooper, aVar, this, a2, elapsedRealtime).b(0);
l lVar = aVar.k;
z.a aVar2 = this.o;
aVar2.f(new r(aVar.a, lVar, elapsedRealtime), new u(1, -1, null, 0, null, aVar2.a(aVar.j), aVar2.a(this.J)));
}
public final boolean D() {
return this.N || w();
}
@Override // c.i.a.c.a2.j
public void a(t tVar) {
this.f786z.post(new h(this, tVar));
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [com.google.android.exoplayer2.upstream.Loader$e, long, long, boolean] */
@Override // com.google.android.exoplayer2.upstream.Loader.b
public void b(a aVar, long j2, long j3, boolean z2) {
a aVar2 = aVar;
c.i.a.c.h2.v vVar = aVar2.f787c;
r rVar = new r(aVar2.a, aVar2.k, vVar.f891c, vVar.d, j2, j3, vVar.b);
Objects.requireNonNull(this.n);
z.a aVar3 = this.o;
aVar3.c(rVar, new u(1, -1, null, 0, null, aVar3.a(aVar2.j), aVar3.a(this.J)));
if (!z2) {
if (this.P == -1) {
this.P = aVar2.l;
}
for (e0 e0Var : this.C) {
e0Var.q(false);
}
if (this.O > 0) {
v.a aVar4 = this.A;
Objects.requireNonNull(aVar4);
aVar4.a(this);
}
}
}
@Override // c.i.a.c.d2.v
public long c() {
if (this.O == 0) {
return Long.MIN_VALUE;
}
return q();
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [com.google.android.exoplayer2.upstream.Loader$e, long, long] */
@Override // com.google.android.exoplayer2.upstream.Loader.b
public void d(a aVar, long j2, long j3) {
t tVar;
a aVar2 = aVar;
if (this.J == -9223372036854775807L && (tVar = this.I) != null) {
boolean c2 = tVar.c();
long v = v();
long j4 = v == Long.MIN_VALUE ? 0 : v + 10000;
this.J = j4;
((c0) this.q).t(j4, c2, this.K);
}
c.i.a.c.h2.v vVar = aVar2.f787c;
r rVar = new r(aVar2.a, aVar2.k, vVar.f891c, vVar.d, j2, j3, vVar.b);
Objects.requireNonNull(this.n);
z.a aVar3 = this.o;
aVar3.d(rVar, new u(1, -1, null, 0, null, aVar3.a(aVar2.j), aVar3.a(this.J)));
if (this.P == -1) {
this.P = aVar2.l;
}
this.U = true;
v.a aVar4 = this.A;
Objects.requireNonNull(aVar4);
aVar4.a(this);
}
@Override // c.i.a.c.d2.v
public void e() throws IOException {
A();
if (this.U && !this.F) {
throw new ParserException("Loading finished before preparation is complete.");
}
}
@Override // c.i.a.c.d2.v
public long f(long j2) {
boolean z2;
t();
boolean[] zArr = this.H.b;
if (!this.I.c()) {
j2 = 0;
}
this.N = false;
this.Q = j2;
if (w()) {
this.R = j2;
return j2;
}
if (this.L != 7) {
int length = this.C.length;
int i2 = 0;
while (true) {
if (i2 >= length) {
z2 = true;
break;
} else if (this.C[i2].r(j2, false) || (!zArr[i2] && this.G)) {
i2++;
}
}
z2 = false;
if (z2) {
return j2;
}
}
this.S = false;
this.R = j2;
this.U = false;
if (this.u.b()) {
for (e0 e0Var : this.C) {
e0Var.h();
}
Loader.d<? extends Loader.e> dVar = this.u.d;
AnimatableValueParser.H(dVar);
dVar.a(false);
} else {
this.u.e = null;
for (e0 e0Var2 : this.C) {
e0Var2.q(false);
}
}
return j2;
}
@Override // c.i.a.c.d2.v
public boolean g(long j2) {
if (!this.U) {
if (!(this.u.e != null) && !this.S && (!this.F || this.O != 0)) {
boolean b2 = this.w.b();
if (this.u.b()) {
return b2;
}
C();
return true;
}
}
return false;
}
@Override // c.i.a.c.d2.v
public boolean h() {
boolean z2;
if (this.u.b()) {
c.i.a.c.i2.j jVar = this.w;
synchronized (jVar) {
z2 = jVar.b;
}
if (z2) {
return true;
}
}
return false;
}
@Override // c.i.a.c.d2.v
public long i(long j2, o1 o1Var) {
t();
if (!this.I.c()) {
return 0;
}
t.a h = this.I.h(j2);
long j3 = h.a.b;
long j4 = h.b.b;
long j5 = o1Var.f936c;
if (j5 == 0 && o1Var.d == 0) {
return j2;
}
long j6 = Long.MIN_VALUE;
int i2 = f0.a;
long j7 = j2 - j5;
if (((j5 ^ j2) & (j2 ^ j7)) >= 0) {
j6 = j7;
}
long j8 = o1Var.d;
long j9 = Long.MAX_VALUE;
long j10 = j2 + j8;
if (((j8 ^ j10) & (j2 ^ j10)) >= 0) {
j9 = j10;
}
boolean z2 = false;
boolean z3 = j6 <= j3 && j3 <= j9;
if (j6 <= j4 && j4 <= j9) {
z2 = true;
}
if (!z3 || !z2) {
if (z3) {
return j3;
}
if (!z2) {
return j6;
}
} else if (Math.abs(j3 - j2) <= Math.abs(j4 - j2)) {
return j3;
}
return j4;
}
@Override // c.i.a.c.a2.j
public void j() {
this.E = true;
this.f786z.post(this.f784x);
}
@Override // c.i.a.c.d2.v
public long k() {
if (!this.N) {
return -9223372036854775807L;
}
if (!this.U && u() <= this.T) {
return -9223372036854775807L;
}
this.N = false;
return this.Q;
}
@Override // c.i.a.c.d2.v
public void l(v.a aVar, long j2) {
this.A = aVar;
this.w.b();
C();
}
@Override // c.i.a.c.d2.v
public long m(g[] gVarArr, boolean[] zArr, f0[] f0VarArr, boolean[] zArr2, long j2) {
t();
e eVar = this.H;
TrackGroupArray trackGroupArray = eVar.a;
boolean[] zArr3 = eVar.f788c;
int i2 = this.O;
for (int i3 = 0; i3 < gVarArr.length; i3++) {
if (f0VarArr[i3] != null && (gVarArr[i3] == null || !zArr[i3])) {
int i4 = ((c) f0VarArr[i3]).a;
AnimatableValueParser.D(zArr3[i4]);
this.O--;
zArr3[i4] = false;
f0VarArr[i3] = null;
}
}
boolean z2 = !this.M ? j2 != 0 : i2 == 0;
for (int i5 = 0; i5 < gVarArr.length; i5++) {
if (f0VarArr[i5] == null && gVarArr[i5] != null) {
g gVar = gVarArr[i5];
AnimatableValueParser.D(gVar.length() == 1);
AnimatableValueParser.D(gVar.f(0) == 0);
int a2 = trackGroupArray.a(gVar.a());
AnimatableValueParser.D(!zArr3[a2]);
this.O++;
zArr3[a2] = true;
f0VarArr[i5] = new c(a2);
zArr2[i5] = true;
if (!z2) {
e0 e0Var = this.C[a2];
z2 = !e0Var.r(j2, true) && e0Var.r + e0Var.t != 0;
}
}
}
if (this.O == 0) {
this.S = false;
this.N = false;
if (this.u.b()) {
for (e0 e0Var2 : this.C) {
e0Var2.h();
}
Loader.d<? extends Loader.e> dVar = this.u.d;
AnimatableValueParser.H(dVar);
dVar.a(false);
} else {
for (e0 e0Var3 : this.C) {
e0Var3.q(false);
}
}
} else if (z2) {
j2 = f(j2);
for (int i6 = 0; i6 < f0VarArr.length; i6++) {
if (f0VarArr[i6] != null) {
zArr2[i6] = true;
}
}
}
this.M = true;
return j2;
}
@Override // c.i.a.c.d2.v
public TrackGroupArray n() {
t();
return this.H.a;
}
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [com.google.android.exoplayer2.upstream.Loader$e, long, long, java.io.IOException, int] */
/* JADX WARNING: Removed duplicated region for block: B:38:0x00ba */
/* JADX WARNING: Removed duplicated region for block: B:39:0x00bf */
@Override // com.google.android.exoplayer2.upstream.Loader.b
public Loader.c o(a aVar, long j2, long j3, IOException iOException, int i2) {
Loader.c cVar;
boolean z2;
t tVar;
a aVar2 = aVar;
if (this.P == -1) {
this.P = aVar2.l;
}
c.i.a.c.h2.v vVar = aVar2.f787c;
r rVar = new r(aVar2.a, aVar2.k, vVar.f891c, vVar.d, j2, j3, vVar.b);
h0.b(aVar2.j);
h0.b(this.J);
r rVar2 = (r) this.n;
long min = ((iOException instanceof ParserException) || (iOException instanceof FileNotFoundException) || (iOException instanceof HttpDataSource$CleartextNotPermittedException) || (iOException instanceof Loader.UnexpectedLoaderException)) ? -9223372036854775807L : (long) Math.min((i2 - 1) * 1000, 5000);
boolean z3 = false;
if (min == -9223372036854775807L) {
cVar = Loader.b;
} else {
int u = u();
boolean z4 = u > this.T;
if (this.P != -1 || ((tVar = this.I) != null && tVar.i() != -9223372036854775807L)) {
this.T = u;
} else if (!this.F || D()) {
this.N = this.F;
this.Q = 0;
this.T = 0;
for (e0 e0Var : this.C) {
e0Var.q(false);
}
aVar2.g.a = 0;
aVar2.j = 0;
aVar2.i = true;
aVar2.n = false;
} else {
this.S = true;
z2 = false;
cVar = !z2 ? Loader.a(z4, min) : Loader.a;
}
z2 = true;
if (!z2) {
}
}
int i3 = cVar.a;
if (i3 == 0 || i3 == 1) {
z3 = true;
}
boolean z5 = !z3;
z.a aVar3 = this.o;
aVar3.e(rVar, new u(1, -1, null, 0, null, aVar3.a(aVar2.j), aVar3.a(this.J)), iOException, z5);
if (z5) {
Objects.requireNonNull(this.n);
}
return cVar;
}
@Override // c.i.a.c.a2.j
public w p(int i2, int i3) {
return B(new d(i2, false));
}
@Override // c.i.a.c.d2.v
public long q() {
long j2;
boolean z2;
long j3;
t();
boolean[] zArr = this.H.b;
if (this.U) {
return Long.MIN_VALUE;
}
if (w()) {
return this.R;
}
if (this.G) {
int length = this.C.length;
j2 = Long.MAX_VALUE;
for (int i2 = 0; i2 < length; i2++) {
if (zArr[i2]) {
e0 e0Var = this.C[i2];
synchronized (e0Var) {
z2 = e0Var.f794x;
}
if (!z2) {
e0 e0Var2 = this.C[i2];
synchronized (e0Var2) {
j3 = e0Var2.w;
}
j2 = Math.min(j2, j3);
} else {
continue;
}
}
}
} else {
j2 = Long.MAX_VALUE;
}
if (j2 == Long.MAX_VALUE) {
j2 = v();
}
return j2 == Long.MIN_VALUE ? this.Q : j2;
}
@Override // c.i.a.c.d2.v
public void r(long j2, boolean z2) {
long j3;
int i2;
t();
if (!w()) {
boolean[] zArr = this.H.f788c;
int length = this.C.length;
for (int i3 = 0; i3 < length; i3++) {
e0 e0Var = this.C[i3];
boolean z3 = zArr[i3];
d0 d0Var = e0Var.a;
synchronized (e0Var) {
int i4 = e0Var.q;
j3 = -1;
if (i4 != 0) {
long[] jArr = e0Var.n;
int i5 = e0Var.f793s;
if (j2 >= jArr[i5]) {
int i6 = e0Var.i(i5, (!z3 || (i2 = e0Var.t) == i4) ? i4 : i2 + 1, j2, z2);
if (i6 != -1) {
j3 = e0Var.g(i6);
}
}
}
}
d0Var.a(j3);
}
}
}
@Override // c.i.a.c.d2.v
public void s(long j2) {
}
@EnsuresNonNull({"trackState", "seekMap"})
public final void t() {
AnimatableValueParser.D(this.F);
Objects.requireNonNull(this.H);
Objects.requireNonNull(this.I);
}
public final int u() {
e0[] e0VarArr = this.C;
int i2 = 0;
for (e0 e0Var : e0VarArr) {
i2 += e0Var.r + e0Var.q;
}
return i2;
}
public final long v() {
long j2;
e0[] e0VarArr = this.C;
long j3 = Long.MIN_VALUE;
for (e0 e0Var : e0VarArr) {
synchronized (e0Var) {
j2 = e0Var.w;
}
j3 = Math.max(j3, j2);
}
return j3;
}
public final boolean w() {
return this.R != -9223372036854775807L;
}
public final void x() {
if (!(this.V || this.F || !this.E || this.I == null)) {
for (e0 e0Var : this.C) {
if (e0Var.l() == null) {
return;
}
}
this.w.a();
int length = this.C.length;
TrackGroup[] trackGroupArr = new TrackGroup[length];
boolean[] zArr = new boolean[length];
for (int i2 = 0; i2 < length; i2++) {
Format l = this.C[i2].l();
Objects.requireNonNull(l);
String str = l.t;
boolean h = c.i.a.c.i2.s.h(str);
boolean z2 = h || c.i.a.c.i2.s.j(str);
zArr[i2] = z2;
this.G = z2 | this.G;
IcyHeaders icyHeaders = this.B;
if (icyHeaders != null) {
if (h || this.D[i2].b) {
Metadata metadata = l.r;
Metadata metadata2 = metadata == null ? new Metadata(icyHeaders) : metadata.a(icyHeaders);
Format.b a2 = l.a();
a2.i = metadata2;
l = a2.a();
}
if (h && l.n == -1 && l.o == -1 && icyHeaders.i != -1) {
Format.b a3 = l.a();
a3.f = icyHeaders.i;
l = a3.a();
}
}
Class<? extends c.i.a.c.z1.w> c2 = this.m.c(l);
Format.b a4 = l.a();
a4.D = c2;
trackGroupArr[i2] = new TrackGroup(a4.a());
}
this.H = new e(new TrackGroupArray(trackGroupArr), zArr);
this.F = true;
v.a aVar = this.A;
Objects.requireNonNull(aVar);
aVar.b(this);
}
}
public final void y(int i2) {
t();
e eVar = this.H;
boolean[] zArr = eVar.d;
if (!zArr[i2]) {
Format format = eVar.a.k[i2].j[0];
z.a aVar = this.o;
aVar.b(new u(1, c.i.a.c.i2.s.g(format.t), format, 0, null, aVar.a(this.Q), -9223372036854775807L));
zArr[i2] = true;
}
}
public final void z(int i2) {
t();
boolean[] zArr = this.H.b;
if (this.S && zArr[i2] && !this.C[i2].n(false)) {
this.R = 0;
this.S = false;
this.N = true;
this.Q = 0;
this.T = 0;
for (e0 e0Var : this.C) {
e0Var.q(false);
}
v.a aVar = this.A;
Objects.requireNonNull(aVar);
aVar.a(this);
}
}
}