QCamera2/HAL3: Recover offline metabuffers on flush

Flush could be called while jpeg jobs from input reprocessing
are still pending. Recover the metabuffers by adding them
to freelist. This will handle the case of flush call not
followed up with conf_streams

BUG=24644360

Change-Id: I1886bf295331d98d2e89b7c43ea7a0c3406ac396
diff --git a/QCamera2/HAL3/QCamera3Channel.cpp b/QCamera2/HAL3/QCamera3Channel.cpp
index ef9a50c..acf435d 100644
--- a/QCamera2/HAL3/QCamera3Channel.cpp
+++ b/QCamera2/HAL3/QCamera3Channel.cpp
@@ -1012,6 +1012,15 @@
 void QCamera3ProcessingChannel::putStreamBufs()
 {
     mMemory.unregisterBuffers();
+
+    /* Reclaim all the offline metabuffers and push them to free list */
+    {
+        Mutex::Autolock lock(mFreeOfflineMetaBuffersLock);
+        mFreeOfflineMetaBuffersList.clear();
+        for (uint32_t i = 0; i < mOfflineMetaMemory.getCnt(); i++) {
+            mFreeOfflineMetaBuffersList.push_back(i);
+        }
+    }
 }
 
 
@@ -3188,7 +3197,7 @@
 
 void QCamera3PicChannel::putStreamBufs()
 {
-    mMemory.unregisterBuffers();
+    QCamera3ProcessingChannel::putStreamBufs();
 
     mYuvMemory->deallocate();
     delete mYuvMemory;