Effect: Reduce Compositor exception try/catch redirection.

The VideoFrameProcessingTaskExecutor already handles wrapping
GlUtil.GlException errors into VideoFrameProcessingExceptions.
Therefore, stop wrapping this ourselves, so that errors are
attributed to the correct line number with less indirection.

PiperOrigin-RevId: 549959258
This commit is contained in:
huangdarwin 2023-07-21 16:50:43 +01:00 committed by Rohit Singh
parent 7eee15ecb4
commit b1cf5fb320

View File

@ -173,7 +173,8 @@ public final class VideoCompositor {
glObjectsProvider.createFocusedPlaceholderEglSurface(eglContext, eglDisplay);
}
private synchronized void maybeComposite() throws VideoFrameProcessingException {
private synchronized void maybeComposite()
throws VideoFrameProcessingException, GlUtil.GlException {
if (!isReadyToComposite()) {
return;
}
@ -192,27 +193,20 @@ public final class VideoCompositor {
InputFrameInfo inputFrame2 = framesToComposite.get(1);
checkState(inputFrame1.texture.width == inputFrame2.texture.width);
checkState(inputFrame1.texture.height == inputFrame2.texture.height);
try {
outputTexturePool.ensureConfigured(
glObjectsProvider, inputFrame1.texture.width, inputFrame1.texture.height);
GlTextureInfo outputTexture = outputTexturePool.useTexture();
long outputPresentationTimestampUs = framesToComposite.get(0).presentationTimeUs;
outputTextureTimestamps.add(outputPresentationTimestampUs);
outputTexturePool.ensureConfigured(
glObjectsProvider, inputFrame1.texture.width, inputFrame1.texture.height);
GlTextureInfo outputTexture = outputTexturePool.useTexture();
long outputPresentationTimestampUs = framesToComposite.get(0).presentationTimeUs;
outputTextureTimestamps.add(outputPresentationTimestampUs);
drawFrame(inputFrame1.texture, inputFrame2.texture, outputTexture);
long syncObject = GlUtil.createGlSyncFence();
syncObjects.add(syncObject);
textureOutputListener.onTextureRendered(
outputTexture,
/* presentationTimeUs= */ framesToComposite.get(0).presentationTimeUs,
this::releaseOutputFrame,
syncObject);
for (int i = 0; i < framesToComposite.size(); i++) {
InputFrameInfo inputFrameInfo = framesToComposite.get(i);
inputFrameInfo.releaseCallback.release(inputFrameInfo.presentationTimeUs);
}
} catch (GlUtil.GlException e) {
throw VideoFrameProcessingException.from(e);
drawFrame(inputFrame1.texture, inputFrame2.texture, outputTexture);
long syncObject = GlUtil.createGlSyncFence();
syncObjects.add(syncObject);
textureOutputListener.onTextureRendered(
outputTexture, outputPresentationTimestampUs, this::releaseOutputFrame, syncObject);
for (int i = 0; i < framesToComposite.size(); i++) {
InputFrameInfo inputFrameInfo = framesToComposite.get(i);
inputFrameInfo.releaseCallback.release(inputFrameInfo.presentationTimeUs);
}
}
@ -255,7 +249,8 @@ public final class VideoCompositor {
maybeComposite();
}
private void ensureGlProgramConfigured() throws VideoFrameProcessingException {
private void ensureGlProgramConfigured()
throws VideoFrameProcessingException, GlUtil.GlException {
if (glProgram != null) {
return;
}
@ -265,7 +260,7 @@ public final class VideoCompositor {
"aFramePosition",
GlUtil.getNormalizedCoordinateBounds(),
GlUtil.HOMOGENEOUS_COORDINATE_VECTOR_SIZE);
} catch (GlUtil.GlException | IOException e) {
} catch (IOException e) {
throw new VideoFrameProcessingException(e);
}
}