aaudio: Reqest 32_BIT in AAudio Service for MMAP streams
Change the format to 32_BIT if the format is float.
Bug: 175673727
Test: The formats listed are the internal AudioFlinger formats:
Test: 1=16_BIT, 3=32_BIT, 4=8_24_BIT, 5=FLOAT, 6=24_BIT_PACKED
Change-Id: I68972a3529e60725aaf44cfd3d35ddcc4523039e
diff --git a/services/oboeservice/AAudioServiceEndpointMMAP.cpp b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
index 7294a58..b4efd1a 100644
--- a/services/oboeservice/AAudioServiceEndpointMMAP.cpp
+++ b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
@@ -80,18 +80,23 @@
audio_format_t audioFormat = getFormat();
- // FLOAT is not directly supported by the HAL so ask for a 24-bit.
- bool isHighResRequested = audioFormat == AUDIO_FORMAT_PCM_FLOAT
- || audioFormat == AUDIO_FORMAT_PCM_32_BIT;
- if (isHighResRequested) {
+ // FLOAT is not directly supported by the HAL so ask for a 32-bit.
+ if (audioFormat == AUDIO_FORMAT_PCM_FLOAT) {
// TODO remove these logs when finished debugging.
- ALOGD("%s() change format from %d to 24_BIT_PACKED", __func__, audioFormat);
- audioFormat = AUDIO_FORMAT_PCM_24_BIT_PACKED;
+ ALOGD("%s() change format from %d to 32_BIT", __func__, audioFormat);
+ audioFormat = AUDIO_FORMAT_PCM_32_BIT;
}
result = openWithFormat(audioFormat);
if (result == AAUDIO_OK) return result;
+ if (result == AAUDIO_ERROR_UNAVAILABLE && audioFormat == AUDIO_FORMAT_PCM_32_BIT) {
+ ALOGD("%s() 32_BIT failed, perhaps due to format. Try again with 24_BIT_PACKED", __func__);
+ audioFormat = AUDIO_FORMAT_PCM_24_BIT_PACKED;
+ result = openWithFormat(audioFormat);
+ }
+ if (result == AAUDIO_OK) return result;
+
// TODO The HAL and AudioFlinger should be recommending a format if the open fails.
// But that recommendation is not propagating back from the HAL.
// So for now just try something very likely to work.