X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fkaka%2Fcakelight%2FVideoMode.java;h=134fa2d33ff574f837af3b68dbd7b0e967ddf4ed;hb=48d4699cf1e92ae7f744c866790417984ec36005;hp=6da36f27a6cb946592955ef359b93ffe07fc9bfe;hpb=6b5696708b4d9aaf03c8c04bea6e734c045a3e25;p=kaka%2Fcakelight.git
diff --git a/src/kaka/cakelight/VideoMode.java b/src/kaka/cakelight/VideoMode.java
index 6da36f2..134fa2d 100644
--- a/src/kaka/cakelight/VideoMode.java
+++ b/src/kaka/cakelight/VideoMode.java
@@ -7,8 +7,8 @@ import java.util.function.Consumer;
public class VideoMode extends Mode {
private Configuration config;
- private Thread thread;
- private Consumer frameConsumer;
+ private Thread grabberThread;
+ private Consumer frameConsumer;
private VideoDeviceListener deviceListener;
public VideoMode() {
@@ -24,43 +24,41 @@ public class VideoMode extends Mode {
@Override
public void exit() {
- thread.interrupt();
+ grabberThread.interrupt();
deviceListener.stopListening();
}
private void startGrabberThread(File videoDevice) {
assert frameConsumer != null;
- thread = new Thread() {
+ grabberThread = new Thread() {
public void run() {
try (FrameGrabber grabber = FrameGrabber.from(videoDevice, config)) {
while (!isInterrupted()) {
- Optional frame = grabber.grabFrame();
+ Optional frame = grabber.grabFrame();
if (frameConsumer != null) frame.ifPresent(frameConsumer);
- frame.ifPresent(VideoMode.this::onFrame);
+ frame.ifPresent(VideoMode.this::onVideoFrame);
// timeIt("frame", grabber::grabFrame);
- // TODO: process frame
- // TODO: save where the LedController can access it
}
} catch (IOException e) {
e.printStackTrace();
}
}
};
- thread.start();
+ grabberThread.start();
}
- public void onVideoFrame(Consumer consumer) {
+ public void onVideoFrame(Consumer consumer) {
frameConsumer = consumer;
}
- private void onFrame(Frame frame) {
+ private void onVideoFrame(VideoFrame frame) {
updateWithFrame(frame.getLedFrame());
}
public void onVideoDeviceChange(Optional videoDevice) {
// Should only happen when this mode is active!
- if (thread != null) {
- thread.interrupt();
+ if (grabberThread != null) {
+ grabberThread.interrupt();
}
videoDevice.ifPresent(this::startGrabberThread);
}