Loading services/audioflinger/AudioFlinger.h +3 −6 Original line number Original line Diff line number Diff line Loading @@ -131,6 +131,7 @@ // Classes that depend on IAf* interfaces but are not cross-dependent. // Classes that depend on IAf* interfaces but are not cross-dependent. #include "PatchCommandThread.h" #include "PatchCommandThread.h" #include "DeviceEffectManager.h" namespace android { namespace android { Loading Loading @@ -163,6 +164,8 @@ class AudioFlinger : public AudioFlingerServerAdapter::Delegate { { friend class sp<AudioFlinger>; friend class sp<AudioFlinger>; friend class Client; // removeClient_l(); friend class Client; // removeClient_l(); friend class DeviceEffectManager; friend class DeviceEffectManagerCallback; friend class PatchPanel; friend class PatchPanel; // TODO(b/291012167) replace the Thread friends with an interface. // TODO(b/291012167) replace the Thread friends with an interface. friend class DirectOutputThread; friend class DirectOutputThread; Loading Loading @@ -579,18 +582,12 @@ private: void requestLogMerge(); void requestLogMerge(); // TODO(b/288339104) replace these forward declaration classes with interfaces. // TODO(b/288339104) replace these forward declaration classes with interfaces. class DeviceEffectManager; // TODO(b/288339104) these should be separate files public: class DeviceEffectManagerCallback; private: private: struct TeePatch; struct TeePatch; public: public: using TeePatches = std::vector<TeePatch>; using TeePatches = std::vector<TeePatch>; private: private: #include "DeviceEffectManager.h" #include "MelReporter.h" #include "MelReporter.h" // Find io handle by session id. // Find io handle by session id. Loading services/audioflinger/DeviceEffectManager.cpp +36 −11 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,7 @@ */ */ #define LOG_TAG "AudioFlinger::DeviceEffectManager" #define LOG_TAG "DeviceEffectManager" //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #include <utils/Log.h> #include <utils/Log.h> Loading @@ -34,7 +34,25 @@ namespace android { using detail::AudioHalVersionInfo; using detail::AudioHalVersionInfo; using media::IEffectClient; using media::IEffectClient; void AudioFlinger::DeviceEffectManager::onCreateAudioPatch(audio_patch_handle_t handle, DeviceEffectManager::DeviceEffectManager(AudioFlinger& audioFlinger) : mAudioFlinger(audioFlinger), mMyCallback(new DeviceEffectManagerCallback(*this)) {} void DeviceEffectManager::onFirstRef() { mAudioFlinger.mPatchCommandThread->addListener(this); } status_t DeviceEffectManager::addEffectToHal(const struct audio_port_config* device, const sp<EffectHalInterface>& effect) { return mAudioFlinger.addEffectToHal(device, effect); }; status_t DeviceEffectManager::removeEffectFromHal(const struct audio_port_config* device, const sp<EffectHalInterface>& effect) { return mAudioFlinger.removeEffectFromHal(device, effect); }; void DeviceEffectManager::onCreateAudioPatch(audio_patch_handle_t handle, const IAfPatchPanel::Patch& patch) { const IAfPatchPanel::Patch& patch) { ALOGV("%s handle %d mHalHandle %d device sink %08x", ALOGV("%s handle %d mHalHandle %d device sink %08x", __func__, handle, patch.mHalHandle, __func__, handle, patch.mHalHandle, Loading @@ -47,7 +65,7 @@ void AudioFlinger::DeviceEffectManager::onCreateAudioPatch(audio_patch_handle_t } } } } void AudioFlinger::DeviceEffectManager::onReleaseAudioPatch(audio_patch_handle_t handle) { void DeviceEffectManager::onReleaseAudioPatch(audio_patch_handle_t handle) { ALOGV("%s", __func__); ALOGV("%s", __func__); Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock); for (auto& effect : mDeviceEffects) { for (auto& effect : mDeviceEffects) { Loading @@ -56,7 +74,7 @@ void AudioFlinger::DeviceEffectManager::onReleaseAudioPatch(audio_patch_handle_t } } // DeviceEffectManager::createEffect_l() must be called with AudioFlinger::mLock held // DeviceEffectManager::createEffect_l() must be called with AudioFlinger::mLock held sp<IAfEffectHandle> AudioFlinger::DeviceEffectManager::createEffect_l( sp<IAfEffectHandle> DeviceEffectManager::createEffect_l( effect_descriptor_t *descriptor, effect_descriptor_t *descriptor, const AudioDeviceTypeAddr& device, const AudioDeviceTypeAddr& device, const sp<Client>& client, const sp<Client>& client, Loading Loading @@ -110,7 +128,7 @@ sp<IAfEffectHandle> AudioFlinger::DeviceEffectManager::createEffect_l( return handle; return handle; } } status_t AudioFlinger::DeviceEffectManager::checkEffectCompatibility( status_t DeviceEffectManager::checkEffectCompatibility( const effect_descriptor_t *desc) { const effect_descriptor_t *desc) { const sp<EffectsFactoryHalInterface> effectsFactory = const sp<EffectsFactoryHalInterface> effectsFactory = audioflinger::EffectConfiguration::getEffectsFactoryHal(); audioflinger::EffectConfiguration::getEffectsFactoryHal(); Loading @@ -136,7 +154,7 @@ status_t AudioFlinger::DeviceEffectManager::checkEffectCompatibility( return NO_ERROR; return NO_ERROR; } } status_t AudioFlinger::DeviceEffectManager::createEffectHal( status_t DeviceEffectManager::createEffectHal( const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t deviceId, const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t deviceId, sp<EffectHalInterface> *effect) { sp<EffectHalInterface> *effect) { status_t status = NO_INIT; status_t status = NO_INIT; Loading @@ -149,10 +167,10 @@ status_t AudioFlinger::DeviceEffectManager::createEffectHal( return status; return status; } } void AudioFlinger::DeviceEffectManager::dump(int fd) void DeviceEffectManager::dump(int fd) NO_THREAD_SAFETY_ANALYSIS // conditional try lock NO_THREAD_SAFETY_ANALYSIS // conditional try lock { { const bool locked = dumpTryLock(mLock); const bool locked = AudioFlinger::dumpTryLock(mLock); if (!locked) { if (!locked) { String8 result("DeviceEffectManager may be deadlocked\n"); String8 result("DeviceEffectManager may be deadlocked\n"); write(fd, result.string(), result.size()); write(fd, result.string(), result.size()); Loading @@ -173,15 +191,14 @@ NO_THREAD_SAFETY_ANALYSIS // conditional try lock } } } } size_t DeviceEffectManager::removeEffect(const sp<IAfDeviceEffectProxy>& effect) size_t AudioFlinger::DeviceEffectManager::removeEffect(const sp<IAfDeviceEffectProxy>& effect) { { Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock); mDeviceEffects.erase(effect->device()); mDeviceEffects.erase(effect->device()); return mDeviceEffects.size(); return mDeviceEffects.size(); } } bool AudioFlinger::DeviceEffectManagerCallback::disconnectEffectHandle( bool DeviceEffectManagerCallback::disconnectEffectHandle( IAfEffectHandle *handle, bool unpinIfLast) { IAfEffectHandle *handle, bool unpinIfLast) { sp<IAfEffectBase> effectBase = handle->effect().promote(); sp<IAfEffectBase> effectBase = handle->effect().promote(); if (effectBase == nullptr) { if (effectBase == nullptr) { Loading @@ -203,4 +220,12 @@ bool AudioFlinger::DeviceEffectManagerCallback::disconnectEffectHandle( return true; return true; } } bool DeviceEffectManagerCallback::isAudioPolicyReady() const { return mManager.audioFlinger().isAudioPolicyReady(); } int DeviceEffectManagerCallback::newEffectId() const { return mManager.audioFlinger().nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT); } } // namespace android } // namespace android services/audioflinger/DeviceEffectManager.h +15 −23 Original line number Original line Diff line number Diff line Loading @@ -15,20 +15,18 @@ ** limitations under the License. ** limitations under the License. */ */ #ifndef INCLUDING_FROM_AUDIOFLINGER_H #pragma once #error This header file should only be included from AudioFlinger.h #endif namespace android { class DeviceEffectManagerCallback; // DeviceEffectManager is concealed within AudioFlinger, their lifetimes are the same. // DeviceEffectManager is concealed within AudioFlinger, their lifetimes are the same. class DeviceEffectManager : public PatchCommandThread::PatchCommandListener { class DeviceEffectManager : public PatchCommandThread::PatchCommandListener { public: public: explicit DeviceEffectManager(AudioFlinger& audioFlinger) explicit DeviceEffectManager(AudioFlinger& audioFlinger); : mAudioFlinger(audioFlinger), mMyCallback(new DeviceEffectManagerCallback(*this)) {} void onFirstRef() override { void onFirstRef() override; mAudioFlinger.mPatchCommandThread->addListener(this); } sp<IAfEffectHandle> createEffect_l(effect_descriptor_t *descriptor, sp<IAfEffectHandle> createEffect_l(effect_descriptor_t *descriptor, const AudioDeviceTypeAddr& device, const AudioDeviceTypeAddr& device, Loading @@ -45,13 +43,9 @@ public: int32_t sessionId, int32_t deviceId, int32_t sessionId, int32_t deviceId, sp<EffectHalInterface> *effect); sp<EffectHalInterface> *effect); status_t addEffectToHal(const struct audio_port_config *device, status_t addEffectToHal(const struct audio_port_config *device, const sp<EffectHalInterface>& effect) { const sp<EffectHalInterface>& effect); return mAudioFlinger.addEffectToHal(device, effect); }; status_t removeEffectFromHal(const struct audio_port_config *device, status_t removeEffectFromHal(const struct audio_port_config *device, const sp<EffectHalInterface>& effect) { const sp<EffectHalInterface>& effect); return mAudioFlinger.removeEffectFromHal(device, effect); }; AudioFlinger& audioFlinger() const { return mAudioFlinger; } AudioFlinger& audioFlinger() const { return mAudioFlinger; } Loading @@ -60,8 +54,8 @@ public: // PatchCommandThread::PatchCommandListener implementation // PatchCommandThread::PatchCommandListener implementation void onCreateAudioPatch(audio_patch_handle_t handle, void onCreateAudioPatch(audio_patch_handle_t handle, const IAfPatchPanel::Patch& patch) override; const IAfPatchPanel::Patch& patch) final; void onReleaseAudioPatch(audio_patch_handle_t handle) override; void onReleaseAudioPatch(audio_patch_handle_t handle) final; private: private: status_t checkEffectCompatibility(const effect_descriptor_t *desc); status_t checkEffectCompatibility(const effect_descriptor_t *desc); Loading @@ -72,7 +66,6 @@ private: std::map<AudioDeviceTypeAddr, sp<IAfDeviceEffectProxy>> mDeviceEffects; std::map<AudioDeviceTypeAddr, sp<IAfDeviceEffectProxy>> mDeviceEffects; }; }; public: // TODO(b/288339104) extract inner class. class DeviceEffectManagerCallback : public EffectCallbackInterface { class DeviceEffectManagerCallback : public EffectCallbackInterface { public: public: explicit DeviceEffectManagerCallback(DeviceEffectManager& manager) explicit DeviceEffectManagerCallback(DeviceEffectManager& manager) Loading Loading @@ -129,11 +122,9 @@ public: wp<IAfEffectChain> chain() const override { return nullptr; } wp<IAfEffectChain> chain() const override { return nullptr; } bool isAudioPolicyReady() const override { bool isAudioPolicyReady() const final; return mManager.audioFlinger().isAudioPolicyReady(); } int newEffectId() { return mManager.audioFlinger().nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT); } int newEffectId() const; status_t addEffectToHal(const struct audio_port_config *device, status_t addEffectToHal(const struct audio_port_config *device, const sp<EffectHalInterface>& effect) { const sp<EffectHalInterface>& effect) { Loading @@ -146,4 +137,5 @@ public: private: private: DeviceEffectManager& mManager; DeviceEffectManager& mManager; }; }; private: } // namespace android services/audioflinger/Effects.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -3257,11 +3257,11 @@ int32_t EffectChain::EffectCallback::activeTrackCnt() const { /* static */ /* static */ sp<IAfDeviceEffectProxy> IAfDeviceEffectProxy::create( sp<IAfDeviceEffectProxy> IAfDeviceEffectProxy::create( const AudioDeviceTypeAddr& device, const AudioDeviceTypeAddr& device, const sp</* DeviceEffectManagerCallback */ RefBase>& callback, // TODO(b/288339104) type const sp<DeviceEffectManagerCallback>& callback, effect_descriptor_t *desc, int id, bool notifyFramesProcessed) effect_descriptor_t *desc, int id, bool notifyFramesProcessed) { { return sp<DeviceEffectProxy>::make(device, return sp<DeviceEffectProxy>::make(device, sp<AudioFlinger::DeviceEffectManagerCallback>::cast(callback), callback, desc, id, notifyFramesProcessed); desc, id, notifyFramesProcessed); } } Loading services/audioflinger/Effects.h +4 −4 Original line number Original line Diff line number Diff line Loading @@ -646,7 +646,7 @@ private: class DeviceEffectProxy : public IAfDeviceEffectProxy, public EffectBase { class DeviceEffectProxy : public IAfDeviceEffectProxy, public EffectBase { public: public: DeviceEffectProxy(const AudioDeviceTypeAddr& device, DeviceEffectProxy(const AudioDeviceTypeAddr& device, const sp<AudioFlinger::DeviceEffectManagerCallback>& callback, const sp<DeviceEffectManagerCallback>& callback, effect_descriptor_t *desc, int id, bool notifyFramesProcessed) effect_descriptor_t *desc, int id, bool notifyFramesProcessed) : EffectBase(callback, desc, id, AUDIO_SESSION_DEVICE, false), : EffectBase(callback, desc, id, AUDIO_SESSION_DEVICE, false), mDevice(device), mManagerCallback(callback), mDevice(device), mManagerCallback(callback), Loading Loading @@ -684,7 +684,7 @@ private: // Note: ctors taking a weak pointer to their owner must not promote it // Note: ctors taking a weak pointer to their owner must not promote it // during construction (but may keep a reference for later promotion). // during construction (but may keep a reference for later promotion). ProxyCallback(const wp<DeviceEffectProxy>& owner, ProxyCallback(const wp<DeviceEffectProxy>& owner, const sp<AudioFlinger::DeviceEffectManagerCallback>& callback) const sp<DeviceEffectManagerCallback>& callback) : mProxy(owner), mManagerCallback(callback) {} : mProxy(owner), mManagerCallback(callback) {} status_t createEffectHal(const effect_uuid_t *pEffectUuid, status_t createEffectHal(const effect_uuid_t *pEffectUuid, Loading Loading @@ -735,14 +735,14 @@ private: private: private: const wp<DeviceEffectProxy> mProxy; const wp<DeviceEffectProxy> mProxy; const sp<AudioFlinger::DeviceEffectManagerCallback> mManagerCallback; const sp<DeviceEffectManagerCallback> mManagerCallback; }; }; status_t checkPort(const IAfPatchPanel::Patch& patch, status_t checkPort(const IAfPatchPanel::Patch& patch, const struct audio_port_config *port, sp<IAfEffectHandle> *handle); const struct audio_port_config *port, sp<IAfEffectHandle> *handle); const AudioDeviceTypeAddr mDevice; const AudioDeviceTypeAddr mDevice; const sp<AudioFlinger::DeviceEffectManagerCallback> mManagerCallback; const sp<DeviceEffectManagerCallback> mManagerCallback; const sp<ProxyCallback> mMyCallback; const sp<ProxyCallback> mMyCallback; mutable Mutex mProxyLock; mutable Mutex mProxyLock; Loading Loading
services/audioflinger/AudioFlinger.h +3 −6 Original line number Original line Diff line number Diff line Loading @@ -131,6 +131,7 @@ // Classes that depend on IAf* interfaces but are not cross-dependent. // Classes that depend on IAf* interfaces but are not cross-dependent. #include "PatchCommandThread.h" #include "PatchCommandThread.h" #include "DeviceEffectManager.h" namespace android { namespace android { Loading Loading @@ -163,6 +164,8 @@ class AudioFlinger : public AudioFlingerServerAdapter::Delegate { { friend class sp<AudioFlinger>; friend class sp<AudioFlinger>; friend class Client; // removeClient_l(); friend class Client; // removeClient_l(); friend class DeviceEffectManager; friend class DeviceEffectManagerCallback; friend class PatchPanel; friend class PatchPanel; // TODO(b/291012167) replace the Thread friends with an interface. // TODO(b/291012167) replace the Thread friends with an interface. friend class DirectOutputThread; friend class DirectOutputThread; Loading Loading @@ -579,18 +582,12 @@ private: void requestLogMerge(); void requestLogMerge(); // TODO(b/288339104) replace these forward declaration classes with interfaces. // TODO(b/288339104) replace these forward declaration classes with interfaces. class DeviceEffectManager; // TODO(b/288339104) these should be separate files public: class DeviceEffectManagerCallback; private: private: struct TeePatch; struct TeePatch; public: public: using TeePatches = std::vector<TeePatch>; using TeePatches = std::vector<TeePatch>; private: private: #include "DeviceEffectManager.h" #include "MelReporter.h" #include "MelReporter.h" // Find io handle by session id. // Find io handle by session id. Loading
services/audioflinger/DeviceEffectManager.cpp +36 −11 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,7 @@ */ */ #define LOG_TAG "AudioFlinger::DeviceEffectManager" #define LOG_TAG "DeviceEffectManager" //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #include <utils/Log.h> #include <utils/Log.h> Loading @@ -34,7 +34,25 @@ namespace android { using detail::AudioHalVersionInfo; using detail::AudioHalVersionInfo; using media::IEffectClient; using media::IEffectClient; void AudioFlinger::DeviceEffectManager::onCreateAudioPatch(audio_patch_handle_t handle, DeviceEffectManager::DeviceEffectManager(AudioFlinger& audioFlinger) : mAudioFlinger(audioFlinger), mMyCallback(new DeviceEffectManagerCallback(*this)) {} void DeviceEffectManager::onFirstRef() { mAudioFlinger.mPatchCommandThread->addListener(this); } status_t DeviceEffectManager::addEffectToHal(const struct audio_port_config* device, const sp<EffectHalInterface>& effect) { return mAudioFlinger.addEffectToHal(device, effect); }; status_t DeviceEffectManager::removeEffectFromHal(const struct audio_port_config* device, const sp<EffectHalInterface>& effect) { return mAudioFlinger.removeEffectFromHal(device, effect); }; void DeviceEffectManager::onCreateAudioPatch(audio_patch_handle_t handle, const IAfPatchPanel::Patch& patch) { const IAfPatchPanel::Patch& patch) { ALOGV("%s handle %d mHalHandle %d device sink %08x", ALOGV("%s handle %d mHalHandle %d device sink %08x", __func__, handle, patch.mHalHandle, __func__, handle, patch.mHalHandle, Loading @@ -47,7 +65,7 @@ void AudioFlinger::DeviceEffectManager::onCreateAudioPatch(audio_patch_handle_t } } } } void AudioFlinger::DeviceEffectManager::onReleaseAudioPatch(audio_patch_handle_t handle) { void DeviceEffectManager::onReleaseAudioPatch(audio_patch_handle_t handle) { ALOGV("%s", __func__); ALOGV("%s", __func__); Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock); for (auto& effect : mDeviceEffects) { for (auto& effect : mDeviceEffects) { Loading @@ -56,7 +74,7 @@ void AudioFlinger::DeviceEffectManager::onReleaseAudioPatch(audio_patch_handle_t } } // DeviceEffectManager::createEffect_l() must be called with AudioFlinger::mLock held // DeviceEffectManager::createEffect_l() must be called with AudioFlinger::mLock held sp<IAfEffectHandle> AudioFlinger::DeviceEffectManager::createEffect_l( sp<IAfEffectHandle> DeviceEffectManager::createEffect_l( effect_descriptor_t *descriptor, effect_descriptor_t *descriptor, const AudioDeviceTypeAddr& device, const AudioDeviceTypeAddr& device, const sp<Client>& client, const sp<Client>& client, Loading Loading @@ -110,7 +128,7 @@ sp<IAfEffectHandle> AudioFlinger::DeviceEffectManager::createEffect_l( return handle; return handle; } } status_t AudioFlinger::DeviceEffectManager::checkEffectCompatibility( status_t DeviceEffectManager::checkEffectCompatibility( const effect_descriptor_t *desc) { const effect_descriptor_t *desc) { const sp<EffectsFactoryHalInterface> effectsFactory = const sp<EffectsFactoryHalInterface> effectsFactory = audioflinger::EffectConfiguration::getEffectsFactoryHal(); audioflinger::EffectConfiguration::getEffectsFactoryHal(); Loading @@ -136,7 +154,7 @@ status_t AudioFlinger::DeviceEffectManager::checkEffectCompatibility( return NO_ERROR; return NO_ERROR; } } status_t AudioFlinger::DeviceEffectManager::createEffectHal( status_t DeviceEffectManager::createEffectHal( const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t deviceId, const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t deviceId, sp<EffectHalInterface> *effect) { sp<EffectHalInterface> *effect) { status_t status = NO_INIT; status_t status = NO_INIT; Loading @@ -149,10 +167,10 @@ status_t AudioFlinger::DeviceEffectManager::createEffectHal( return status; return status; } } void AudioFlinger::DeviceEffectManager::dump(int fd) void DeviceEffectManager::dump(int fd) NO_THREAD_SAFETY_ANALYSIS // conditional try lock NO_THREAD_SAFETY_ANALYSIS // conditional try lock { { const bool locked = dumpTryLock(mLock); const bool locked = AudioFlinger::dumpTryLock(mLock); if (!locked) { if (!locked) { String8 result("DeviceEffectManager may be deadlocked\n"); String8 result("DeviceEffectManager may be deadlocked\n"); write(fd, result.string(), result.size()); write(fd, result.string(), result.size()); Loading @@ -173,15 +191,14 @@ NO_THREAD_SAFETY_ANALYSIS // conditional try lock } } } } size_t DeviceEffectManager::removeEffect(const sp<IAfDeviceEffectProxy>& effect) size_t AudioFlinger::DeviceEffectManager::removeEffect(const sp<IAfDeviceEffectProxy>& effect) { { Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock); mDeviceEffects.erase(effect->device()); mDeviceEffects.erase(effect->device()); return mDeviceEffects.size(); return mDeviceEffects.size(); } } bool AudioFlinger::DeviceEffectManagerCallback::disconnectEffectHandle( bool DeviceEffectManagerCallback::disconnectEffectHandle( IAfEffectHandle *handle, bool unpinIfLast) { IAfEffectHandle *handle, bool unpinIfLast) { sp<IAfEffectBase> effectBase = handle->effect().promote(); sp<IAfEffectBase> effectBase = handle->effect().promote(); if (effectBase == nullptr) { if (effectBase == nullptr) { Loading @@ -203,4 +220,12 @@ bool AudioFlinger::DeviceEffectManagerCallback::disconnectEffectHandle( return true; return true; } } bool DeviceEffectManagerCallback::isAudioPolicyReady() const { return mManager.audioFlinger().isAudioPolicyReady(); } int DeviceEffectManagerCallback::newEffectId() const { return mManager.audioFlinger().nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT); } } // namespace android } // namespace android
services/audioflinger/DeviceEffectManager.h +15 −23 Original line number Original line Diff line number Diff line Loading @@ -15,20 +15,18 @@ ** limitations under the License. ** limitations under the License. */ */ #ifndef INCLUDING_FROM_AUDIOFLINGER_H #pragma once #error This header file should only be included from AudioFlinger.h #endif namespace android { class DeviceEffectManagerCallback; // DeviceEffectManager is concealed within AudioFlinger, their lifetimes are the same. // DeviceEffectManager is concealed within AudioFlinger, their lifetimes are the same. class DeviceEffectManager : public PatchCommandThread::PatchCommandListener { class DeviceEffectManager : public PatchCommandThread::PatchCommandListener { public: public: explicit DeviceEffectManager(AudioFlinger& audioFlinger) explicit DeviceEffectManager(AudioFlinger& audioFlinger); : mAudioFlinger(audioFlinger), mMyCallback(new DeviceEffectManagerCallback(*this)) {} void onFirstRef() override { void onFirstRef() override; mAudioFlinger.mPatchCommandThread->addListener(this); } sp<IAfEffectHandle> createEffect_l(effect_descriptor_t *descriptor, sp<IAfEffectHandle> createEffect_l(effect_descriptor_t *descriptor, const AudioDeviceTypeAddr& device, const AudioDeviceTypeAddr& device, Loading @@ -45,13 +43,9 @@ public: int32_t sessionId, int32_t deviceId, int32_t sessionId, int32_t deviceId, sp<EffectHalInterface> *effect); sp<EffectHalInterface> *effect); status_t addEffectToHal(const struct audio_port_config *device, status_t addEffectToHal(const struct audio_port_config *device, const sp<EffectHalInterface>& effect) { const sp<EffectHalInterface>& effect); return mAudioFlinger.addEffectToHal(device, effect); }; status_t removeEffectFromHal(const struct audio_port_config *device, status_t removeEffectFromHal(const struct audio_port_config *device, const sp<EffectHalInterface>& effect) { const sp<EffectHalInterface>& effect); return mAudioFlinger.removeEffectFromHal(device, effect); }; AudioFlinger& audioFlinger() const { return mAudioFlinger; } AudioFlinger& audioFlinger() const { return mAudioFlinger; } Loading @@ -60,8 +54,8 @@ public: // PatchCommandThread::PatchCommandListener implementation // PatchCommandThread::PatchCommandListener implementation void onCreateAudioPatch(audio_patch_handle_t handle, void onCreateAudioPatch(audio_patch_handle_t handle, const IAfPatchPanel::Patch& patch) override; const IAfPatchPanel::Patch& patch) final; void onReleaseAudioPatch(audio_patch_handle_t handle) override; void onReleaseAudioPatch(audio_patch_handle_t handle) final; private: private: status_t checkEffectCompatibility(const effect_descriptor_t *desc); status_t checkEffectCompatibility(const effect_descriptor_t *desc); Loading @@ -72,7 +66,6 @@ private: std::map<AudioDeviceTypeAddr, sp<IAfDeviceEffectProxy>> mDeviceEffects; std::map<AudioDeviceTypeAddr, sp<IAfDeviceEffectProxy>> mDeviceEffects; }; }; public: // TODO(b/288339104) extract inner class. class DeviceEffectManagerCallback : public EffectCallbackInterface { class DeviceEffectManagerCallback : public EffectCallbackInterface { public: public: explicit DeviceEffectManagerCallback(DeviceEffectManager& manager) explicit DeviceEffectManagerCallback(DeviceEffectManager& manager) Loading Loading @@ -129,11 +122,9 @@ public: wp<IAfEffectChain> chain() const override { return nullptr; } wp<IAfEffectChain> chain() const override { return nullptr; } bool isAudioPolicyReady() const override { bool isAudioPolicyReady() const final; return mManager.audioFlinger().isAudioPolicyReady(); } int newEffectId() { return mManager.audioFlinger().nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT); } int newEffectId() const; status_t addEffectToHal(const struct audio_port_config *device, status_t addEffectToHal(const struct audio_port_config *device, const sp<EffectHalInterface>& effect) { const sp<EffectHalInterface>& effect) { Loading @@ -146,4 +137,5 @@ public: private: private: DeviceEffectManager& mManager; DeviceEffectManager& mManager; }; }; private: } // namespace android
services/audioflinger/Effects.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -3257,11 +3257,11 @@ int32_t EffectChain::EffectCallback::activeTrackCnt() const { /* static */ /* static */ sp<IAfDeviceEffectProxy> IAfDeviceEffectProxy::create( sp<IAfDeviceEffectProxy> IAfDeviceEffectProxy::create( const AudioDeviceTypeAddr& device, const AudioDeviceTypeAddr& device, const sp</* DeviceEffectManagerCallback */ RefBase>& callback, // TODO(b/288339104) type const sp<DeviceEffectManagerCallback>& callback, effect_descriptor_t *desc, int id, bool notifyFramesProcessed) effect_descriptor_t *desc, int id, bool notifyFramesProcessed) { { return sp<DeviceEffectProxy>::make(device, return sp<DeviceEffectProxy>::make(device, sp<AudioFlinger::DeviceEffectManagerCallback>::cast(callback), callback, desc, id, notifyFramesProcessed); desc, id, notifyFramesProcessed); } } Loading
services/audioflinger/Effects.h +4 −4 Original line number Original line Diff line number Diff line Loading @@ -646,7 +646,7 @@ private: class DeviceEffectProxy : public IAfDeviceEffectProxy, public EffectBase { class DeviceEffectProxy : public IAfDeviceEffectProxy, public EffectBase { public: public: DeviceEffectProxy(const AudioDeviceTypeAddr& device, DeviceEffectProxy(const AudioDeviceTypeAddr& device, const sp<AudioFlinger::DeviceEffectManagerCallback>& callback, const sp<DeviceEffectManagerCallback>& callback, effect_descriptor_t *desc, int id, bool notifyFramesProcessed) effect_descriptor_t *desc, int id, bool notifyFramesProcessed) : EffectBase(callback, desc, id, AUDIO_SESSION_DEVICE, false), : EffectBase(callback, desc, id, AUDIO_SESSION_DEVICE, false), mDevice(device), mManagerCallback(callback), mDevice(device), mManagerCallback(callback), Loading Loading @@ -684,7 +684,7 @@ private: // Note: ctors taking a weak pointer to their owner must not promote it // Note: ctors taking a weak pointer to their owner must not promote it // during construction (but may keep a reference for later promotion). // during construction (but may keep a reference for later promotion). ProxyCallback(const wp<DeviceEffectProxy>& owner, ProxyCallback(const wp<DeviceEffectProxy>& owner, const sp<AudioFlinger::DeviceEffectManagerCallback>& callback) const sp<DeviceEffectManagerCallback>& callback) : mProxy(owner), mManagerCallback(callback) {} : mProxy(owner), mManagerCallback(callback) {} status_t createEffectHal(const effect_uuid_t *pEffectUuid, status_t createEffectHal(const effect_uuid_t *pEffectUuid, Loading Loading @@ -735,14 +735,14 @@ private: private: private: const wp<DeviceEffectProxy> mProxy; const wp<DeviceEffectProxy> mProxy; const sp<AudioFlinger::DeviceEffectManagerCallback> mManagerCallback; const sp<DeviceEffectManagerCallback> mManagerCallback; }; }; status_t checkPort(const IAfPatchPanel::Patch& patch, status_t checkPort(const IAfPatchPanel::Patch& patch, const struct audio_port_config *port, sp<IAfEffectHandle> *handle); const struct audio_port_config *port, sp<IAfEffectHandle> *handle); const AudioDeviceTypeAddr mDevice; const AudioDeviceTypeAddr mDevice; const sp<AudioFlinger::DeviceEffectManagerCallback> mManagerCallback; const sp<DeviceEffectManagerCallback> mManagerCallback; const sp<ProxyCallback> mMyCallback; const sp<ProxyCallback> mMyCallback; mutable Mutex mProxyLock; mutable Mutex mProxyLock; Loading