Use fast mode with patch track and patch record if possible.

Use fast mode with patch track/patch record if fast mixer/fast capture
is enabled. With the fast track and fast mixer/fast capture, we can get
a better performance on latency.

Bug: 111800664
Test: make phone call on marlin/walleye with enabling legacy usb hal
Change-Id: I0edd5978049e7c55da217a7a19e45fcbe5c3ac62
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 1e411c7..68c8cac 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -6700,6 +6700,14 @@
                 }
                 didModify = true;
             }
+            AudioBufferProvider* abp = (fastTrack != 0 && fastTrack->isPatchTrack()) ?
+                    reinterpret_cast<AudioBufferProvider*>(fastTrack.get()) : nullptr;
+            if (state->mFastPatchRecordBufferProvider != abp) {
+                state->mFastPatchRecordBufferProvider = abp;
+                state->mFastPatchRecordFormat = fastTrack == 0 ?
+                        AUDIO_FORMAT_INVALID : fastTrack->format();
+                didModify = true;
+            }
             sq->end(didModify);
             if (didModify) {
                 sq->push(block);