From f95c11cab9ef15dbedd05b4245dfcebb36c054b4 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Tue, 21 Jan 2020 14:01:11 +0000 Subject: [PATCH] Fix BaseFilter bug --- .../com/otaliastudios/cameraview/filter/BaseFilter.java | 7 ++++--- .../com/otaliastudios/cameraview/demo/CameraActivity.java | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/filter/BaseFilter.java b/cameraview/src/main/java/com/otaliastudios/cameraview/filter/BaseFilter.java index 288fddbd..143d51e1 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/filter/BaseFilter.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/filter/BaseFilter.java @@ -133,9 +133,10 @@ public abstract class BaseFilter implements Filter { @Override public void onDestroy() { - // NOTE: this destroys the GL program, but Filter consumers (GlTextureDrawer, MultiFilter) - // will destroy it too (just like they create it). Hope this doesn't cause any issue; - // if it does, we could avoid calling release here. + // Since we used the handle constructor of GlTextureProgram, calling release here + // will NOT destroy the GL program. This is important because Filters are not supposed + // to have ownership of programs. Creation and deletion happen outside, and deleting twice + // would cause an error. program.release(); program = null; } diff --git a/demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java b/demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java index 1ee1891e..cba4cbad 100644 --- a/demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java +++ b/demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java @@ -47,8 +47,8 @@ import java.util.List; public class CameraActivity extends AppCompatActivity implements View.OnClickListener, OptionView.Callback { private final static CameraLogger LOG = CameraLogger.create("DemoApp"); - private final static boolean USE_FRAME_PROCESSOR = true; - private final static boolean DECODE_BITMAP = true; + private final static boolean USE_FRAME_PROCESSOR = false; + private final static boolean DECODE_BITMAP = false; private CameraView camera; private ViewGroup controlPanel; @@ -76,7 +76,7 @@ public class CameraActivity extends AppCompatActivity implements View.OnClickLis long newTime = frame.getTime(); long delay = newTime - lastTime; lastTime = newTime; - LOG.e("Frame delayMillis:", delay, "FPS:", 1000 / delay); + LOG.v("Frame delayMillis:", delay, "FPS:", 1000 / delay); if (DECODE_BITMAP) { if (frame.getFormat() == ImageFormat.NV21 && frame.getDataClass() == byte[].class) {