File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
library/src/main/api21/com/google/android/cameraview Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ public void onError(@NonNull CameraDevice camera, int error) {
9898
9999 @ Override
100100 public void onConfigured (@ NonNull CameraCaptureSession session ) {
101- if (mCamera == null ) {
101+ if (! isCameraOpened () ) {
102102 return ;
103103 }
104104 mCaptureSession = session ;
@@ -226,11 +226,9 @@ boolean start() {
226226
227227 @ Override
228228 void stop () {
229- if (mCaptureSession != null ) {
230- mCaptureSession .close ();
231- mCaptureSession = null ;
232- }
233- if (mCamera != null ) {
229+ closeCaptureSession ();
230+
231+ if (isCameraOpened ()) {
234232 mCamera .close ();
235233 mCamera = null ;
236234 }
@@ -285,12 +283,15 @@ boolean setAspectRatio(AspectRatio ratio) {
285283
286284 mAspectRatio = ratio ;
287285 prepareImageReader ();
286+ closeCaptureSession ();
287+ return true ;
288+ }
289+
290+ private void closeCaptureSession () {
288291 if (mCaptureSession != null ) {
289292 mCaptureSession .close ();
290293 mCaptureSession = null ;
291- startCaptureSession ();
292294 }
293- return true ;
294295 }
295296
296297 @ Override
You can’t perform that action at this time.
0 commit comments