discord-jadx/app/src/main/java/c/i/a/c/j2/t.java

271 lines
8.4 KiB
Java

package c.i.a.c.j2;
import android.content.Context;
import android.hardware.display.DisplayManager;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.Choreographer;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import c.i.a.c.i2.f0;
import c.i.a.c.i2.p;
import c.i.a.c.j2.l;
import java.util.Objects;
/* compiled from: VideoFrameReleaseHelper */
public final class t {
public final l a = new l();
@Nullable
public final WindowManager b;
@Nullable
/* renamed from: c reason: collision with root package name */
public final b f921c;
@Nullable
public final a d;
public boolean e;
@Nullable
public Surface f;
public float g;
public float h;
public float i;
public float j;
public long k;
public long l;
public long m;
public long n;
public long o;
public long p;
public long q;
/* compiled from: VideoFrameReleaseHelper */
@RequiresApi(17)
public final class a implements DisplayManager.DisplayListener {
public final DisplayManager a;
public a(DisplayManager displayManager) {
this.a = displayManager;
}
@Override // android.hardware.display.DisplayManager.DisplayListener
public void onDisplayAdded(int i) {
}
@Override // android.hardware.display.DisplayManager.DisplayListener
public void onDisplayChanged(int i) {
if (i == 0) {
t.this.d();
}
}
@Override // android.hardware.display.DisplayManager.DisplayListener
public void onDisplayRemoved(int i) {
}
}
/* compiled from: VideoFrameReleaseHelper */
public static final class b implements Choreographer.FrameCallback, Handler.Callback {
public static final b i = new b();
public volatile long j = -9223372036854775807L;
public final Handler k;
public final HandlerThread l;
public Choreographer m;
public int n;
public b() {
HandlerThread handlerThread = new HandlerThread("ExoPlayer:FrameReleaseChoreographer");
this.l = handlerThread;
handlerThread.start();
Looper looper = handlerThread.getLooper();
int i2 = f0.a;
Handler handler = new Handler(looper, this);
this.k = handler;
handler.sendEmptyMessage(0);
}
@Override // android.view.Choreographer.FrameCallback
public void doFrame(long j) {
this.j = j;
Choreographer choreographer = this.m;
Objects.requireNonNull(choreographer);
choreographer.postFrameCallbackDelayed(this, 500);
}
@Override // android.os.Handler.Callback
public boolean handleMessage(Message message) {
int i2 = message.what;
if (i2 == 0) {
this.m = Choreographer.getInstance();
return true;
} else if (i2 == 1) {
int i3 = this.n + 1;
this.n = i3;
if (i3 == 1) {
Choreographer choreographer = this.m;
Objects.requireNonNull(choreographer);
choreographer.postFrameCallback(this);
}
return true;
} else if (i2 != 2) {
return false;
} else {
int i4 = this.n - 1;
this.n = i4;
if (i4 == 0) {
Choreographer choreographer2 = this.m;
Objects.requireNonNull(choreographer2);
choreographer2.removeFrameCallback(this);
this.j = -9223372036854775807L;
}
return true;
}
}
}
public t(@Nullable Context context) {
a aVar = null;
if (context != null) {
context = context.getApplicationContext();
this.b = (WindowManager) context.getSystemService("window");
} else {
this.b = null;
}
if (this.b != null) {
if (f0.a >= 17) {
Objects.requireNonNull(context);
DisplayManager displayManager = (DisplayManager) context.getSystemService("display");
if (displayManager != null) {
aVar = new a(displayManager);
}
}
this.d = aVar;
this.f921c = b.i;
} else {
this.d = null;
this.f921c = null;
}
this.k = -9223372036854775807L;
this.l = -9223372036854775807L;
this.g = -1.0f;
this.j = 1.0f;
}
@RequiresApi(30)
public static void c(Surface surface, float f) {
try {
surface.setFrameRate(f, f == 0.0f ? 0 : 1);
} catch (IllegalStateException e) {
p.b("VideoFrameReleaseHelper", "Failed to call Surface.setFrameRate", e);
}
}
public final void a() {
Surface surface;
if (f0.a >= 30 && (surface = this.f) != null && this.i != 0.0f) {
this.i = 0.0f;
c(surface, 0.0f);
}
}
public final void b() {
this.m = 0;
this.p = -1;
this.n = -1;
}
public final void d() {
WindowManager windowManager = this.b;
Objects.requireNonNull(windowManager);
Display defaultDisplay = windowManager.getDefaultDisplay();
if (defaultDisplay != null) {
long refreshRate = (long) (1.0E9d / ((double) defaultDisplay.getRefreshRate()));
this.k = refreshRate;
this.l = (refreshRate * 80) / 100;
return;
}
Log.w("VideoFrameReleaseHelper", "Unable to query display refresh rate");
this.k = -9223372036854775807L;
this.l = -9223372036854775807L;
}
/* JADX WARNING: Code restructure failed: missing block: B:35:0x0083, code lost:
if (java.lang.Math.abs(r0 - r10.h) < (!r1 ? 0.02f : 1.0f)) goto L_0x0086;
*/
/* JADX WARNING: Code restructure failed: missing block: B:39:0x008f, code lost:
if (r10.a.e >= 30) goto L_0x0091;
*/
/* JADX WARNING: Removed duplicated region for block: B:32:0x0073 */
/* JADX WARNING: Removed duplicated region for block: B:33:0x0077 */
/* JADX WARNING: Removed duplicated region for block: B:41:0x0093 */
/* JADX WARNING: Removed duplicated region for block: B:44:? A[RETURN, SYNTHETIC] */
public final void e() {
float f;
boolean z2;
if (f0.a >= 30 && this.f != null) {
if (this.a.a()) {
l lVar = this.a;
if (lVar.a()) {
l.a aVar = lVar.a;
long j = aVar.e;
long j2 = 0;
if (j != 0) {
j2 = aVar.f / j;
}
f = (float) (1.0E9d / ((double) j2));
} else {
f = -1.0f;
}
} else {
f = this.g;
}
float f2 = this.h;
if (f != f2) {
boolean z3 = true;
int i = (f > -1.0f ? 1 : (f == -1.0f ? 0 : -1));
if (i == 0 || f2 == -1.0f) {
if (i == 0) {
}
if (!z3) {
this.h = f;
f(false);
return;
}
return;
}
if (this.a.a()) {
l lVar2 = this.a;
if ((lVar2.a() ? lVar2.a.f : -9223372036854775807L) >= 5000000000L) {
z2 = true;
}
}
z2 = false;
z3 = false;
if (!z3) {
}
}
}
}
public final void f(boolean z2) {
Surface surface;
if (f0.a >= 30 && (surface = this.f) != null) {
float f = 0.0f;
if (this.e) {
float f2 = this.h;
if (f2 != -1.0f) {
f = this.j * f2;
}
}
if (z2 || this.i != f) {
this.i = f;
c(surface, f);
}
}
}
}