aaudio: add support for FLOAT pcm
Add to support for AUDIO_FORMAT_PCM_FLOAT.
Request AUDIO_FORMAT_PCM_FLOAT for MMAP streams.
Change the format to 32_BIT if openWithFormat returns error
and the format is float.
Bug: 201398105
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: If1ce1b31746dccba82d4eb9493d16946e39720b4
diff --git a/services/oboeservice/AAudioServiceEndpointMMAP.cpp b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
index 42b07ae..b9c1260 100644
--- a/services/oboeservice/AAudioServiceEndpointMMAP.cpp
+++ b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
@@ -80,16 +80,16 @@
audio_format_t audioFormat = getFormat();
- // 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 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_FLOAT) {
+ ALOGD("%s() FLOAT failed, perhaps due to format. Try again with 32_BIT", __func__);
+ 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;