X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fkaka%2Fcakelight%2FVideoMode.java;h=ca0bd53127c4840d6284da99bbf74af428f2e90c;hb=dcef78901ed32c81c91164c2ba45d21d44ac24f6;hp=e4b9400ca04b57d6d570fb8c4b4675702d9612f2;hpb=03b67a7377d6d23d517d33e47f338bb7859596ed;p=kaka%2Fcakelight.git diff --git a/src/kaka/cakelight/VideoMode.java b/src/kaka/cakelight/VideoMode.java index e4b9400..ca0bd53 100644 --- a/src/kaka/cakelight/VideoMode.java +++ b/src/kaka/cakelight/VideoMode.java @@ -5,7 +5,7 @@ import java.io.IOException; import java.util.Optional; import java.util.function.Consumer; -public class VideoMode extends Mode implements Consumer> { +public class VideoMode extends Mode { private Configuration config; private Thread thread; private Consumer frameConsumer; @@ -13,7 +13,7 @@ public class VideoMode extends Mode implements Consumer> { public VideoMode() { deviceListener = new VideoDeviceListener(); - deviceListener.onVideoDeviceChange(this); + deviceListener.onVideoDeviceChange(this::onVideoDeviceChange); } @Override @@ -38,8 +38,6 @@ public class VideoMode extends Mode implements Consumer> { if (frameConsumer != null) frame.ifPresent(frameConsumer); frame.ifPresent(VideoMode.this::onFrame); // timeIt("frame", grabber::grabFrame); - // TODO: process frame - // TODO: save where the LedController can access it } } catch (IOException e) { e.printStackTrace(); @@ -54,12 +52,10 @@ public class VideoMode extends Mode implements Consumer> { } private void onFrame(Frame frame) { - assert frameListener != null; - frameListener.accept(frame.getLedFrame()); + updateWithFrame(frame.getLedFrame()); } - @Override - public void accept(Optional videoDevice) { + public void onVideoDeviceChange(Optional videoDevice) { // Should only happen when this mode is active! if (thread != null) { thread.interrupt();