Browse Source

avoid hang on closing webcam due to rescans for new camera devices

terminal
Craig Raw 4 years ago
parent
commit
2f153686dd
  1. 18
      src/main/java/com/sparrowwallet/sparrow/control/WebcamScanDriver.java

18
src/main/java/com/sparrowwallet/sparrow/control/WebcamScanDriver.java

@ -8,15 +8,21 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class WebcamScanDriver extends WebcamDefaultDriver { public class WebcamScanDriver extends WebcamDefaultDriver {
private List<WebcamDevice> foundScanDevices;
@Override @Override
public List<WebcamDevice> getDevices() { public List<WebcamDevice> getDevices() {
List<WebcamDevice> devices = super.getDevices(); if(foundScanDevices == null || foundScanDevices.isEmpty()) {
List<WebcamDevice> scanDevices = new ArrayList<>(); List<WebcamDevice> devices = super.getDevices();
for(WebcamDevice device : devices) { List<WebcamDevice> scanDevices = new ArrayList<>();
WebcamDefaultDevice defaultDevice = (WebcamDefaultDevice)device; for(WebcamDevice device : devices) {
scanDevices.add(new WebcamScanDevice(defaultDevice.getDeviceRef())); WebcamDefaultDevice defaultDevice = (WebcamDefaultDevice)device;
scanDevices.add(new WebcamScanDevice(defaultDevice.getDeviceRef()));
}
foundScanDevices = scanDevices;
} }
return scanDevices; return foundScanDevices;
} }
} }

Loading…
Cancel
Save