From 8bf9263e4333b058b2e0a7a9522b73206de293cc Mon Sep 17 00:00:00 2001 From: JohanBlome Date: Thu, 23 May 2024 10:22:20 -0700 Subject: [PATCH] encapp: do not waste peoples times Only wait if needed. Signed-off-by: JohanBlome --- .../java/com/facebook/encapp/SurfaceTranscoder.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/facebook/encapp/SurfaceTranscoder.java b/app/src/main/java/com/facebook/encapp/SurfaceTranscoder.java index 47898649..d4f92061 100644 --- a/app/src/main/java/com/facebook/encapp/SurfaceTranscoder.java +++ b/app/src/main/java/com/facebook/encapp/SurfaceTranscoder.java @@ -582,11 +582,13 @@ public long sleepUntilNextFrameSynched() { public void stopAllActivity(){ synchronized (mStopLock) { - Log.d(TAG, "Give me a sec, waiting for last encodings dec: " + mStats.getDecodedFrameCount() + " > enc: " + mStats.getEncodedFrameCount()); - try { - mStopLock.wait(WAIT_TIME_SHORT_MS); - } catch (InterruptedException e) { - e.printStackTrace(); + if (mStats.getDecodedFrameCount() > mStats.getEncodedFrameCount()) { + Log.d(TAG, "Give me a sec, waiting for last encodings dec: " + mStats.getDecodedFrameCount() + " > enc: " + mStats.getEncodedFrameCount()); + try { + mStopLock.wait(WAIT_TIME_SHORT_MS); + } catch (InterruptedException e) { + e.printStackTrace(); + } } mDone = true; mStats.stop();