mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Block until FrameProcessorChain is released.
This is safer because it will prevent any future problems with creating a new FrameProcessorChain before the previous one has completed its async release. From [eglDestroyContext documentation](https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglDestroyContext.xhtml): "If the EGL rendering context is not current to any thread, eglDestroyContext destroys it immediately." The context isn't current to any thread here because GlUtil calls eglMakeCurrent with EGL_NO_CONTEXT before calling eglDestroyContext. So everthing should be released once the FrameProcessorChain's release task terminates. PiperOrigin-RevId: 442807484
This commit is contained in:
parent
570769ac9a
commit
ba5d570aca
1 changed files with 13 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkState;
|
import static com.google.android.exoplayer2.util.Assertions.checkState;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
||||||
import static com.google.common.collect.Iterables.getLast;
|
import static com.google.common.collect.Iterables.getLast;
|
||||||
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.SurfaceTexture;
|
import android.graphics.SurfaceTexture;
|
||||||
|
|
@ -36,6 +37,7 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.util.GlUtil;
|
import com.google.android.exoplayer2.util.GlUtil;
|
||||||
|
import com.google.android.exoplayer2.util.Log;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -183,7 +185,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
enableExperimentalHdrEditing);
|
enableExperimentalHdrEditing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String TAG = "FrameProcessorChain";
|
||||||
private static final String THREAD_NAME = "Transformer:FrameProcessorChain";
|
private static final String THREAD_NAME = "Transformer:FrameProcessorChain";
|
||||||
|
private static final long RELEASE_WAIT_TIME_MS = 100;
|
||||||
|
|
||||||
private final boolean enableExperimentalHdrEditing;
|
private final boolean enableExperimentalHdrEditing;
|
||||||
private final EGLDisplay eglDisplay;
|
private final EGLDisplay eglDisplay;
|
||||||
|
|
@ -373,6 +377,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
* <p>If the frame processor chain is released before it has {@linkplain #isEnded() ended}, it
|
* <p>If the frame processor chain is released before it has {@linkplain #isEnded() ended}, it
|
||||||
* will attempt to cancel processing any input frames that have already become available. Input
|
* will attempt to cancel processing any input frames that have already become available. Input
|
||||||
* frames that become available after release are ignored.
|
* frames that become available after release are ignored.
|
||||||
|
*
|
||||||
|
* <p>This method blocks until all OpenGL resources are released or releasing times out.
|
||||||
*/
|
*/
|
||||||
public void release() {
|
public void release() {
|
||||||
releaseRequested = true;
|
releaseRequested = true;
|
||||||
|
|
@ -394,6 +400,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
inputSurface.release();
|
inputSurface.release();
|
||||||
}
|
}
|
||||||
singleThreadExecutorService.shutdown();
|
singleThreadExecutorService.shutdown();
|
||||||
|
try {
|
||||||
|
if (!singleThreadExecutorService.awaitTermination(RELEASE_WAIT_TIME_MS, MILLISECONDS)) {
|
||||||
|
Log.d(TAG, "Failed to release FrameProcessorChain");
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Log.d(TAG, "FrameProcessorChain release was interrupted", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue