Effect: Clearly state what callers must do onError.

Instead of invoking "undefined behavior" may occur when a class is used
incorrectly, which is clear but not very helpful to callers, specify what Apps
or users of a class should do when issues occur.

Apply this to Compositor as well, where this otherwise might seem unclear.

PiperOrigin-RevId: 563406219
This commit is contained in:
huangdarwin 2023-09-07 05:59:15 -07:00 committed by Copybara-Service
parent 3835aa5344
commit 19878b0b8b
3 changed files with 16 additions and 5 deletions

View File

@ -149,7 +149,8 @@ public interface VideoFrameProcessor {
/**
* Called when an exception occurs during asynchronous video frame processing.
*
* <p>Using {@code VideoFrameProcessor} after an error happens is undefined behavior.
* <p>If this is called, the calling {@link VideoFrameProcessor} must immediately be {@linkplain
* VideoFrameProcessor#release() released}.
*/
void onError(VideoFrameProcessingException exception);
@ -345,6 +346,8 @@ public interface VideoFrameProcessor {
* <p>This method blocks until all resources are released or releasing times out.
*
* <p>Can be called on any thread.
*
* <p>This {@link VideoFrameProcessor} instance must not be used after this method is called.
*/
void release();
}

View File

@ -35,7 +35,8 @@ public interface VideoCompositor extends GlTextureProducer {
/**
* Called when an exception occurs during asynchronous frame compositing.
*
* <p>Using {@link VideoCompositor} after an error happens is undefined behavior.
* <p>If this is called, the calling {@link VideoCompositor} must immediately be {@linkplain
* VideoCompositor#release() released}.
*/
void onError(VideoFrameProcessingException exception);
@ -87,6 +88,10 @@ public interface VideoCompositor extends GlTextureProducer {
GlTextureInfo inputTexture,
long presentationTimeUs);
/** Releases all resources. */
/**
* Releases all resources.
*
* <p>This {@link VideoCompositor} instance must not be used after this method is called.
*/
void release();
}

View File

@ -57,8 +57,8 @@ import java.util.concurrent.RejectedExecutionException;
/**
* Called when an exception occurs while executing submitted tasks.
*
* <p>Using the {@link VideoFrameProcessingTaskExecutor} after an error happens is undefined
* behavior.
* <p>If this is called, the calling {@link VideoFrameProcessingTaskExecutor} must immediately
* be {@linkplain VideoFrameProcessingTaskExecutor#release} released}.
*/
void onError(VideoFrameProcessingException exception);
}
@ -160,6 +160,9 @@ import java.util.concurrent.RejectedExecutionException;
* <p>If {@code shouldShutdownExecutorService} is {@code true}, shuts down the {@linkplain
* ExecutorService background thread}.
*
* <p>This {@link VideoFrameProcessingTaskExecutor} instance must not be used after this method is
* called.
*
* @param releaseTask A {@link Task} to execute before shutting down the background thread.
* @throws InterruptedException If interrupted while releasing resources.
*/