public class VideoMode extends Mode {
private Configuration config;
- private Thread thread;
+ private Thread grabberThread;
private Consumer<Frame> frameConsumer;
private VideoDeviceListener deviceListener;
@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()) {
}
}
};
- thread.start();
+ grabberThread.start();
}
public void onVideoFrame(Consumer<Frame> consumer) {
public void onVideoDeviceChange(Optional<File> videoDevice) {
// Should only happen when this mode is active!
- if (thread != null) {
- thread.interrupt();
+ if (grabberThread != null) {
+ grabberThread.interrupt();
}
videoDevice.ifPresent(this::startGrabberThread);
}