audioflinger: add effect creation probe mode
Add an argument to IAudioFlinger::createEffect() API to
ask AudioFlinger to just run the pre flight checks but not
create the actual audio effect instance and allocate resources.
This is the basis of an API for apps to query if a given
effect can be created without having to allocate the resources
and risk an exception when calling the constructor.
Bug: 150699608
Test: CTS and GTS Tests for audio effects
Change-Id: Ibdda22fd945c88c33e3c7342a7a5ed3e02d399ac
diff --git a/media/libaudioclient/IAudioFlinger.cpp b/media/libaudioclient/IAudioFlinger.cpp
index 513da2b..16d2232 100644
--- a/media/libaudioclient/IAudioFlinger.cpp
+++ b/media/libaudioclient/IAudioFlinger.cpp
@@ -662,6 +662,7 @@
const AudioDeviceTypeAddr& device,
const String16& opPackageName,
pid_t pid,
+ bool probe,
status_t *status,
int *id,
int *enabled)
@@ -689,6 +690,7 @@
}
data.writeString16(opPackageName);
data.writeInt32((int32_t) pid);
+ data.writeInt32(probe ? 1 : 0);
status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply);
if (lStatus != NO_ERROR) {
@@ -1395,12 +1397,13 @@
}
const String16 opPackageName = data.readString16();
pid_t pid = (pid_t)data.readInt32();
+ bool probe = data.readInt32() == 1;
int id = 0;
int enabled = 0;
sp<IEffect> effect = createEffect(&desc, client, priority, output, sessionId, device,
- opPackageName, pid, &status, &id, &enabled);
+ opPackageName, pid, probe, &status, &id, &enabled);
reply->writeInt32(status);
reply->writeInt32(id);
reply->writeInt32(enabled);