Merge "Camera: Release extension resources after closing handler thread" into sc-dev
This commit is contained in:
@@ -446,16 +446,12 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void release(boolean skipCloseNotification) {
|
||||||
protected void finalize() throws Throwable {
|
boolean notifyClose = false;
|
||||||
if (mHandlerThread != null) {
|
|
||||||
mHandlerThread.quitSafely();
|
|
||||||
}
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void release() {
|
|
||||||
synchronized (mInterfaceLock) {
|
synchronized (mInterfaceLock) {
|
||||||
|
mHandlerThread.quitSafely();
|
||||||
|
|
||||||
if (mSessionProcessor != null) {
|
if (mSessionProcessor != null) {
|
||||||
try {
|
try {
|
||||||
mSessionProcessor.deInitSession();
|
mSessionProcessor.deInitSession();
|
||||||
@@ -469,6 +465,7 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
|
|||||||
if (mExtensionClientId >= 0) {
|
if (mExtensionClientId >= 0) {
|
||||||
CameraExtensionCharacteristics.unregisterClient(mExtensionClientId);
|
CameraExtensionCharacteristics.unregisterClient(mExtensionClientId);
|
||||||
if (mInitialized) {
|
if (mInitialized) {
|
||||||
|
notifyClose = true;
|
||||||
CameraExtensionCharacteristics.releaseSession();
|
CameraExtensionCharacteristics.releaseSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -482,6 +479,16 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
|
|||||||
mClientRepeatingRequestSurface = null;
|
mClientRepeatingRequestSurface = null;
|
||||||
mClientCaptureSurface = null;
|
mClientCaptureSurface = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (notifyClose && !skipCloseNotification) {
|
||||||
|
final long ident = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
mExecutor.execute(() -> mCallbacks.onClosed(
|
||||||
|
CameraAdvancedExtensionSessionImpl.this));
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyConfigurationFailure() {
|
private void notifyConfigurationFailure() {
|
||||||
@@ -491,7 +498,7 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
release();
|
release(true /*skipCloseNotification*/);
|
||||||
|
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
@@ -507,15 +514,7 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
|
|||||||
android.hardware.camera2.CameraCaptureSession.StateCallback {
|
android.hardware.camera2.CameraCaptureSession.StateCallback {
|
||||||
@Override
|
@Override
|
||||||
public void onClosed(@NonNull CameraCaptureSession session) {
|
public void onClosed(@NonNull CameraCaptureSession session) {
|
||||||
release();
|
release(false /*skipCloseNotification*/);
|
||||||
|
|
||||||
final long ident = Binder.clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
mExecutor.execute(() -> mCallbacks.onClosed(
|
|
||||||
CameraAdvancedExtensionSessionImpl.this));
|
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(ident);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -697,12 +697,12 @@ public class CameraDeviceImpl extends CameraDevice
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentExtensionSession != null) {
|
if (mCurrentExtensionSession != null) {
|
||||||
mCurrentExtensionSession.release();
|
mCurrentExtensionSession.release(false /*skipCloseNotification*/);
|
||||||
mCurrentExtensionSession = null;
|
mCurrentExtensionSession = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentAdvancedExtensionSession != null) {
|
if (mCurrentAdvancedExtensionSession != null) {
|
||||||
mCurrentAdvancedExtensionSession.release();
|
mCurrentAdvancedExtensionSession.release(false /*skipCloseNotification*/);
|
||||||
mCurrentAdvancedExtensionSession = null;
|
mCurrentAdvancedExtensionSession = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1352,12 +1352,12 @@ public class CameraDeviceImpl extends CameraDevice
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentExtensionSession != null) {
|
if (mCurrentExtensionSession != null) {
|
||||||
mCurrentExtensionSession.release();
|
mCurrentExtensionSession.release(true /*skipCloseNotification*/);
|
||||||
mCurrentExtensionSession = null;
|
mCurrentExtensionSession = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentAdvancedExtensionSession != null) {
|
if (mCurrentAdvancedExtensionSession != null) {
|
||||||
mCurrentAdvancedExtensionSession.release();
|
mCurrentAdvancedExtensionSession.release(true /*skipCloseNotification*/);
|
||||||
mCurrentAdvancedExtensionSession = null;
|
mCurrentAdvancedExtensionSession = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -630,18 +630,13 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
new CameraExtensionUtils.HandlerExecutor(mHandler), requestHandler);
|
new CameraExtensionUtils.HandlerExecutor(mHandler), requestHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
if (mHandlerThread != null) {
|
|
||||||
mHandlerThread.quitSafely();
|
|
||||||
}
|
|
||||||
super.finalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void release() {
|
public void release(boolean skipCloseNotification) {
|
||||||
|
boolean notifyClose = false;
|
||||||
|
|
||||||
synchronized (mInterfaceLock) {
|
synchronized (mInterfaceLock) {
|
||||||
mInternalRepeatingRequestEnabled = false;
|
mInternalRepeatingRequestEnabled = false;
|
||||||
|
mHandlerThread.quitSafely();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mPreviewExtender.onDeInit();
|
mPreviewExtender.onDeInit();
|
||||||
@@ -654,6 +649,7 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
if (mExtensionClientId >= 0) {
|
if (mExtensionClientId >= 0) {
|
||||||
CameraExtensionCharacteristics.unregisterClient(mExtensionClientId);
|
CameraExtensionCharacteristics.unregisterClient(mExtensionClientId);
|
||||||
if (mInitialized) {
|
if (mInitialized) {
|
||||||
|
notifyClose = true;
|
||||||
CameraExtensionCharacteristics.releaseSession();
|
CameraExtensionCharacteristics.releaseSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -704,6 +700,15 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
mCameraRepeatingSurface = mClientRepeatingRequestSurface = null;
|
mCameraRepeatingSurface = mClientRepeatingRequestSurface = null;
|
||||||
mCameraBurstSurface = mClientCaptureSurface = null;
|
mCameraBurstSurface = mClientCaptureSurface = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (notifyClose && !skipCloseNotification) {
|
||||||
|
final long ident = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
mExecutor.execute(() -> mCallbacks.onClosed(CameraExtensionSessionImpl.this));
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyConfigurationFailure() {
|
private void notifyConfigurationFailure() {
|
||||||
@@ -713,7 +718,7 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
release();
|
release(true /*skipCloseNotification*/);
|
||||||
|
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
@@ -745,14 +750,7 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
android.hardware.camera2.CameraCaptureSession.StateCallback {
|
android.hardware.camera2.CameraCaptureSession.StateCallback {
|
||||||
@Override
|
@Override
|
||||||
public void onClosed(@NonNull CameraCaptureSession session) {
|
public void onClosed(@NonNull CameraCaptureSession session) {
|
||||||
release();
|
release(false /*skipCloseNotification*/);
|
||||||
|
|
||||||
final long ident = Binder.clearCallingIdentity();
|
|
||||||
try {
|
|
||||||
mExecutor.execute(() -> mCallbacks.onClosed(CameraExtensionSessionImpl.this));
|
|
||||||
} finally {
|
|
||||||
Binder.restoreCallingIdentity(ident);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user