fix: Fix Session has been closed; further changes are illegal
error by using tryStopRepeating()
(#2568)
* feat: Allow focus calls to be cancelable * Cancelable * fix: Use `tryStopRepeating`
This commit is contained in:
parent
4168d8f752
commit
129e21f14e
@ -19,6 +19,7 @@ import com.mrousavy.camera.extensions.isValid
|
|||||||
import com.mrousavy.camera.extensions.openCamera
|
import com.mrousavy.camera.extensions.openCamera
|
||||||
import com.mrousavy.camera.extensions.precapture
|
import com.mrousavy.camera.extensions.precapture
|
||||||
import com.mrousavy.camera.extensions.tryAbortCaptures
|
import com.mrousavy.camera.extensions.tryAbortCaptures
|
||||||
|
import com.mrousavy.camera.extensions.tryStopRepeating
|
||||||
import com.mrousavy.camera.types.Flash
|
import com.mrousavy.camera.types.Flash
|
||||||
import com.mrousavy.camera.types.Orientation
|
import com.mrousavy.camera.types.Orientation
|
||||||
import com.mrousavy.camera.types.QualityPrioritization
|
import com.mrousavy.camera.types.QualityPrioritization
|
||||||
@ -280,8 +281,8 @@ class PersistentCameraCaptureSession(private val cameraManager: CameraManager, p
|
|||||||
val builder = repeatingRequest.createCaptureRequest(device, details, repeatingOutputs)
|
val builder = repeatingRequest.createCaptureRequest(device, details, repeatingOutputs)
|
||||||
session.setRepeatingRequest(builder.build(), null, null)
|
session.setRepeatingRequest(builder.build(), null, null)
|
||||||
} else {
|
} else {
|
||||||
session.stopRepeating()
|
|
||||||
Log.d(TAG, "Stopping repeating request...")
|
Log.d(TAG, "Stopping repeating request...")
|
||||||
|
session.tryStopRepeating()
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Configure() done! isActive: $isActive, ID: $cameraId, device: $device, session: $session")
|
Log.d(TAG, "Configure() done! isActive: $isActive, ID: $cameraId, device: $device, session: $session")
|
||||||
} catch (e: CameraAccessException) {
|
} catch (e: CameraAccessException) {
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.mrousavy.camera.extensions
|
||||||
|
|
||||||
|
import android.hardware.camera2.CameraCaptureSession
|
||||||
|
|
||||||
|
fun CameraCaptureSession.tryStopRepeating() {
|
||||||
|
try {
|
||||||
|
stopRepeating()
|
||||||
|
} catch (_: Throwable) {}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user