Camera: fix release fence FD leaks

Test: use sw_sync to fake release fence FDs, GCA, CTS
Bug: 62070085
Change-Id: Iae77a2e112df5363e55e4177656a5dd41b830cbd
diff --git a/camera/device/3.2/default/CameraDeviceSession.h b/camera/device/3.2/default/CameraDeviceSession.h
index d559c48..fb3fc02 100644
--- a/camera/device/3.2/default/CameraDeviceSession.h
+++ b/camera/device/3.2/default/CameraDeviceSession.h
@@ -184,6 +184,9 @@
             std::vector<NotifyMsg> mShutterMsgs;
 
             struct BufferBatch {
+                BufferBatch(uint32_t batchSize) {
+                    mBuffers.reserve(batchSize);
+                }
                 bool mDelivered = false;
                 // This currently assumes every batched request will output to the batched stream
                 // and since HAL must always send buffers in order, no frameNumber tracking is
@@ -241,6 +244,11 @@
         void processOneCaptureResult(CaptureResult& result);
         void invokeProcessCaptureResultCallback(hidl_vec<CaptureResult> &results, bool tryWriteFmq);
 
+        // move/push function avoids "hidl_handle& operator=(hidl_handle&)", which clones native
+        // handle
+        void moveStreamBuffer(StreamBuffer&& src, StreamBuffer& dst);
+        void pushStreamBuffer(StreamBuffer&& src, std::vector<StreamBuffer>& dst);
+
         // Protect access to mInflightBatches, mNumPartialResults and mStreamsToBatch
         // processCaptureRequest, processCaptureResult, notify will compete for this lock
         // Do NOT issue HIDL IPCs while holding this lock (except when HAL reports error)