camerauis/cameraxui/cxengine/src/cxecameradevicecontrolsymbian.cpp
changeset 52 7e18d488ac5f
parent 46 c826656d6714
--- a/camerauis/cameraxui/cxengine/src/cxecameradevicecontrolsymbian.cpp	Fri Aug 06 10:03:37 2010 +0300
+++ b/camerauis/cameraxui/cxengine/src/cxecameradevicecontrolsymbian.cpp	Mon Aug 23 13:50:05 2010 +0300
@@ -45,6 +45,10 @@
 
     mCameraDevice = new CxeCameraDevice();
 
+    //!@todo Temporary delay before reserving camera to avoid timing issues
+    connect(&mReserveTimer, SIGNAL(timeout()), this, SLOT(doReserve()));
+    mReserveTimer.setSingleShot(true);
+
     CX_DEBUG_EXIT_FUNCTION();
 }
 
@@ -76,13 +80,14 @@
 void CxeCameraDeviceControlSymbian::reserve()
 {
     CX_DEBUG_ENTER_FUNCTION();
-
-    CX_DEBUG_ASSERT(mCameraDevice && mCameraDevice->camera());
+    CX_ASSERT_ALWAYS(mCameraDevice);
 
     if (state() == Idle) {
         setState(Initializing);
-        mCameraDevice->reserveCamera();
+        //!@todo Temporary delay before reserving camera to avoid timing issues
+        mReserveTimer.start(2000);
         OstTrace0(camerax_performance, CXECAMERADEVICECONTROLSYMBIAN_RESERVE, "msg: e_CX_RESERVE 1");
+        CX_DEBUG(("HACK: Waiting for 2000ms before really doing reserve()"));
     } else if (state() == PendingRelease) {
         // if we get a reserve request and if there is a pending release
         // it is just fine to continue the init operation.
@@ -94,6 +99,15 @@
     CX_DEBUG_EXIT_FUNCTION();
 }
 
+void CxeCameraDeviceControlSymbian::doReserve()
+{
+    CX_DEBUG_ENTER_FUNCTION();
+    CX_ASSERT_ALWAYS(mCameraDevice);
+    mCameraDevice->reserveCamera();
+    CX_DEBUG_EXIT_FUNCTION();
+}
+
+
 void CxeCameraDeviceControlSymbian::powerOn()
 {
     CX_DEBUG_ENTER_FUNCTION();
@@ -226,6 +240,16 @@
 {
     CX_DEBUG_ENTER_FUNCTION();
 
+    //!@todo Temporary delay before reserving camera to avoid timing issues
+    if (mReserveTimer.isActive()) {
+        // release() was called when the timer was active
+        mReserveTimer.stop();
+        mCameraDevice->releaseCamera();
+        setState(Idle);
+        CX_DEBUG_EXIT_FUNCTION();
+        return;
+    }
+
     if (state() == Idle) {
         // nothing to do
         return;