mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
MultipleInputVideoGraph: Destroy EGL context on GL thread
PiperOrigin-RevId: 725159572
This commit is contained in:
parent
cadecf0219
commit
faf555e12b
@ -49,7 +49,6 @@ import androidx.media3.common.VideoCompositorSettings;
|
||||
import androidx.media3.common.VideoFrameProcessingException;
|
||||
import androidx.media3.common.VideoFrameProcessor;
|
||||
import androidx.media3.common.VideoGraph;
|
||||
import androidx.media3.common.util.GlUtil;
|
||||
import androidx.media3.common.util.GlUtil.GlException;
|
||||
import androidx.media3.common.util.Log;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
@ -60,6 +59,7 @@ import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
/** A {@link VideoGraph} that handles multiple input streams. */
|
||||
@ -306,21 +306,25 @@ public abstract class MultipleInputVideoGraph implements VideoGraph {
|
||||
compositionVideoFrameProcessor = null;
|
||||
}
|
||||
|
||||
try {
|
||||
// The eglContext is not released by any of the frame processors.
|
||||
if (glObjectsProvider.singleEglContext != null) {
|
||||
destroyEglContext(getDefaultEglDisplay(), glObjectsProvider.singleEglContext);
|
||||
}
|
||||
} catch (GlUtil.GlException e) {
|
||||
Log.e(TAG, "Error releasing GL context", e);
|
||||
}
|
||||
Future<?> unused =
|
||||
sharedExecutorService.submit(
|
||||
() -> {
|
||||
try {
|
||||
// The eglContext is not released by any of the frame processors.
|
||||
if (glObjectsProvider.singleEglContext != null) {
|
||||
destroyEglContext(getDefaultEglDisplay(), glObjectsProvider.singleEglContext);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error releasing GL context", e);
|
||||
}
|
||||
});
|
||||
|
||||
sharedExecutorService.shutdown();
|
||||
try {
|
||||
sharedExecutorService.awaitTermination(RELEASE_WAIT_TIME_MS, MILLISECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
listenerExecutor.execute(() -> listener.onError(VideoFrameProcessingException.from(e)));
|
||||
Log.e(TAG, "Thread interrupted while waiting for executor service termination");
|
||||
}
|
||||
|
||||
released = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user