mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-03-17 13:22:40 +01:00
initialize capture library in service thread, fix sigsegv fault
This commit is contained in:
parent
7de63b2b5f
commit
d8877a259c
@ -87,7 +87,7 @@ dependencies {
|
||||
implementation('com.fasterxml.jackson.core:jackson-databind:2.17.2')
|
||||
implementation('com.sparrowwallet:hummingbird:1.7.4')
|
||||
implementation('co.nstant.in:cbor:0.9')
|
||||
implementation('org.openpnp:openpnp-capture-java:0.0.28-3')
|
||||
implementation('org.openpnp:openpnp-capture-java:0.0.28-4')
|
||||
implementation("io.matthewnelson.kotlin-components:kmp-tor:${vTor}-${vKmpTor}") {
|
||||
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-common'
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class WebcamService extends ScheduledService<Image> {
|
||||
|
||||
private static final int QR_SAMPLE_PERIOD_MILLIS = 200;
|
||||
|
||||
private final OpenPnpCapture capture;
|
||||
private OpenPnpCapture capture;
|
||||
private CaptureStream stream;
|
||||
private PropertyLimits zoomLimits;
|
||||
private long lastQrSampleTime;
|
||||
@ -82,7 +82,6 @@ public class WebcamService extends ScheduledService<Image> {
|
||||
}
|
||||
|
||||
public WebcamService(WebcamResolution requestedResolution, CaptureDevice requestedDevice) {
|
||||
this.capture = new OpenPnpCapture();
|
||||
this.resolution = requestedResolution;
|
||||
this.device = requestedDevice;
|
||||
this.lastQrSampleTime = System.currentTimeMillis();
|
||||
@ -96,6 +95,8 @@ public class WebcamService extends ScheduledService<Image> {
|
||||
@Override
|
||||
protected Image call() throws Exception {
|
||||
try {
|
||||
createCapture();
|
||||
|
||||
if(stream == null) {
|
||||
devices = capture.getDevices();
|
||||
|
||||
@ -178,6 +179,12 @@ public class WebcamService extends ScheduledService<Image> {
|
||||
};
|
||||
}
|
||||
|
||||
private synchronized void createCapture() {
|
||||
if(capture == null) {
|
||||
capture = new OpenPnpCapture();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
stream = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user