From efaad5044fa06e26b7fd463ea736286e765fa8fa Mon Sep 17 00:00:00 2001 From: Guosong Zhou Date: Thu, 07 Jul 2016 03:31:41 +0000 Subject: PD#125746: camera: fix camera plug Change-Id: I66728e3b5e056ef3b535a8ee606f359130a311ed --- diff --git a/v3/EmulatedCameraFactory.cpp b/v3/EmulatedCameraFactory.cpp index ca77151..42569fd 100644 --- a/v3/EmulatedCameraFactory.cpp +++ b/v3/EmulatedCameraFactory.cpp @@ -303,6 +303,7 @@ int EmulatedCameraFactory::get_number_of_cameras(void) break; } } else { + DBG_LOGB("%s : cam is NULL", __FUNCTION__); break; } } @@ -483,6 +484,7 @@ void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus) char dev_name[128]; int i = 0 , j = 0; int m = 0, n = 0; + int k = 0; //EmulatedBaseCamera *cam = mEmulatedCameras[cameraId]; const camera_module_callbacks_t* cb = mCallbacks; sprintf(dev_name, "%s%d", "/dev/video", cameraId); @@ -504,6 +506,18 @@ void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus) if (mEmulatedCameras[cameraId] != NULL && (!mEmulatedCameras[cameraId]->getHotplugStatus())) { DBG_LOGA("close EmulatedFakeCamera3 object for the last time"); + while (k < 150) { + if (!(mEmulatedCameras[cameraId]->getCameraStatus())) { + usleep(10000); + k++; + } else { + break; + } + } + if (k == 150) { + DBG_LOGA("wait 1s, but camera still not closed , it's abnormal status.\n"); + return; + } delete mEmulatedCameras[cameraId]; mEmulatedCameras[cameraId] = NULL; } diff --git a/v3/EmulatedFakeCamera3.cpp b/v3/EmulatedFakeCamera3.cpp index 79aafa1..09a8cda 100644 --- a/v3/EmulatedFakeCamera3.cpp +++ b/v3/EmulatedFakeCamera3.cpp @@ -180,6 +180,7 @@ EmulatedFakeCamera3::EmulatedFakeCamera3(int cameraId, struct hw_module_t* modul mSupportRotate = 0; mFullMode = 0; mFlushTag = false; + mPlugged = false; gLoadXml.parseXMLFile(); } -- cgit