audio: Provide a way for Module to specify nominal latency

The latency figure depends on the module implementation.
Instead of using a hardcoded value, each module should be
able to specify its own value. This value is then used
for calculating the minimum buffer size.

Set the nominal latency of the primary (CF) module to a high
value since the virtual device implementation fails CTS tests
if it attempts to pretend that it provides low latency.

Bug: 302132812
Test: atest CtsMediaAudioTestCases --test-filter=".*AudioTrackTest.*"
Test: atest CtsMediaAudioTestCases --test-filter=".*AudioRecordTest.*"
Change-Id: I8ce9f230378eea787c9b3c7ce3660c1e4e7bc895
diff --git a/audio/aidl/default/ModulePrimary.cpp b/audio/aidl/default/ModulePrimary.cpp
index 9919c7f..3da6d48 100644
--- a/audio/aidl/default/ModulePrimary.cpp
+++ b/audio/aidl/default/ModulePrimary.cpp
@@ -58,4 +58,12 @@
                                                   offloadInfo);
 }
 
+int32_t ModulePrimary::getNominalLatencyMs(const AudioPortConfig&) {
+    // 85 ms is chosen considering 4096 frames @ 48 kHz. This is the value which allows
+    // the virtual Android device implementation to pass CTS. Hardware implementations
+    // should have significantly lower latency.
+    static constexpr int32_t kLatencyMs = 85;
+    return kLatencyMs;
+}
+
 }  // namespace aidl::android::hardware::audio::core