summaryrefslogtreecommitdiff
Diffstat
-rw-r--r--v3/EmulatedCameraFactory.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/v3/EmulatedCameraFactory.cpp b/v3/EmulatedCameraFactory.cpp
index 0f6a6fa..3e86aee 100644
--- a/v3/EmulatedCameraFactory.cpp
+++ b/v3/EmulatedCameraFactory.cpp
@@ -482,11 +482,18 @@ void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus)
CAMHAL_LOGDB("mEmulatedCameraNum =%d\n", mEmulatedCameraNum);
n = getValidCameraOjectId();
if ((n != cameraId) && (mEmulatedCameras[n] != NULL)) {
+ DBG_LOGA("device node changed");
mEmulatedCameras[n]->unplugCamera();
delete mEmulatedCameras[n];
mEmulatedCameras[n] = NULL;
}
+ if (mEmulatedCameras[cameraId] != NULL && (!mEmulatedCameras[cameraId]->getHotplugStatus())) {
+ DBG_LOGA("close EmulatedFakeCamera3 object for the last time");
+ delete mEmulatedCameras[cameraId];
+ mEmulatedCameras[cameraId] = NULL;
+ }
+
EmulatedBaseCamera *cam = mEmulatedCameras[cameraId];
if ((!cam) && (newStatus == CAMERA_DEVICE_STATUS_PRESENT)) {
@@ -549,8 +556,9 @@ void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus)
CAMHAL_LOGDB("mEmulatedCameraNum =%d\n", mEmulatedCameraNum);
if (newStatus == CAMERA_DEVICE_STATUS_NOT_PRESENT) {
+ mEmulatedCameraNum --;
j = getValidCameraOjectId();
- while (m < 2000) {
+ while (m < 200) {
if (mEmulatedCameras[j] != NULL) {
if (mEmulatedCameras[j]->getCameraStatus()) {
DBG_LOGA("start to delete EmulatedFakeCamera3 object");
@@ -565,7 +573,9 @@ void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus)
break;
}
}
- mEmulatedCameraNum --;
+ if (m == 200) {
+ cam->unplugCamera();
+ }
} else if (newStatus == CAMERA_DEVICE_STATUS_PRESENT) {
CAMHAL_LOGDA("camera plugged again?\n");
cam->plugCamera();