AAudio: Add AAudioStream_getHardware* functions
Add new methods to AAudioStream that allow for queries on the hardware
aspects of streams.
These will allow developers understand the hardware limitations of their
Android devices after they create AAudio streams.
Bug: 245412674
Test: atest AAudioTests
Change-Id: I104a738df89ab22aba9e0658b43402ddf053b887
diff --git a/media/libaaudio/src/utility/AAudioUtilities.cpp b/media/libaaudio/src/utility/AAudioUtilities.cpp
index a197ced..69e51d6 100644
--- a/media/libaaudio/src/utility/AAudioUtilities.cpp
+++ b/media/libaaudio/src/utility/AAudioUtilities.cpp
@@ -180,6 +180,17 @@
return aaudioFormat;
}
+aaudio_format_t AAudioConvert_androidToNearestAAudioDataFormat(audio_format_t androidFormat) {
+ // Special case AUDIO_FORMAT_PCM_8_24_BIT because this function should be used to find the
+ // resolution of the data format. Setting AUDIO_FORMAT_PCM_8_24_BIT directly is not available
+ // from AAudio but hardware may use AUDIO_FORMAT_PCM_8_24_BIT under the hood.
+ if (androidFormat == AUDIO_FORMAT_PCM_8_24_BIT) {
+ ALOGD("%s() converting 8.24 to 24 bit packed", __func__);
+ return AAUDIO_FORMAT_PCM_I24_PACKED;
+ }
+ return AAudioConvert_androidToAAudioDataFormat(androidFormat);
+}
+
// Make a message string from the condition.
#define STATIC_ASSERT(condition) static_assert(condition, #condition)
diff --git a/media/libaaudio/src/utility/AAudioUtilities.h b/media/libaaudio/src/utility/AAudioUtilities.h
index b59ce1c..f3365eb 100644
--- a/media/libaaudio/src/utility/AAudioUtilities.h
+++ b/media/libaaudio/src/utility/AAudioUtilities.h
@@ -62,6 +62,7 @@
aaudio_format_t AAudioConvert_androidToAAudioDataFormat(audio_format_t format);
+aaudio_format_t AAudioConvert_androidToNearestAAudioDataFormat(audio_format_t format);
/**
* Note that this function does not validate the passed in value.