Skip to content

Commit

Permalink
Schedule update execution only when webcam is open, fixes #228
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed Jun 21, 2014
1 parent 2071822 commit 4371adb
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.awt.image.BufferedImage;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -234,7 +235,13 @@ private void tick() {

// reschedule task

executor.schedule(this, delay, TimeUnit.MILLISECONDS);
if (webcam.isOpen()) {
try {
executor.schedule(this, delay, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
LOG.trace("Webcam update has been rejected", e);
}
}

// notify webcam listeners about the new image available

Expand Down

0 comments on commit 4371adb

Please sign in to comment.