AudioFlinger: implement device specific audio effects
Add management of audio effects applied to a specific input
or output audio device.
A new class DeviceEffectProxy derived from Effectbase is added
to represent an effect attached to a particular audio device type and
address. This proxy manages one or more actual EffectModule instances
automatically added to a playback or capture thread or directly to the
audio HAL when the targeted audio device is used by an audio patch.
A new DeviceEffectManager class is added to manage creation and release
of DeviceEffectProxy instances and monitor creation and release of audio
patches and create or release actual effect instances accordingly.
Bug: 136294538
Test: make
Change-Id: I23b9f9db4459136039c5ee327cf3b1aefa7db5af
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index b9afba8..87b72fb 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1423,7 +1423,10 @@
if (effectBase == nullptr) {
return;
}
- effect = static_cast<EffectModule *>(effectBase.get());
+ effect = effectBase->asEffectModule();
+ if (effect == nullptr) {
+ return;
+ }
// restore suspended effects if the disconnected handle was enabled and the last one.
remove = (effect->removeHandle(handle) == 0) && (!effect->isPinned() || unpinIfLast);
if (remove) {