Camera: ensure lock ordering (device->session)
am: b0025e1f68
Change-Id: Idcb9b48274ecfe9fe2f306ae201491d1e485d601
This commit is contained in:
@@ -286,7 +286,8 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void abortCaptures() throws CameraAccessException {
|
public void abortCaptures() throws CameraAccessException {
|
||||||
|
synchronized (this) {
|
||||||
checkNotClosed();
|
checkNotClosed();
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -300,10 +301,15 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
|
|||||||
|
|
||||||
mAborting = true;
|
mAborting = true;
|
||||||
mAbortDrainer.taskStarted();
|
mAbortDrainer.taskStarted();
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (mDeviceImpl.mInterfaceLock) {
|
||||||
|
synchronized (this) {
|
||||||
mDeviceImpl.flush();
|
mDeviceImpl.flush();
|
||||||
// The next BUSY -> IDLE set of transitions will mark the end of the abort.
|
// The next BUSY -> IDLE set of transitions will mark the end of the abort.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isReprocessable() {
|
public boolean isReprocessable() {
|
||||||
@@ -330,7 +336,8 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
|
|||||||
* @see CameraCaptureSession#close
|
* @see CameraCaptureSession#close
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void replaceSessionClose() {
|
public void replaceSessionClose() {
|
||||||
|
synchronized (this) {
|
||||||
/*
|
/*
|
||||||
* In order for creating new sessions to be fast, the new session should be created
|
* In order for creating new sessions to be fast, the new session should be created
|
||||||
* before the old session is closed.
|
* before the old session is closed.
|
||||||
@@ -352,16 +359,16 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
|
|||||||
// configureOutputsChecked(null) has already been called.
|
// configureOutputsChecked(null) has already been called.
|
||||||
//
|
//
|
||||||
// Do not call configureOutputsChecked(null) going forward, since it would race with the
|
// Do not call configureOutputsChecked(null) going forward, since it would race with the
|
||||||
// configuration for the new session. If it was already called, then we don't care, since it
|
// configuration for the new session. If it was already called, then we don't care,
|
||||||
// won't get called again.
|
// since it won't get called again.
|
||||||
mSkipUnconfigure = true;
|
mSkipUnconfigure = true;
|
||||||
|
}
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void close() {
|
public void close() {
|
||||||
|
synchronized (this) {
|
||||||
if (mClosed) {
|
if (mClosed) {
|
||||||
if (DEBUG) Log.v(TAG, mIdString + "close - reentering");
|
if (DEBUG) Log.v(TAG, mIdString + "close - reentering");
|
||||||
return;
|
return;
|
||||||
@@ -370,7 +377,10 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
|
|||||||
if (DEBUG) Log.v(TAG, mIdString + "close - first time");
|
if (DEBUG) Log.v(TAG, mIdString + "close - first time");
|
||||||
|
|
||||||
mClosed = true;
|
mClosed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (mDeviceImpl.mInterfaceLock) {
|
||||||
|
synchronized (this) {
|
||||||
/*
|
/*
|
||||||
* Flush out any repeating request. Since camera is closed, no new requests
|
* Flush out any repeating request. Since camera is closed, no new requests
|
||||||
* can be queued, and eventually the entire request queue will be drained.
|
* can be queued, and eventually the entire request queue will be drained.
|
||||||
@@ -378,8 +388,8 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
|
|||||||
* If the camera device was already closed, short circuit and do nothing; since
|
* If the camera device was already closed, short circuit and do nothing; since
|
||||||
* no more internal device callbacks will fire anyway.
|
* no more internal device callbacks will fire anyway.
|
||||||
*
|
*
|
||||||
* Otherwise, once stopRepeating is done, wait for camera to idle, then unconfigure the
|
* Otherwise, once stopRepeating is done, wait for camera to idle, then unconfigure
|
||||||
* camera. Once that's done, fire #onClosed.
|
* the camera. Once that's done, fire #onClosed.
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
mDeviceImpl.stopRepeating();
|
mDeviceImpl.stopRepeating();
|
||||||
@@ -399,10 +409,14 @@ public class CameraCaptureSessionImpl extends CameraCaptureSession
|
|||||||
|
|
||||||
// TODO: call onError instead of onClosed if this happens
|
// TODO: call onError instead of onClosed if this happens
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (this) {
|
||||||
// If no sequences are pending, fire #onClosed immediately
|
// If no sequences are pending, fire #onClosed immediately
|
||||||
mSequenceDrainer.beginDrain();
|
mSequenceDrainer.beginDrain();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether currently in mid-abort.
|
* Whether currently in mid-abort.
|
||||||
|
|||||||
Reference in New Issue
Block a user