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/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index f24dcd7..dc39b62 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1365,7 +1365,8 @@
effect_descriptor_t *desc,
int *enabled,
status_t *status,
- bool pinned)
+ bool pinned,
+ bool probe)
{
sp<EffectModule> effect;
sp<EffectHandle> handle;
@@ -1387,7 +1388,7 @@
Mutex::Autolock _l(mLock);
lStatus = checkEffectCompatibility_l(desc, sessionId);
- if (lStatus != NO_ERROR) {
+ if (probe || lStatus != NO_ERROR) {
goto Exit;
}
@@ -1433,7 +1434,7 @@
}
Exit:
- if (lStatus != NO_ERROR && lStatus != ALREADY_EXISTS) {
+ if (!probe && lStatus != NO_ERROR && lStatus != ALREADY_EXISTS) {
Mutex::Autolock _l(mLock);
if (effectCreated) {
chain->removeEffect_l(effect);