diff --git a/library/src/main/java/com/pedro/library/view/GlStreamInterface.kt b/library/src/main/java/com/pedro/library/view/GlStreamInterface.kt index e7d8e9d72..9e2548c5c 100644 --- a/library/src/main/java/com/pedro/library/view/GlStreamInterface.kt +++ b/library/src/main/java/com/pedro/library/view/GlStreamInterface.kt @@ -171,7 +171,8 @@ class GlStreamInterface(private val context: Context): OnFrameAvailableListener, } private fun draw(forced: Boolean) { - if (!isRunning || fpsLimiter.limitFPS()) return + if (!isRunning) return + val limitFps = fpsLimiter.limitFPS() if (!forced) forceRender.frameAvailable() if (surfaceManager.isReady && mainRender.isReady()) { @@ -197,7 +198,7 @@ class GlStreamInterface(private val context: Context): OnFrameAvailableListener, OrientationForced.NONE -> isPortrait } // render VideoEncoder (stream and record) - if (surfaceManagerEncoder.isReady && mainRender.isReady()) { + if (surfaceManagerEncoder.isReady && mainRender.isReady() && !limitFps) { val w = if (muteVideo) 0 else encoderWidth val h = if (muteVideo) 0 else encoderHeight surfaceManagerEncoder.makeCurrent() @@ -215,7 +216,7 @@ class GlStreamInterface(private val context: Context): OnFrameAvailableListener, surfaceManagerPhoto.swapBuffer() } // render preview - if (surfaceManagerPreview.isReady && mainRender.isReady()) { + if (surfaceManagerPreview.isReady && mainRender.isReady() && !limitFps) { val w = if (previewWidth == 0) encoderWidth else previewWidth val h = if (previewHeight == 0) encoderHeight else previewHeight surfaceManagerPreview.makeCurrent() diff --git a/library/src/main/java/com/pedro/library/view/OpenGlView.java b/library/src/main/java/com/pedro/library/view/OpenGlView.java index 4befc51a3..44aef00ba 100644 --- a/library/src/main/java/com/pedro/library/view/OpenGlView.java +++ b/library/src/main/java/com/pedro/library/view/OpenGlView.java @@ -235,16 +235,19 @@ public void takePhoto(TakePhotoCallback takePhotoCallback) { } private void draw(boolean forced) { - if (!isRunning() || fpsLimiter.limitFPS()) return; + if (!isRunning()) return; + boolean limitFps = fpsLimiter.limitFPS(); if (!forced) forceRenderer.frameAvailable(); if (surfaceManager.isReady() && mainRender.isReady()) { surfaceManager.makeCurrent(); mainRender.updateFrame(); mainRender.drawOffScreen(); - mainRender.drawScreen(previewWidth, previewHeight, aspectRatioMode, 0, - isPreviewVerticalFlip, isPreviewHorizontalFlip); - surfaceManager.swapBuffer(); + if (!limitFps) { + mainRender.drawScreen(previewWidth, previewHeight, aspectRatioMode, 0, + isPreviewVerticalFlip, isPreviewHorizontalFlip); + surfaceManager.swapBuffer(); + } } if (!filterQueue.isEmpty() && mainRender.isReady()) { @@ -256,7 +259,7 @@ private void draw(boolean forced) { return; } } - if (surfaceManagerEncoder.isReady() && mainRender.isReady()) { + if (surfaceManagerEncoder.isReady() && mainRender.isReady() && !limitFps) { int w = muteVideo ? 0 : encoderWidth; int h = muteVideo ? 0 : encoderHeight; surfaceManagerEncoder.makeCurrent();