Add aaudio APC opt-out
The opt-out was only present in the java API but not on the native ones.
Test: atest test_attributes
Change-Id: I1b84f1a428508e00de65e615b59405b9ee2ba009
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/media/libaaudio/tests/test_attributes.cpp b/media/libaaudio/tests/test_attributes.cpp
index dbf8712..32ee2a3 100644
--- a/media/libaaudio/tests/test_attributes.cpp
+++ b/media/libaaudio/tests/test_attributes.cpp
@@ -32,6 +32,7 @@
aaudio_usage_t usage,
aaudio_content_type_t contentType,
aaudio_input_preset_t preset = DONT_SET,
+ aaudio_allowed_capture_policy_t capturePolicy = DONT_SET,
aaudio_direction_t direction = AAUDIO_DIRECTION_OUTPUT) {
float *buffer = new float[kNumFrames * kChannelCount];
@@ -56,6 +57,9 @@
if (preset != DONT_SET) {
AAudioStreamBuilder_setInputPreset(aaudioBuilder, preset);
}
+ if (capturePolicy != DONT_SET) {
+ AAudioStreamBuilder_setAllowedCapturePolicy(aaudioBuilder, capturePolicy);
+ }
// Create an AAudioStream using the Builder.
ASSERT_EQ(AAUDIO_OK, AAudioStreamBuilder_openStream(aaudioBuilder, &aaudioStream));
@@ -80,6 +84,12 @@
: preset;
EXPECT_EQ(expectedPreset, AAudioStream_getInputPreset(aaudioStream));
+ aaudio_allowed_capture_policy_t expectedCapturePolicy =
+ (capturePolicy == DONT_SET || capturePolicy == AAUDIO_UNSPECIFIED)
+ ? AAUDIO_ALLOW_CAPTURE_BY_ALL // default
+ : preset;
+ EXPECT_EQ(expectedCapturePolicy, AAudioStream_getAllowedCapturePolicy(aaudioStream));
+
EXPECT_EQ(AAUDIO_OK, AAudioStream_requestStart(aaudioStream));
if (direction == AAUDIO_DIRECTION_INPUT) {
@@ -133,13 +143,21 @@
AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE,
};
+static const aaudio_input_preset_t sAllowCapturePolicies[] = {
+ DONT_SET,
+ AAUDIO_UNSPECIFIED,
+ AAUDIO_ALLOW_CAPTURE_BY_ALL,
+ AAUDIO_ALLOW_CAPTURE_BY_SYSTEM,
+ AAUDIO_ALLOW_CAPTURE_BY_NONE,
+};
+
static void checkAttributesUsage(aaudio_performance_mode_t perfMode) {
for (aaudio_usage_t usage : sUsages) {
checkAttributes(perfMode, usage, DONT_SET);
}
}
-static void checkAttributesContentType(aaudio_input_preset_t perfMode) {
+static void checkAttributesContentType(aaudio_performance_mode_t perfMode) {
for (aaudio_content_type_t contentType : sContentypes) {
checkAttributes(perfMode, DONT_SET, contentType);
}
@@ -151,6 +169,18 @@
DONT_SET,
DONT_SET,
inputPreset,
+ DONT_SET,
+ AAUDIO_DIRECTION_INPUT);
+ }
+}
+
+static void checkAttributesAllowedCapturePolicy(aaudio_performance_mode_t perfMode) {
+ for (aaudio_allowed_capture_policy_t policy : sAllowCapturePolicies) {
+ checkAttributes(perfMode,
+ DONT_SET,
+ DONT_SET,
+ DONT_SET,
+ policy,
AAUDIO_DIRECTION_INPUT);
}
}
@@ -167,6 +197,10 @@
checkAttributesInputPreset(AAUDIO_PERFORMANCE_MODE_NONE);
}
+TEST(test_attributes, aaudio_allowed_capture_policy_perfnone) {
+ checkAttributesAllowedCapturePolicy(AAUDIO_PERFORMANCE_MODE_NONE);
+}
+
TEST(test_attributes, aaudio_usage_lowlat) {
checkAttributesUsage(AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
}
@@ -178,3 +212,7 @@
TEST(test_attributes, aaudio_input_preset_lowlat) {
checkAttributesInputPreset(AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
}
+
+TEST(test_attributes, aaudio_allowed_capture_policy_lowlat) {
+ checkAttributesAllowedCapturePolicy(AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
+}