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
5 files changed