Skip to content

Commit 67038b1

Browse files
CameraDevice と CameraCaptureSession の close よりに try-catch を追加
1 parent 486b51e commit 67038b1

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

  • dConnectDevicePlugin/dConnectDeviceHost/app/src/main/java/org/deviceconnect/android/deviceplugin/host/camera

dConnectDevicePlugin/dConnectDeviceHost/app/src/main/java/org/deviceconnect/android/deviceplugin/host/camera/CameraWrapper.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,19 @@ public synchronized void destroy() {
198198

199199
private void close() {
200200
if (mCaptureSession != null) {
201-
mCaptureSession.close();
201+
try {
202+
mCaptureSession.close();
203+
} catch (Exception e) {
204+
// ignore
205+
}
202206
mCaptureSession = null;
203207
}
204208
if (mCameraDevice != null) {
205-
mCameraDevice.close();
209+
try {
210+
mCameraDevice.close();
211+
} catch (Exception e) {
212+
// ignore.
213+
}
206214
mCameraDevice = null;
207215
}
208216
}
@@ -369,7 +377,11 @@ private synchronized CameraCaptureSession createCaptureSession(final CameraDevic
369377
private synchronized CameraCaptureSession createCaptureSession(final List<Surface> targets, final CameraDevice cameraDevice) throws CameraWrapperException {
370378
try {
371379
if (mCaptureSession != null) {
372-
mCaptureSession.close();
380+
try {
381+
mCaptureSession.close();
382+
} catch (Exception e) {
383+
// ignore.
384+
}
373385
mCaptureSession = null;
374386
}
375387
final CountDownLatch lock = new CountDownLatch(1);
@@ -464,7 +476,11 @@ public synchronized void stopPreview() throws CameraWrapperException {
464476
mIsPreview = false;
465477
mPreviewSurface = null;
466478
if (mCaptureSession != null) {
467-
mCaptureSession.close();
479+
try {
480+
mCaptureSession.close();
481+
} catch (Exception e) {
482+
// ignore.
483+
}
468484
mCaptureSession = null;
469485
}
470486
if (mIsRecording) {
@@ -524,7 +540,11 @@ public synchronized void stopRecording() throws CameraWrapperException {
524540
mIsRecording = false;
525541
mRecordingSurface = null;
526542
if (mCaptureSession != null) {
527-
mCaptureSession.close();
543+
try {
544+
mCaptureSession.close();
545+
} catch (Exception e) {
546+
// ignore.
547+
}
528548
mCaptureSession = null;
529549
}
530550

0 commit comments

Comments
 (0)