Skip to content

Commit

Permalink
fix forceFpsLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Oct 9, 2024
1 parent da4736f commit 83f06d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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()
Expand All @@ -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()
Expand Down
13 changes: 8 additions & 5 deletions library/src/main/java/com/pedro/library/view/OpenGlView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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();
Expand Down

0 comments on commit 83f06d8

Please sign in to comment.