예제 #1
0
 public void CloseCamera()
 {
     try
     {
         CameraOpenCloseLock.Acquire();
         if (null != CaptureSession)
         {
             CaptureSession.Close();
             CaptureSession = null;
         }
         if (null != Device)
         {
             Device.Close();
             Device = null;
         }
         if (null != mImageReader)
         {
             mImageReader.Close();
             mImageReader = null;
         }
     }
     catch (InterruptedException e)
     {
         throw new RuntimeException("Interrupted while trying to lock camera closing.", e);
     }
     finally
     {
         CameraOpenCloseLock.Release();
     }
 }
예제 #2
0
 // Closes the current {@link CurrentCameraDevice}.
 private void CloseCamera()
 {
     try
     {
         CameraOpenCloseLock.Acquire();
         if (null != CaptureSession)
         {
             CaptureSession.Close();
             CaptureSession = null;
         }
         if (null != CurrentCameraDevice)
         {
             CurrentCameraDevice.Close();
             CurrentCameraDevice = null;
         }
     }
     catch (InterruptedException e)
     {
         throw new RuntimeException("Interrupted while trying to lock camera closing.", e);
     }
     finally
     {
         CameraOpenCloseLock.Release();
     }
 }
        // Closes the current {@link CameraDevice}.
        protected void CloseCamera()
        {
            if (CaptureSession == null)
            {
                return;
            }

            try
            {
                CameraOpenCloseLock.Acquire();
                if (null != CaptureSession)
                {
                    try
                    {
                        CaptureSession.StopRepeating();
                        CaptureSession.AbortCaptures();
                    }
                    catch (CameraAccessException ex)
                    {
#if DEBUG
                        ex.PrintStackTrace();
#endif
                    }
                    catch (IllegalStateException ex)
                    {
#if DEBUG
                        ex.PrintStackTrace();
#endif
                    }

                    CaptureSession.Close();
                    CaptureSession = null;
                }

                if (null != CameraDevice)
                {
                    CameraDevice.Close();
                    CameraDevice = null;
                }

                if (null != _imageReader)
                {
                    _imageReader.Close();
                    _imageReader = null;
                }
            }
            catch (InterruptedException ex)
            {
                throw new RuntimeException("Interrupted while trying to lock camera closing.", ex);
            }
            finally
            {
                CameraOpenCloseLock.Release();
            }
        }