manta: libcamera2: drain requests on empty request queue
authorMark Salyzyn <salyzyn@google.com>
Wed, 19 Nov 2014 16:38:54 +0000 (08:38 -0800)
committerThe Android Automerger <android-build@google.com>
Wed, 19 Nov 2014 22:56:16 +0000 (14:56 -0800)
Bug: 18118823
Bug: 17771002
Bug: 17660746
Bug: 13921808
Bug: 13358648
Bug: 13299991
Change-Id: Ib81b7d8b76470eebcd434a20b46d6235f5381f8b

libcamera2/ExynosCameraHWInterface2.cpp
libcamera2/ExynosCameraHWInterface2.h

index 8fce907870b2de6cff2ea1151c8813357a3687b0..cab01b4bfba73a3fa47e11785e8edd838f4e7354 100644 (file)
@@ -615,10 +615,15 @@ void RequestManager::ApplyDynamicMetadata(struct camera2_shot_ext *shot_ext)
     ALOGV("DEBUG(%s): frameCnt(%d)", __FUNCTION__, shot_ext->shot.ctl.request.frameCount);
 
     for (i = 0 ; i < NUM_MAX_REQUEST_MGR_ENTRY ; i++) {
-        if((entries[i].internal_shot.shot.ctl.request.frameCount == shot_ext->shot.ctl.request.frameCount)
-            && (entries[i].status == CAPTURED)){
-            entries[i].status = METADONE;
-            break;
+        if (entries[i].internal_shot.shot.ctl.request.frameCount
+                == shot_ext->shot.ctl.request.frameCount) {
+            if (entries[i].status == CAPTURED) {
+                entries[i].status = METADONE;
+                break;
+            }
+            if (entries[i].status == METADONE) {
+                return;
+            }
         }
     }
 
@@ -861,9 +866,10 @@ camera2_shot_ext *  RequestManager::GetInternalShotExt(int index)
     return &currentEntry->internal_shot;
 }
 
-int     RequestManager::FindFrameCnt(struct camera2_shot_ext * shot_ext)
+int     RequestManager::FindFrameCnt(struct camera2_shot_ext * shot_ext, bool drain)
 {
     Mutex::Autolock lock(m_requestMutex);
+    Mutex::Autolock lock2(m_numOfEntriesLock);
     int i;
 
     if (m_numOfEntries == 0) {
@@ -879,6 +885,9 @@ int     RequestManager::FindFrameCnt(struct camera2_shot_ext * shot_ext)
             entries[i].status = CAPTURED;
             return entries[i].internal_shot.shot.ctl.request.frameCount;
         }
+        if (drain && (entries[i].status >= CAPTURED)) {
+            return entries[i].internal_shot.shot.ctl.request.frameCount;
+        }
         CAM_LOGE("ERR(%s): frameCount(%d), index(%d), status(%d)", __FUNCTION__, shot_ext->shot.ctl.request.frameCount, i, entries[i].status);
 
     }
@@ -3154,7 +3163,7 @@ void ExynosCameraHWInterface2::m_sensorThreadFunc(SignalDrivenThread * self)
             matchedFrameCnt = m_ctlInfo.flash.m_flashFrameCount;
             ALOGV("Skip frame, request is fixed at %d", matchedFrameCnt);
         } else {
-            matchedFrameCnt = m_requestManager->FindFrameCnt(shot_ext);
+            matchedFrameCnt = m_requestManager->FindFrameCnt(shot_ext, m_isRequestQueueNull);
         }
 
         if (matchedFrameCnt == -1 && m_vdisBubbleCnt > 0) {
index a8e334885e1665a3f4b19a276281144053905db5..927eace337d147248b6130d7f920132327ee4124 100644 (file)
@@ -283,7 +283,7 @@ public:
     uint8_t  GetOutputStream(int index);
     camera2_shot_ext *  GetInternalShotExtByFrameCnt(int frameCnt);
     camera2_shot_ext *  GetInternalShotExt(int index);
-    int     FindFrameCnt(struct camera2_shot_ext * shot_ext);
+    int     FindFrameCnt(struct camera2_shot_ext * shot_ext, bool drain);
     bool    IsVdisEnable(void);
     int     FindEntryIndexByFrameCnt(int frameCnt);
     void    Dump(void);