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/client/AudioStreamInternal.cpp b/media/libaaudio/src/client/AudioStreamInternal.cpp
index 2de878d..4956646 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternal.cpp
@@ -131,6 +131,10 @@
request.getConfiguration().setBufferCapacity(builder.getBufferCapacity());
+ request.getConfiguration().setHardwareSamplesPerFrame(builder.getHardwareSamplesPerFrame());
+ request.getConfiguration().setHardwareSampleRate(builder.getHardwareSampleRate());
+ request.getConfiguration().setHardwareFormat(builder.getHardwareFormat());
+
mDeviceChannelCount = getSamplesPerFrame(); // Assume it will be the same. Update if not.
mServiceStreamHandle = mServiceInterface.openStream(request, configurationOutput);
@@ -192,6 +196,10 @@
// Save device format so we can do format conversion and volume scaling together.
setDeviceFormat(configurationOutput.getFormat());
+ setHardwareSamplesPerFrame(configurationOutput.getHardwareSamplesPerFrame());
+ setHardwareSampleRate(configurationOutput.getHardwareSampleRate());
+ setHardwareFormat(configurationOutput.getHardwareFormat());
+
result = mServiceInterface.getStreamDescription(mServiceStreamHandle, mEndPointParcelable);
if (result != AAUDIO_OK) {
goto error;