Loading core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java +113 −113 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession } @Override public synchronized int capture(CaptureRequest request, CaptureCallback callback, public int capture(CaptureRequest request, CaptureCallback callback, Handler handler) throws CameraAccessException { if (request == null) { throw new IllegalArgumentException("request must not be null"); Loading @@ -169,6 +169,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession throw new IllegalArgumentException("capture request was created for another session"); } synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); handler = checkHandler(handler, callback); Loading @@ -181,9 +182,10 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession return addPendingSequence(mDeviceImpl.capture(request, createCaptureCallbackProxy(handler, callback), mDeviceHandler)); } } @Override public synchronized int captureBurst(List<CaptureRequest> requests, CaptureCallback callback, public int captureBurst(List<CaptureRequest> requests, CaptureCallback callback, Handler handler) throws CameraAccessException { if (requests == null) { throw new IllegalArgumentException("Requests must not be null"); Loading @@ -203,6 +205,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession } } synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); handler = checkHandler(handler, callback); Loading @@ -216,9 +219,10 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession return addPendingSequence(mDeviceImpl.captureBurst(requests, createCaptureCallbackProxy(handler, callback), mDeviceHandler)); } } @Override public synchronized int setRepeatingRequest(CaptureRequest request, CaptureCallback callback, public int setRepeatingRequest(CaptureRequest request, CaptureCallback callback, Handler handler) throws CameraAccessException { if (request == null) { throw new IllegalArgumentException("request must not be null"); Loading @@ -226,6 +230,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession throw new IllegalArgumentException("repeating reprocess requests are not supported"); } synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); handler = checkHandler(handler, callback); Loading @@ -238,9 +243,10 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession return addPendingSequence(mDeviceImpl.setRepeatingRequest(request, createCaptureCallbackProxy(handler, callback), mDeviceHandler)); } } @Override public synchronized int setRepeatingBurst(List<CaptureRequest> requests, public int setRepeatingBurst(List<CaptureRequest> requests, CaptureCallback callback, Handler handler) throws CameraAccessException { if (requests == null) { throw new IllegalArgumentException("requests must not be null"); Loading @@ -255,22 +261,26 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession } } synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); handler = checkHandler(handler, callback); if (DEBUG) { CaptureRequest[] requestArray = requests.toArray(new CaptureRequest[0]); Log.v(TAG, mIdString + "setRepeatingBurst - requests " + Arrays.toString(requestArray) + ", callback " + callback + " handler" + "" + handler); Log.v(TAG, mIdString + "setRepeatingBurst - requests " + Arrays.toString(requestArray) + ", callback " + callback + " handler" + "" + handler); } return addPendingSequence(mDeviceImpl.setRepeatingBurst(requests, createCaptureCallbackProxy(handler, callback), mDeviceHandler)); } } @Override public synchronized void stopRepeating() throws CameraAccessException { public void stopRepeating() throws CameraAccessException { synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); if (DEBUG) { Loading @@ -279,10 +289,11 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession mDeviceImpl.stopRepeating(); } } @Override public void abortCaptures() throws CameraAccessException { synchronized (this) { synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); if (DEBUG) { Loading @@ -296,15 +307,11 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession mAborting = true; mAbortDrainer.taskStarted(); } synchronized (mDeviceImpl.mInterfaceLock) { synchronized (this) { mDeviceImpl.flush(); // The next BUSY -> IDLE set of transitions will mark the end of the abort. } } } @Override public boolean isReprocessable() { Loading Loading @@ -332,7 +339,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession */ @Override public void replaceSessionClose() { synchronized (this) { synchronized (mDeviceImpl.mInterfaceLock) { /* * In order for creating new sessions to be fast, the new session should be created * before the old session is closed. Loading @@ -357,13 +364,13 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession // configuration for the new session. If it was already called, then we don't care, // since it won't get called again. mSkipUnconfigure = true; } close(); } } @Override public void close() { synchronized (this) { synchronized (mDeviceImpl.mInterfaceLock) { if (mClosed) { if (DEBUG) Log.v(TAG, mIdString + "close - reentering"); return; Loading @@ -372,10 +379,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession if (DEBUG) Log.v(TAG, mIdString + "close - first time"); mClosed = true; } synchronized (mDeviceImpl.mInterfaceLock) { synchronized (this) { /* * Flush out any repeating request. Since camera is closed, no new requests * can be queued, and eventually the entire request queue will be drained. Loading Loading @@ -404,10 +408,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession // TODO: call onError instead of onClosed if this happens } } } synchronized (this) { // If no sequences are pending, fire #onClosed immediately mSequenceDrainer.beginDrain(); } Loading Loading @@ -552,6 +553,8 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession @Override public CameraDeviceImpl.StateCallbackKK getDeviceStateCallback() { final CameraCaptureSession session = this; final Object interfaceLock = mDeviceImpl.mInterfaceLock; return new CameraDeviceImpl.StateCallbackKK() { private boolean mBusy = false; Loading Loading @@ -588,7 +591,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession boolean isAborting; if (DEBUG) Log.v(TAG, mIdString + "onIdle"); synchronized (session) { synchronized (interfaceLock) { isAborting = mAborting; } Loading @@ -606,7 +609,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession if (mBusy && isAborting) { mAbortDrainer.taskFinished(); synchronized (session) { synchronized (interfaceLock) { mAborting = false; } } Loading Loading @@ -729,7 +732,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession @Override public void onDrained() { if (DEBUG) Log.v(TAG, mIdString + "onAbortDrained"); synchronized (CameraCaptureSessionImpl.this) { synchronized (mDeviceImpl.mInterfaceLock) { /* * Any queued aborts have now completed. * Loading Loading @@ -757,7 +760,6 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession // Take device lock before session lock so that we can call back into device // without causing a deadlock synchronized (mDeviceImpl.mInterfaceLock) { synchronized (CameraCaptureSessionImpl.this) { /* * The device is now IDLE, and has settled. It will not transition to * ACTIVE or BUSY again by itself. Loading Loading @@ -792,8 +794,6 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession if (DEBUG) Log.v(TAG, mIdString + "Camera was already closed or busy, skipping unconfigure"); } } } } } Loading Loading
core/java/android/hardware/camera2/impl/CameraCaptureSessionImpl.java +113 −113 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession } @Override public synchronized int capture(CaptureRequest request, CaptureCallback callback, public int capture(CaptureRequest request, CaptureCallback callback, Handler handler) throws CameraAccessException { if (request == null) { throw new IllegalArgumentException("request must not be null"); Loading @@ -169,6 +169,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession throw new IllegalArgumentException("capture request was created for another session"); } synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); handler = checkHandler(handler, callback); Loading @@ -181,9 +182,10 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession return addPendingSequence(mDeviceImpl.capture(request, createCaptureCallbackProxy(handler, callback), mDeviceHandler)); } } @Override public synchronized int captureBurst(List<CaptureRequest> requests, CaptureCallback callback, public int captureBurst(List<CaptureRequest> requests, CaptureCallback callback, Handler handler) throws CameraAccessException { if (requests == null) { throw new IllegalArgumentException("Requests must not be null"); Loading @@ -203,6 +205,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession } } synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); handler = checkHandler(handler, callback); Loading @@ -216,9 +219,10 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession return addPendingSequence(mDeviceImpl.captureBurst(requests, createCaptureCallbackProxy(handler, callback), mDeviceHandler)); } } @Override public synchronized int setRepeatingRequest(CaptureRequest request, CaptureCallback callback, public int setRepeatingRequest(CaptureRequest request, CaptureCallback callback, Handler handler) throws CameraAccessException { if (request == null) { throw new IllegalArgumentException("request must not be null"); Loading @@ -226,6 +230,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession throw new IllegalArgumentException("repeating reprocess requests are not supported"); } synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); handler = checkHandler(handler, callback); Loading @@ -238,9 +243,10 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession return addPendingSequence(mDeviceImpl.setRepeatingRequest(request, createCaptureCallbackProxy(handler, callback), mDeviceHandler)); } } @Override public synchronized int setRepeatingBurst(List<CaptureRequest> requests, public int setRepeatingBurst(List<CaptureRequest> requests, CaptureCallback callback, Handler handler) throws CameraAccessException { if (requests == null) { throw new IllegalArgumentException("requests must not be null"); Loading @@ -255,22 +261,26 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession } } synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); handler = checkHandler(handler, callback); if (DEBUG) { CaptureRequest[] requestArray = requests.toArray(new CaptureRequest[0]); Log.v(TAG, mIdString + "setRepeatingBurst - requests " + Arrays.toString(requestArray) + ", callback " + callback + " handler" + "" + handler); Log.v(TAG, mIdString + "setRepeatingBurst - requests " + Arrays.toString(requestArray) + ", callback " + callback + " handler" + "" + handler); } return addPendingSequence(mDeviceImpl.setRepeatingBurst(requests, createCaptureCallbackProxy(handler, callback), mDeviceHandler)); } } @Override public synchronized void stopRepeating() throws CameraAccessException { public void stopRepeating() throws CameraAccessException { synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); if (DEBUG) { Loading @@ -279,10 +289,11 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession mDeviceImpl.stopRepeating(); } } @Override public void abortCaptures() throws CameraAccessException { synchronized (this) { synchronized (mDeviceImpl.mInterfaceLock) { checkNotClosed(); if (DEBUG) { Loading @@ -296,15 +307,11 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession mAborting = true; mAbortDrainer.taskStarted(); } synchronized (mDeviceImpl.mInterfaceLock) { synchronized (this) { mDeviceImpl.flush(); // The next BUSY -> IDLE set of transitions will mark the end of the abort. } } } @Override public boolean isReprocessable() { Loading Loading @@ -332,7 +339,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession */ @Override public void replaceSessionClose() { synchronized (this) { synchronized (mDeviceImpl.mInterfaceLock) { /* * In order for creating new sessions to be fast, the new session should be created * before the old session is closed. Loading @@ -357,13 +364,13 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession // configuration for the new session. If it was already called, then we don't care, // since it won't get called again. mSkipUnconfigure = true; } close(); } } @Override public void close() { synchronized (this) { synchronized (mDeviceImpl.mInterfaceLock) { if (mClosed) { if (DEBUG) Log.v(TAG, mIdString + "close - reentering"); return; Loading @@ -372,10 +379,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession if (DEBUG) Log.v(TAG, mIdString + "close - first time"); mClosed = true; } synchronized (mDeviceImpl.mInterfaceLock) { synchronized (this) { /* * Flush out any repeating request. Since camera is closed, no new requests * can be queued, and eventually the entire request queue will be drained. Loading Loading @@ -404,10 +408,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession // TODO: call onError instead of onClosed if this happens } } } synchronized (this) { // If no sequences are pending, fire #onClosed immediately mSequenceDrainer.beginDrain(); } Loading Loading @@ -552,6 +553,8 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession @Override public CameraDeviceImpl.StateCallbackKK getDeviceStateCallback() { final CameraCaptureSession session = this; final Object interfaceLock = mDeviceImpl.mInterfaceLock; return new CameraDeviceImpl.StateCallbackKK() { private boolean mBusy = false; Loading Loading @@ -588,7 +591,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession boolean isAborting; if (DEBUG) Log.v(TAG, mIdString + "onIdle"); synchronized (session) { synchronized (interfaceLock) { isAborting = mAborting; } Loading @@ -606,7 +609,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession if (mBusy && isAborting) { mAbortDrainer.taskFinished(); synchronized (session) { synchronized (interfaceLock) { mAborting = false; } } Loading Loading @@ -729,7 +732,7 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession @Override public void onDrained() { if (DEBUG) Log.v(TAG, mIdString + "onAbortDrained"); synchronized (CameraCaptureSessionImpl.this) { synchronized (mDeviceImpl.mInterfaceLock) { /* * Any queued aborts have now completed. * Loading Loading @@ -757,7 +760,6 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession // Take device lock before session lock so that we can call back into device // without causing a deadlock synchronized (mDeviceImpl.mInterfaceLock) { synchronized (CameraCaptureSessionImpl.this) { /* * The device is now IDLE, and has settled. It will not transition to * ACTIVE or BUSY again by itself. Loading Loading @@ -792,8 +794,6 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession if (DEBUG) Log.v(TAG, mIdString + "Camera was already closed or busy, skipping unconfigure"); } } } } } Loading