mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
avoid hang on closing webcam due to rescans for new camera devices
This commit is contained in:
parent
f691f1691e
commit
2f153686dd
1 changed files with 12 additions and 6 deletions
|
@ -8,8 +8,11 @@ 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() {
|
||||||
|
if(foundScanDevices == null || foundScanDevices.isEmpty()) {
|
||||||
List<WebcamDevice> devices = super.getDevices();
|
List<WebcamDevice> devices = super.getDevices();
|
||||||
List<WebcamDevice> scanDevices = new ArrayList<>();
|
List<WebcamDevice> scanDevices = new ArrayList<>();
|
||||||
for(WebcamDevice device : devices) {
|
for(WebcamDevice device : devices) {
|
||||||
|
@ -17,6 +20,9 @@ public class WebcamScanDriver extends WebcamDefaultDriver {
|
||||||
scanDevices.add(new WebcamScanDevice(defaultDevice.getDeviceRef()));
|
scanDevices.add(new WebcamScanDevice(defaultDevice.getDeviceRef()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return scanDevices;
|
foundScanDevices = scanDevices;
|
||||||
|
}
|
||||||
|
|
||||||
|
return foundScanDevices;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue