Revert "Audio effects: define interface between EffectModule and audio framework"

This reverts commit c0abc6239e1134ed224a10aa66a364baff71cd07.

Reason for revert: broken build on target cf_x86_phone-userdebug_coverage

Change-Id: Ic6808bfd31bedfa85b7d7a120e4c6f6273678f73
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index d838644..e70c776 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1146,13 +1146,18 @@
     }
 }
 
-void AudioFlinger::ThreadBase::checkSuspendOnEffectEnabled(bool enabled,
-                                                           audio_session_t sessionId,
-                                                           bool threadLocked) {
-    if (!threadLocked) {
-        mLock.lock();
-    }
+void AudioFlinger::ThreadBase::checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
+                                                            bool enabled,
+                                                            audio_session_t sessionId)
+{
+    Mutex::Autolock _l(mLock);
+    checkSuspendOnEffectEnabled_l(effect, enabled, sessionId);
+}
 
+void AudioFlinger::ThreadBase::checkSuspendOnEffectEnabled_l(const sp<EffectModule>& effect,
+                                                            bool enabled,
+                                                            audio_session_t sessionId)
+{
     if (mType != RECORD) {
         // suspend all effects in AUDIO_SESSION_OUTPUT_MIX when enabling any effect on
         // another session. This gives the priority to well behaved effect control panels
@@ -1164,8 +1169,9 @@
         }
     }
 
-    if (!threadLocked) {
-        mLock.unlock();
+    sp<EffectChain> chain = getEffectChain_l(sessionId);
+    if (chain != 0) {
+        chain->checkSuspendOnEffectEnabled(effect, enabled);
     }
 }
 
@@ -1373,7 +1379,7 @@
         if (effect == 0) {
             effectId = mAudioFlinger->nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT);
             // create a new effect module if none present in the chain
-            lStatus = chain->createEffect_l(effect, desc, effectId, sessionId, pinned);
+            lStatus = chain->createEffect_l(effect, this, desc, effectId, sessionId, pinned);
             if (lStatus != NO_ERROR) {
                 goto Exit;
             }
@@ -1421,7 +1427,7 @@
         Mutex::Autolock _l(mLock);
 
         effect = handle->effect().promote();
-        if (effect == nullptr) {
+        if (effect == 0) {
             return;
         }
         // restore suspended effects if the disconnected handle was enabled and the last one.
@@ -1433,34 +1439,11 @@
     if (remove) {
         mAudioFlinger->updateOrphanEffectChains(effect);
         if (handle->enabled()) {
-            effect->checkSuspendOnEffectEnabled(false, false /*threadLocked*/);
+            checkSuspendOnEffectEnabled(effect, false, effect->sessionId());
         }
     }
 }
 
-void AudioFlinger::ThreadBase::onEffectEnable(const sp<EffectModule>& effect) {
-    if (mType == OFFLOAD || mType == MMAP) {
-        Mutex::Autolock _l(mLock);
-        broadcast_l();
-    }
-    if (!effect->isOffloadable()) {
-        if (mType == ThreadBase::OFFLOAD) {
-            PlaybackThread *t = (PlaybackThread *)this;
-            t->invalidateTracks(AUDIO_STREAM_MUSIC);
-        }
-        if (effect->sessionId() == AUDIO_SESSION_OUTPUT_MIX) {
-            mAudioFlinger->onNonOffloadableGlobalEffectEnable();
-        }
-    }
-}
-
-void AudioFlinger::ThreadBase::onEffectDisable() {
-    if (mType == OFFLOAD || mType == MMAP) {
-        Mutex::Autolock _l(mLock);
-        broadcast_l();
-    }
-}
-
 sp<AudioFlinger::EffectModule> AudioFlinger::ThreadBase::getEffect(audio_session_t sessionId,
         int effectId)
 {
@@ -1536,7 +1519,7 @@
         detachAuxEffect_l(effect->id());
     }
 
-    sp<EffectChain> chain = effect->callback()->chain().promote();
+    sp<EffectChain> chain = effect->chain().promote();
     if (chain != 0) {
         // remove effect chain if removing last effect
         if (chain->removeEffect_l(effect, release) == 0) {