Camera service: Restructure buffer returns to avoid locks

Currently, the in-flight queue mutex is held while filled buffers are
returned to buffer queues.  Since queuing buffers into a BQ issues
binder calls into the client process, it can take a long time for
these calls to complete on heavily loaded devices.

Instead, collect buffers to be returned and then return them once the
in-flight mutex is released.

All buffer queuing is moved to the new method that consumes the list
of buffers to return, but the placement of the call to the new method
is gated by a flag, keeping the flow and order of buffer return as
close to before when the flag is off.

Performance tracing shows that the duration histogram of getExpectedInflightDuration is much more reasonable now.

Test: Manual testing of various GCA modes, atest CtsCameraTestCases,
    Perfetto comparisons of flag on/off while running GCA in 1080p60
    video recording.
Bug: 315526878
Change-Id: I433b3ce77a07bdf3f3685fe75e1fbd443a94fb4f
diff --git a/camera/camera_platform.aconfig b/camera/camera_platform.aconfig
index 63a514d..2266483 100644
--- a/camera/camera_platform.aconfig
+++ b/camera/camera_platform.aconfig
@@ -90,3 +90,10 @@
      description: "Only trigger lazy HAL instantiation when the HAL is needed for an operation."
      bug: "319735068"
 }
+
+flag {
+     namespace: "camera_platform"
+     name: "return_buffers_outside_locks"
+     description: "Enable returning graphics buffers to buffer queues without holding the in-flight mutex"
+     bug: "315526878"
+}