AudioFlinger: fix createEffect() for second client attached
The refactoring of AudioFlinger::createEffect() with AIDL (commit ce182940)
introduced a regression for the case where a second client
connects to an already existing effect.
In this case, the conventional return status of ALREADY_EXISTS is
interpreted as an error by the AIDL infrastructure and the response
data is dropped during the transaction causing the effect creation
to fail.
Test: atest audioeffect_tests:DefaultEffectTest#ManageSourceDefaultEffects
Change-Id: I858dd0ee2a200901ec229d4a5cabdf4a458ee88c
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 733fea4..defb8c1 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -3990,6 +3990,12 @@
Register:
if (!probe && (lStatus == NO_ERROR || lStatus == ALREADY_EXISTS)) {
+ if (lStatus == ALREADY_EXISTS) {
+ response->alreadyExists = true;
+ lStatus = NO_ERROR;
+ } else {
+ response->alreadyExists = false;
+ }
// Check CPU and memory usage
sp<EffectBase> effect = handle->effect().promote();
if (effect != nullptr) {