discord-jadx/app/src/main/java/c/i/a/c/x1/g.java

237 lines
6.7 KiB
Java

package c.i.a.c.x1;
import androidx.annotation.CallSuper;
import androidx.annotation.Nullable;
import c.i.a.c.e2.d;
import c.i.a.c.e2.e;
import c.i.a.c.e2.i;
import c.i.a.c.x1.f;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.google.android.exoplayer2.decoder.DecoderException;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.text.SubtitleDecoderException;
import java.util.ArrayDeque;
import java.util.Objects;
/* compiled from: SimpleDecoder */
public abstract class g<I extends DecoderInputBuffer, O extends f, E extends DecoderException> implements c<I, O, E> {
public final Thread a;
public final Object b = new Object();
/* renamed from: c reason: collision with root package name */
public final ArrayDeque<I> f1011c = new ArrayDeque<>();
public final ArrayDeque<O> d = new ArrayDeque<>();
public final I[] e;
public final O[] f;
public int g;
public int h;
public I i;
public E j;
public boolean k;
public boolean l;
public int m;
/* compiled from: SimpleDecoder */
public class a extends Thread {
public a(String str) {
super(str);
}
@Override // java.lang.Thread, java.lang.Runnable
public void run() {
g gVar = g.this;
Objects.requireNonNull(gVar);
do {
try {
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
} while (gVar.f());
}
}
public g(I[] iArr, O[] oArr) {
this.e = iArr;
this.g = iArr.length;
for (int i = 0; i < this.g; i++) {
this.e[i] = new i();
}
this.f = oArr;
this.h = oArr.length;
for (int i2 = 0; i2 < this.h; i2++) {
this.f[i2] = new e(new c.i.a.c.e2.a((d) this));
}
a aVar = new a("ExoPlayer:SimpleDecoder");
this.a = aVar;
aVar.start();
}
@Override // c.i.a.c.x1.c
@Nullable
public Object b() throws DecoderException {
O removeFirst;
synchronized (this.b) {
h();
removeFirst = this.d.isEmpty() ? null : this.d.removeFirst();
}
return removeFirst;
}
@Override // c.i.a.c.x1.c
@Nullable
public Object c() throws DecoderException {
I i;
synchronized (this.b) {
h();
AnimatableValueParser.D(this.i == null);
int i2 = this.g;
if (i2 == 0) {
i = null;
} else {
I[] iArr = this.e;
int i3 = i2 - 1;
this.g = i3;
i = iArr[i3];
}
this.i = i;
}
return i;
}
/* JADX DEBUG: Multi-variable search result rejected for r1v2, resolved type: java.util.ArrayDeque<I extends com.google.android.exoplayer2.decoder.DecoderInputBuffer> */
/* JADX WARN: Multi-variable type inference failed */
@Override // c.i.a.c.x1.c
public void d(Object obj) throws DecoderException {
DecoderInputBuffer decoderInputBuffer = (DecoderInputBuffer) obj;
synchronized (this.b) {
h();
AnimatableValueParser.k(decoderInputBuffer == this.i);
this.f1011c.addLast(decoderInputBuffer);
g();
this.i = null;
}
}
@Nullable
public abstract E e(I i, O o, boolean z2);
/* JADX WARNING: Removed duplicated region for block: B:33:0x006b */
/* JADX WARNING: Removed duplicated region for block: B:44:0x0078 A[SYNTHETIC] */
public final boolean f() throws InterruptedException {
I removeFirst;
O o;
boolean z2;
SubtitleDecoderException subtitleDecoderException;
SubtitleDecoderException subtitleDecoderException2;
synchronized (this.b) {
while (!this.l) {
if (!this.f1011c.isEmpty() && this.h > 0) {
break;
}
this.b.wait();
}
if (this.l) {
return false;
}
removeFirst = this.f1011c.removeFirst();
O[] oArr = this.f;
int i = this.h - 1;
this.h = i;
o = oArr[i];
z2 = this.k;
this.k = false;
}
if (removeFirst.n()) {
o.j(4);
} else {
if (removeFirst.m()) {
o.j(Integer.MIN_VALUE);
}
try {
subtitleDecoderException = e(removeFirst, o, z2);
} catch (RuntimeException e) {
subtitleDecoderException2 = new SubtitleDecoderException("Unexpected decode error", e);
} catch (OutOfMemoryError e2) {
subtitleDecoderException2 = new SubtitleDecoderException("Unexpected decode error", e2);
}
if (subtitleDecoderException != null) {
synchronized (this.b) {
this.j = subtitleDecoderException;
}
return false;
}
}
synchronized (this.b) {
if (this.k) {
o.p();
} else if (o.m()) {
this.m++;
o.p();
} else {
this.m = 0;
this.d.addLast(o);
}
i(removeFirst);
}
return true;
subtitleDecoderException = subtitleDecoderException2;
if (subtitleDecoderException != null) {
}
synchronized (this.b) {
}
}
@Override // c.i.a.c.x1.c
public final void flush() {
synchronized (this.b) {
this.k = true;
this.m = 0;
I i = this.i;
if (i != null) {
i(i);
this.i = null;
}
while (!this.f1011c.isEmpty()) {
i(this.f1011c.removeFirst());
}
while (!this.d.isEmpty()) {
this.d.removeFirst().p();
}
}
}
public final void g() {
if (!this.f1011c.isEmpty() && this.h > 0) {
this.b.notify();
}
}
public final void h() throws DecoderException {
E e = this.j;
if (e != null) {
throw e;
}
}
public final void i(I i) {
i.p();
I[] iArr = this.e;
int i2 = this.g;
this.g = i2 + 1;
iArr[i2] = i;
}
@Override // c.i.a.c.x1.c
@CallSuper
public void release() {
synchronized (this.b) {
this.l = true;
this.b.notify();
}
try {
this.a.join();
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
}
}
}