Add format conversion in AudioRecord.
In audio flinger, it is required that the client's format matches the
hardware format to get fast mode. However, format conversion is not a
time consuming operation. In that case, adding format conversion in
AudioRecord can help the client get fast mode if only format is
different from the hardware one. This can help improve latency.
Test: atest AudioRecordTest, capture audio in fast/non-fast mode
Bug: 79156275
Bug: 188843084
Change-Id: I1baaa9a6054bb84412c31a159c6d25ee498822cf
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index a1fb304..445de02 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2142,6 +2142,20 @@
goto Exit;
}
+ if (recordTrack->isFastTrack()) {
+ output.serverConfig = {
+ thread->sampleRate(),
+ thread->channelMask(),
+ thread->format()
+ };
+ } else {
+ output.serverConfig = {
+ recordTrack->sampleRate(),
+ recordTrack->channelMask(),
+ recordTrack->format()
+ };
+ }
+
// Check if one effect chain was awaiting for an AudioRecord to be created on this
// session and move it to this thread.
sp<EffectChain> chain = getOrphanEffectChain_l(sessionId);