Use HAL-provided config for getInputBufferSize
Since getInputBufferSize is essentially the same
operation as opening a stream, it can also suggest
a config if the provided one is not supported.
Modify AudioFlinger::getInputBufferSize implementation
to retry with HAL-provided config.
Bug: 318423731
Test: run `atest audioeffect_tests` on cf_x86_64_auto-trunk_staging-userdebug
Change-Id: I0eb14966ce816674d631bfef097d243a0445c83b
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 7d63afb..c78e98e 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1933,7 +1933,7 @@
mHardwareStatus = AUDIO_HW_IDLE;
// Change parameters of the configuration each iteration until we find a
- // configuration that the device will support.
+ // configuration that the device will support, or HAL suggests what it supports.
audio_config_t config = AUDIO_CONFIG_INITIALIZER;
for (auto testChannelMask : channelMasks) {
config.channel_mask = testChannelMask;
@@ -1943,11 +1943,16 @@
config.sample_rate = testSampleRate;
size_t bytes = 0;
+ audio_config_t loopConfig = config;
status_t result = dev->getInputBufferSize(&config, &bytes);
+ if (result == BAD_VALUE) {
+ // Retry with the config suggested by the HAL.
+ result = dev->getInputBufferSize(&config, &bytes);
+ }
if (result != OK || bytes == 0) {
+ config = loopConfig;
continue;
}
-
if (config.sample_rate != sampleRate || config.channel_mask != channelMask ||
config.format != format) {
uint32_t dstChannelCount = audio_channel_count_from_in_mask(channelMask);