mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
TextureInput: Advise client to delete syncObject after use
PiperOrigin-RevId: 544670927
This commit is contained in:
parent
58180a0f2a
commit
6f9731ce7e
@ -27,7 +27,8 @@ public interface OnInputFrameProcessedListener {
|
|||||||
* @param textureId The identifier of the processed texture.
|
* @param textureId The identifier of the processed texture.
|
||||||
* @param syncObject A GL sync object that has been inserted into the GL command stream after the
|
* @param syncObject A GL sync object that has been inserted into the GL command stream after the
|
||||||
* last write of texture. Value is 0 if and only if the {@code GLES30#glFenceSync} failed or
|
* last write of texture. Value is 0 if and only if the {@code GLES30#glFenceSync} failed or
|
||||||
* the EGL context version is less than openGL 3.0.
|
* the EGL context version is less than openGL 3.0. The sync object must be {@link
|
||||||
|
* androidx.media3.common.util.GlUtil#deleteSyncObject deleted} after use.
|
||||||
*/
|
*/
|
||||||
void onInputFrameProcessed(int textureId, long syncObject) throws VideoFrameProcessingException;
|
void onInputFrameProcessed(int textureId, long syncObject) throws VideoFrameProcessingException;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
private @MonotonicNonNull OnInputFrameProcessedListener frameProcessedListener;
|
private @MonotonicNonNull OnInputFrameProcessedListener frameProcessedListener;
|
||||||
private @MonotonicNonNull FrameInfo inputFrameInfo;
|
private @MonotonicNonNull FrameInfo inputFrameInfo;
|
||||||
private long glSyncObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
@ -68,11 +67,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
@Override
|
@Override
|
||||||
public void onInputFrameProcessed(GlTextureInfo inputTexture) {
|
public void onInputFrameProcessed(GlTextureInfo inputTexture) {
|
||||||
videoFrameProcessingTaskExecutor.submit(
|
videoFrameProcessingTaskExecutor.submit(
|
||||||
() -> {
|
() ->
|
||||||
glSyncObject = GlUtil.createGlSyncFence();
|
checkNotNull(frameProcessedListener)
|
||||||
checkNotNull(frameProcessedListener)
|
.onInputFrameProcessed(inputTexture.getTexId(), GlUtil.createGlSyncFence()));
|
||||||
.onInputFrameProcessed(inputTexture.getTexId(), glSyncObject);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -128,10 +125,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release() throws VideoFrameProcessingException {
|
public void release() throws VideoFrameProcessingException {
|
||||||
try {
|
// Do nothing.
|
||||||
GlUtil.deleteSyncObject(glSyncObject);
|
|
||||||
} catch (GlUtil.GlException e) {
|
|
||||||
throw new VideoFrameProcessingException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,9 +354,10 @@ public final class VideoFrameProcessorTestRunner {
|
|||||||
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
|
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
|
||||||
.build());
|
.build());
|
||||||
videoFrameProcessor.setOnInputFrameProcessedListener(
|
videoFrameProcessor.setOnInputFrameProcessedListener(
|
||||||
(texId, unused) -> {
|
(texId, syncObject) -> {
|
||||||
try {
|
try {
|
||||||
GlUtil.deleteTexture(texId);
|
GlUtil.deleteTexture(texId);
|
||||||
|
GlUtil.deleteSyncObject(syncObject);
|
||||||
} catch (GlUtil.GlException e) {
|
} catch (GlUtil.GlException e) {
|
||||||
throw new VideoFrameProcessingException(e);
|
throw new VideoFrameProcessingException(e);
|
||||||
}
|
}
|
||||||
|
@ -503,9 +503,10 @@ public class TransformerEndToEndTest {
|
|||||||
EditedMediaItem editedMediaItem, Looper looper, AssetLoader.Listener listener) {
|
EditedMediaItem editedMediaItem, Looper looper, AssetLoader.Listener listener) {
|
||||||
Format format = new Format.Builder().setWidth(width).setHeight(height).build();
|
Format format = new Format.Builder().setWidth(width).setHeight(height).build();
|
||||||
OnInputFrameProcessedListener frameProcessedListener =
|
OnInputFrameProcessedListener frameProcessedListener =
|
||||||
(texId, unused) -> {
|
(texId, syncObject) -> {
|
||||||
try {
|
try {
|
||||||
GlUtil.deleteTexture(texId);
|
GlUtil.deleteTexture(texId);
|
||||||
|
GlUtil.deleteSyncObject(syncObject);
|
||||||
} catch (GlUtil.GlException e) {
|
} catch (GlUtil.GlException e) {
|
||||||
throw new VideoFrameProcessingException(e);
|
throw new VideoFrameProcessingException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user