discord-jadx/app/src/main/java/c/i/a/c/b2/n.java

127 lines
3.6 KiB
Java

package c.i.a.c.b2;
import android.media.MediaCodec;
import android.os.Handler;
import android.os.HandlerThread;
import androidx.annotation.GuardedBy;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import c.i.a.c.i2.f0;
import c.i.a.c.i2.j;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicReference;
/* compiled from: AsynchronousMediaCodecBufferEnqueuer */
@RequiresApi(23)
public class n {
@GuardedBy("MESSAGE_PARAMS_INSTANCE_POOL")
public static final ArrayDeque<a> a = new ArrayDeque<>();
public static final Object b = new Object();
/* renamed from: c reason: collision with root package name */
public final MediaCodec f765c;
public final HandlerThread d;
public Handler e;
public final AtomicReference<RuntimeException> f = new AtomicReference<>();
public final j g;
public final boolean h;
public boolean i;
/* compiled from: AsynchronousMediaCodecBufferEnqueuer */
public static class a {
public int a;
public int b;
/* renamed from: c reason: collision with root package name */
public int f766c;
public final MediaCodec.CryptoInfo d = new MediaCodec.CryptoInfo();
public long e;
public int f;
}
/* JADX WARNING: Code restructure failed: missing block: B:8:0x0033, code lost:
if ((r4.contains("samsung") || r4.contains("motorola")) != false) goto L_0x0035;
*/
public n(MediaCodec mediaCodec, HandlerThread handlerThread, boolean z2) {
j jVar = new j();
this.f765c = mediaCodec;
this.d = handlerThread;
this.g = jVar;
boolean z3 = false;
if (!z2) {
String K = f0.K(f0.f904c);
}
z3 = true;
this.h = z3;
}
@Nullable
public static byte[] b(@Nullable byte[] bArr, @Nullable byte[] bArr2) {
if (bArr == null) {
return bArr2;
}
if (bArr2 == null || bArr2.length < bArr.length) {
return Arrays.copyOf(bArr, bArr.length);
}
System.arraycopy(bArr, 0, bArr2, 0, bArr.length);
return bArr2;
}
@Nullable
public static int[] c(@Nullable int[] iArr, @Nullable int[] iArr2) {
if (iArr == null) {
return iArr2;
}
if (iArr2 == null || iArr2.length < iArr.length) {
return Arrays.copyOf(iArr, iArr.length);
}
System.arraycopy(iArr, 0, iArr2, 0, iArr.length);
return iArr2;
}
public static a e() {
ArrayDeque<a> arrayDeque = a;
synchronized (arrayDeque) {
if (arrayDeque.isEmpty()) {
return new a();
}
return arrayDeque.removeFirst();
}
}
public final void a() throws InterruptedException {
this.g.a();
Handler handler = this.e;
int i = f0.a;
handler.obtainMessage(2).sendToTarget();
j jVar = this.g;
synchronized (jVar) {
while (!jVar.b) {
jVar.wait();
}
}
}
public void d() {
if (this.i) {
try {
Handler handler = this.e;
int i = f0.a;
handler.removeCallbacksAndMessages(null);
a();
f();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException(e);
}
}
}
public final void f() {
RuntimeException andSet = this.f.getAndSet(null);
if (andSet != null) {
throw andSet;
}
}
}