374 lines
11 KiB
Java
374 lines
11 KiB
Java
package c.i.a.c;
|
|
|
|
import android.os.Handler;
|
|
import android.util.Pair;
|
|
import androidx.annotation.Nullable;
|
|
import c.i.a.c.d2.j0.a;
|
|
import c.i.a.c.d2.y;
|
|
import c.i.a.c.r1;
|
|
import c.i.a.c.u1.c1;
|
|
import c.i.b.b.u;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
/* compiled from: MediaPeriodQueue */
|
|
public final class z0 {
|
|
public final r1.b a = new r1.b();
|
|
public final r1.c b = new r1.c();
|
|
@Nullable
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final c1 f1014c;
|
|
public final Handler d;
|
|
public long e;
|
|
public int f;
|
|
public boolean g;
|
|
@Nullable
|
|
public x0 h;
|
|
@Nullable
|
|
public x0 i;
|
|
@Nullable
|
|
public x0 j;
|
|
public int k;
|
|
@Nullable
|
|
public Object l;
|
|
public long m;
|
|
|
|
public z0(@Nullable c1 c1Var, Handler handler) {
|
|
this.f1014c = c1Var;
|
|
this.d = handler;
|
|
}
|
|
|
|
public static y.a o(r1 r1Var, Object obj, long j, long j2, r1.b bVar) {
|
|
r1Var.h(obj, bVar);
|
|
int c2 = bVar.c(j);
|
|
return c2 == -1 ? new y.a(obj, j2, bVar.b(j)) : new y.a(obj, c2, bVar.e(c2), j2);
|
|
}
|
|
|
|
@Nullable
|
|
public x0 a() {
|
|
x0 x0Var = this.h;
|
|
if (x0Var == null) {
|
|
return null;
|
|
}
|
|
if (x0Var == this.i) {
|
|
this.i = x0Var.l;
|
|
}
|
|
x0Var.h();
|
|
int i = this.k - 1;
|
|
this.k = i;
|
|
if (i == 0) {
|
|
this.j = null;
|
|
x0 x0Var2 = this.h;
|
|
this.l = x0Var2.b;
|
|
this.m = x0Var2.f.a.d;
|
|
}
|
|
this.h = this.h.l;
|
|
k();
|
|
return this.h;
|
|
}
|
|
|
|
public void b() {
|
|
if (this.k != 0) {
|
|
x0 x0Var = this.h;
|
|
AnimatableValueParser.H(x0Var);
|
|
x0 x0Var2 = x0Var;
|
|
this.l = x0Var2.b;
|
|
this.m = x0Var2.f.a.d;
|
|
while (x0Var2 != null) {
|
|
x0Var2.h();
|
|
x0Var2 = x0Var2.l;
|
|
}
|
|
this.h = null;
|
|
this.j = null;
|
|
this.i = null;
|
|
this.k = 0;
|
|
k();
|
|
}
|
|
}
|
|
|
|
@Nullable
|
|
public final y0 c(r1 r1Var, x0 x0Var, long j) {
|
|
long j2;
|
|
y0 y0Var = x0Var.f;
|
|
long j3 = (x0Var.o + y0Var.e) - j;
|
|
if (y0Var.f) {
|
|
long j4 = 0;
|
|
int d = r1Var.d(r1Var.b(y0Var.a.a), this.a, this.b, this.f, this.g);
|
|
if (d == -1) {
|
|
return null;
|
|
}
|
|
int i = r1Var.g(d, this.a, true).f952c;
|
|
Object obj = this.a.b;
|
|
long j5 = y0Var.a.d;
|
|
if (r1Var.n(i, this.b).o == d) {
|
|
Pair<Object, Long> k = r1Var.k(this.b, this.a, i, -9223372036854775807L, Math.max(0L, j3));
|
|
if (k == null) {
|
|
return null;
|
|
}
|
|
obj = k.first;
|
|
long longValue = ((Long) k.second).longValue();
|
|
x0 x0Var2 = x0Var.l;
|
|
if (x0Var2 == null || !x0Var2.b.equals(obj)) {
|
|
j5 = this.e;
|
|
this.e = 1 + j5;
|
|
} else {
|
|
j5 = x0Var2.f.a.d;
|
|
}
|
|
j2 = longValue;
|
|
j4 = -9223372036854775807L;
|
|
} else {
|
|
j2 = 0;
|
|
}
|
|
return d(r1Var, o(r1Var, obj, j2, j5, this.a), j4, j2);
|
|
}
|
|
y.a aVar = y0Var.a;
|
|
r1Var.h(aVar.a, this.a);
|
|
if (aVar.a()) {
|
|
int i2 = aVar.b;
|
|
a.C0086a[] aVarArr = this.a.f.e;
|
|
int i3 = aVarArr[i2].a;
|
|
if (i3 == -1) {
|
|
return null;
|
|
}
|
|
int a = aVarArr[i2].a(aVar.f810c);
|
|
if (a < i3) {
|
|
return e(r1Var, aVar.a, i2, a, y0Var.f1012c, aVar.d);
|
|
}
|
|
long j6 = y0Var.f1012c;
|
|
if (j6 == -9223372036854775807L) {
|
|
r1.c cVar = this.b;
|
|
r1.b bVar = this.a;
|
|
Pair<Object, Long> k2 = r1Var.k(cVar, bVar, bVar.f952c, -9223372036854775807L, Math.max(0L, j3));
|
|
if (k2 == null) {
|
|
return null;
|
|
}
|
|
j6 = ((Long) k2.second).longValue();
|
|
}
|
|
return f(r1Var, aVar.a, j6, y0Var.f1012c, aVar.d);
|
|
}
|
|
int c2 = this.a.c(y0Var.d);
|
|
if (c2 == -1) {
|
|
Object obj2 = aVar.a;
|
|
long j7 = y0Var.e;
|
|
return f(r1Var, obj2, j7, j7, aVar.d);
|
|
}
|
|
return e(r1Var, aVar.a, c2, this.a.e(c2), y0Var.e, aVar.d);
|
|
}
|
|
|
|
@Nullable
|
|
public final y0 d(r1 r1Var, y.a aVar, long j, long j2) {
|
|
r1Var.h(aVar.a, this.a);
|
|
return aVar.a() ? e(r1Var, aVar.a, aVar.b, aVar.f810c, j, aVar.d) : f(r1Var, aVar.a, j2, j, aVar.d);
|
|
}
|
|
|
|
public final y0 e(r1 r1Var, Object obj, int i, int i2, long j, long j2) {
|
|
y.a aVar = new y.a(obj, i, i2, j2);
|
|
long a = r1Var.h(obj, this.a).a(i, i2);
|
|
long j3 = i2 == this.a.f.e[i].a(-1) ? this.a.f.f : 0;
|
|
return new y0(aVar, (a == -9223372036854775807L || j3 < a) ? j3 : Math.max(0L, a - 1), j, -9223372036854775807L, a, false, false, false);
|
|
}
|
|
|
|
public final y0 f(r1 r1Var, Object obj, long j, long j2, long j3) {
|
|
long j4 = j;
|
|
r1Var.h(obj, this.a);
|
|
int b = this.a.b(j4);
|
|
y.a aVar = new y.a(obj, j3, b);
|
|
boolean h = h(aVar);
|
|
boolean j5 = j(r1Var, aVar);
|
|
boolean i = i(r1Var, aVar, h);
|
|
long d = b != -1 ? this.a.d(b) : -9223372036854775807L;
|
|
long j6 = (d == -9223372036854775807L || d == Long.MIN_VALUE) ? this.a.d : d;
|
|
if (j6 != -9223372036854775807L && j4 >= j6) {
|
|
j4 = Math.max(0L, j6 - 1);
|
|
}
|
|
return new y0(aVar, j4, j2, d, j6, h, j5, i);
|
|
}
|
|
|
|
public y0 g(r1 r1Var, y0 y0Var) {
|
|
long j;
|
|
y.a aVar = y0Var.a;
|
|
boolean h = h(aVar);
|
|
boolean j2 = j(r1Var, aVar);
|
|
boolean i = i(r1Var, aVar, h);
|
|
r1Var.h(y0Var.a.a, this.a);
|
|
if (aVar.a()) {
|
|
j = this.a.a(aVar.b, aVar.f810c);
|
|
} else {
|
|
j = y0Var.d;
|
|
if (j == -9223372036854775807L || j == Long.MIN_VALUE) {
|
|
j = this.a.d;
|
|
}
|
|
}
|
|
return new y0(aVar, y0Var.b, y0Var.f1012c, y0Var.d, j, h, j2, i);
|
|
}
|
|
|
|
public final boolean h(y.a aVar) {
|
|
return !aVar.a() && aVar.e == -1;
|
|
}
|
|
|
|
public final boolean i(r1 r1Var, y.a aVar, boolean z2) {
|
|
int b = r1Var.b(aVar.a);
|
|
if (r1Var.n(r1Var.f(b, this.a).f952c, this.b).k) {
|
|
return false;
|
|
}
|
|
return (r1Var.d(b, this.a, this.b, this.f, this.g) == -1) && z2;
|
|
}
|
|
|
|
public final boolean j(r1 r1Var, y.a aVar) {
|
|
if (!h(aVar)) {
|
|
return false;
|
|
}
|
|
return r1Var.n(r1Var.h(aVar.a, this.a).f952c, this.b).p == r1Var.b(aVar.a);
|
|
}
|
|
|
|
public final void k() {
|
|
if (this.f1014c != null) {
|
|
c.i.b.b.a<Object> aVar = u.j;
|
|
u.a aVar2 = new u.a();
|
|
for (x0 x0Var = this.h; x0Var != null; x0Var = x0Var.l) {
|
|
aVar2.b(x0Var.f.a);
|
|
}
|
|
x0 x0Var2 = this.i;
|
|
this.d.post(new y(this, aVar2, x0Var2 == null ? null : x0Var2.f.a));
|
|
}
|
|
}
|
|
|
|
public void l(long j) {
|
|
x0 x0Var = this.j;
|
|
if (x0Var != null) {
|
|
AnimatableValueParser.D(x0Var.g());
|
|
if (x0Var.d) {
|
|
x0Var.a.s(j - x0Var.o);
|
|
}
|
|
}
|
|
}
|
|
|
|
public boolean m(x0 x0Var) {
|
|
boolean z2 = false;
|
|
AnimatableValueParser.D(x0Var != null);
|
|
if (x0Var.equals(this.j)) {
|
|
return false;
|
|
}
|
|
this.j = x0Var;
|
|
while (true) {
|
|
x0Var = x0Var.l;
|
|
if (x0Var == null) {
|
|
break;
|
|
}
|
|
if (x0Var == this.i) {
|
|
this.i = this.h;
|
|
z2 = true;
|
|
}
|
|
x0Var.h();
|
|
this.k--;
|
|
}
|
|
x0 x0Var2 = this.j;
|
|
if (x0Var2.l != null) {
|
|
x0Var2.b();
|
|
x0Var2.l = null;
|
|
x0Var2.c();
|
|
}
|
|
k();
|
|
return z2;
|
|
}
|
|
|
|
public y.a n(r1 r1Var, Object obj, long j) {
|
|
long j2;
|
|
int b;
|
|
int i = r1Var.h(obj, this.a).f952c;
|
|
Object obj2 = this.l;
|
|
if (obj2 == null || (b = r1Var.b(obj2)) == -1 || r1Var.f(b, this.a).f952c != i) {
|
|
x0 x0Var = this.h;
|
|
while (true) {
|
|
if (x0Var == null) {
|
|
x0 x0Var2 = this.h;
|
|
while (true) {
|
|
if (x0Var2 != null) {
|
|
int b2 = r1Var.b(x0Var2.b);
|
|
if (b2 != -1 && r1Var.f(b2, this.a).f952c == i) {
|
|
j2 = x0Var2.f.a.d;
|
|
break;
|
|
}
|
|
x0Var2 = x0Var2.l;
|
|
} else {
|
|
j2 = this.e;
|
|
this.e = 1 + j2;
|
|
if (this.h == null) {
|
|
this.l = obj;
|
|
this.m = j2;
|
|
}
|
|
}
|
|
}
|
|
} else if (x0Var.b.equals(obj)) {
|
|
j2 = x0Var.f.a.d;
|
|
break;
|
|
} else {
|
|
x0Var = x0Var.l;
|
|
}
|
|
}
|
|
} else {
|
|
j2 = this.m;
|
|
}
|
|
return o(r1Var, obj, j, j2, this.a);
|
|
}
|
|
|
|
public final boolean p(r1 r1Var) {
|
|
x0 x0Var;
|
|
x0 x0Var2 = this.h;
|
|
if (x0Var2 == null) {
|
|
return true;
|
|
}
|
|
int b = r1Var.b(x0Var2.b);
|
|
while (true) {
|
|
b = r1Var.d(b, this.a, this.b, this.f, this.g);
|
|
while (true) {
|
|
x0Var = x0Var2.l;
|
|
if (x0Var == null || x0Var2.f.f) {
|
|
break;
|
|
}
|
|
x0Var2 = x0Var;
|
|
}
|
|
if (b == -1 || x0Var == null || r1Var.b(x0Var.b) != b) {
|
|
break;
|
|
}
|
|
x0Var2 = x0Var;
|
|
}
|
|
boolean m = m(x0Var2);
|
|
x0Var2.f = g(r1Var, x0Var2.f);
|
|
return !m;
|
|
}
|
|
|
|
public boolean q(r1 r1Var, long j, long j2) {
|
|
y0 y0Var;
|
|
boolean m;
|
|
x0 x0Var = this.h;
|
|
x0 x0Var2 = null;
|
|
while (x0Var != null) {
|
|
y0 y0Var2 = x0Var.f;
|
|
if (x0Var2 == null) {
|
|
y0Var = g(r1Var, y0Var2);
|
|
} else {
|
|
y0 c2 = c(r1Var, x0Var2, j);
|
|
if (c2 == null) {
|
|
m = m(x0Var2);
|
|
} else {
|
|
if (!(y0Var2.b == c2.b && y0Var2.a.equals(c2.a))) {
|
|
m = m(x0Var2);
|
|
} else {
|
|
y0Var = c2;
|
|
}
|
|
}
|
|
return !m;
|
|
}
|
|
x0Var.f = y0Var.a(y0Var2.f1012c);
|
|
long j3 = y0Var2.e;
|
|
long j4 = y0Var.e;
|
|
if (!(j3 == -9223372036854775807L || j3 == j4)) {
|
|
return !m(x0Var) && !(x0Var == this.i && ((j2 > Long.MIN_VALUE ? 1 : (j2 == Long.MIN_VALUE ? 0 : -1)) == 0 || (j2 > ((j4 > -9223372036854775807L ? 1 : (j4 == -9223372036854775807L ? 0 : -1)) == 0 ? Long.MAX_VALUE : x0Var.o + j4) ? 1 : (j2 == ((j4 > -9223372036854775807L ? 1 : (j4 == -9223372036854775807L ? 0 : -1)) == 0 ? Long.MAX_VALUE : x0Var.o + j4) ? 0 : -1)) >= 0));
|
|
}
|
|
x0Var2 = x0Var;
|
|
x0Var = x0Var.l;
|
|
}
|
|
return true;
|
|
}
|
|
}
|