jimu-decompiled/sources/com/hw/videoprocessor/util/OutputSurface.java
2025-05-13 19:24:51 +02:00

97 lines
2.8 KiB
Java

package com.hw.videoprocessor.util;
import android.annotation.TargetApi;
import android.graphics.SurfaceTexture;
import android.view.Surface;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
@TargetApi(16)
/* loaded from: classes.dex */
public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener {
private EGL10 a;
private SurfaceTexture e;
private Surface f;
private boolean h;
private TextureRenderer i;
private EGLDisplay b = null;
private EGLContext c = null;
private EGLSurface d = null;
private final Object g = new Object();
private int j = 0;
public OutputSurface() {
d();
}
private void d() {
this.i = new TextureRenderer(this.j);
this.i.b();
this.e = new SurfaceTexture(this.i.a());
this.e.setOnFrameAvailableListener(this);
this.f = new Surface(this.e);
}
public void a() {
synchronized (this.g) {
do {
if (this.h) {
this.h = false;
} else {
try {
this.g.wait(5000L);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
} while (this.h);
throw new RuntimeException("Surface frame wait timed out");
}
this.i.a("before updateTexImage");
this.e.updateTexImage();
}
public Surface b() {
return this.f;
}
public void c() {
EGL10 egl10 = this.a;
if (egl10 != null) {
if (egl10.eglGetCurrentContext().equals(this.c)) {
EGL10 egl102 = this.a;
EGLDisplay eGLDisplay = this.b;
EGLSurface eGLSurface = EGL10.EGL_NO_SURFACE;
egl102.eglMakeCurrent(eGLDisplay, eGLSurface, eGLSurface, EGL10.EGL_NO_CONTEXT);
}
this.a.eglDestroySurface(this.b, this.d);
this.a.eglDestroyContext(this.b, this.c);
}
this.f.release();
this.b = null;
this.c = null;
this.d = null;
this.a = null;
this.i = null;
this.f = null;
this.e = null;
}
@Override // android.graphics.SurfaceTexture.OnFrameAvailableListener
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
synchronized (this.g) {
if (this.h) {
throw new RuntimeException("mFrameAvailable already set, frame could be dropped");
}
this.h = true;
this.g.notifyAll();
}
}
public void a(boolean z) {
this.i.a(this.e, z);
}
}