Skip to content

Commit

Permalink
Tidy releasing FrameProcessorChain
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 449238525
  • Loading branch information
andrewlewis authored and icbaker committed May 24, 2022
1 parent a9bdd6e commit dcb58c7
Showing 1 changed file with 3 additions and 8 deletions.
Expand Up @@ -50,7 +50,6 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.RequiresNonNull;

/**
* {@code FrameProcessorChain} applies changes to individual video frames.
Expand Down Expand Up @@ -439,20 +438,17 @@ public void release() {
}
futures.add(
singleThreadExecutorService.submit(this::releaseFrameProcessorsAndDestroyGlContext));
if (inputSurfaceTexture != null) {
inputSurfaceTexture.release();
}
if (inputSurface != null) {
inputSurface.release();
}
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);
Thread.currentThread().interrupt();
}
inputSurfaceTexture.release();
inputSurface.release();
}

/**
Expand Down Expand Up @@ -491,7 +487,6 @@ private void createOpenGlSurfaces(Surface outputSurface, @Nullable SurfaceView d
* <p>This method must be called on the {@linkplain #THREAD_NAME background thread}.
*/
@WorkerThread
@RequiresNonNull("inputSurfaceTexture")
private void processFrame() {
if (stopProcessing.get()) {
return;
Expand Down

0 comments on commit dcb58c7

Please sign in to comment.