Loading services/audioflinger/AudioFlinger.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -329,7 +329,6 @@ AudioFlinger::AudioFlinger() mClientSharedHeapSize(kMinimumClientSharedHeapSizeBytes), mGlobalEffectEnableTime(0), mPatchCommandThread(sp<PatchCommandThread>::make()), mDeviceEffectManager(sp<DeviceEffectManager>::make(*this)), mMelReporter(sp<MelReporter>::make(*this)), mSystemReady(false), mBluetoothLatencyModesEnabled(true) Loading Loading @@ -404,7 +403,8 @@ void AudioFlinger::onFirstRef() mMode = AUDIO_MODE_NORMAL; gAudioFlinger = this; // we are already refcounted, store into atomic pointer. mDeviceEffectManager = sp<DeviceEffectManager>::make( sp<IAfDeviceEffectManagerCallback>::fromExisting(this)), mDevicesFactoryHalCallback = new DevicesFactoryHalCallbackImpl; mDevicesFactoryHal->setCallbackOnce(mDevicesFactoryHalCallback); Loading services/audioflinger/AudioFlinger.h +14 −10 Original line number Diff line number Diff line Loading @@ -165,11 +165,10 @@ struct stream_type_t { class AudioFlinger : public AudioFlingerServerAdapter::Delegate // IAudioFlinger client interface , public IAfClientCallback , public IAfDeviceEffectManagerCallback { friend class sp<AudioFlinger>; // TODO(b/291319167) Create interface and remove friends. friend class DeviceEffectManager; friend class DeviceEffectManagerCallback; friend class MelReporter; friend class PatchPanel; // TODO(b/291012167) replace the Thread friends with an interface. Loading Loading @@ -373,7 +372,16 @@ public: // ---- end of IAfClientCallback interface bool isAudioPolicyReady() const { return mAudioPolicyReady.load(); } // ---- begin IAfDeviceEffectManagerCallback interface bool isAudioPolicyReady() const final { return mAudioPolicyReady.load(); } const sp<PatchCommandThread>& getPatchCommandThread() final { return mPatchCommandThread; } status_t addEffectToHal( const struct audio_port_config* device, const sp<EffectHalInterface>& effect) final; status_t removeEffectFromHal( const struct audio_port_config* device, const sp<EffectHalInterface>& effect) final; // ---- end of IAfDeviceEffectManagerCallback interface /* List available audio ports and their attributes */ status_t listAudioPorts(unsigned int* num_ports, struct audio_port* ports) const; Loading @@ -396,11 +404,6 @@ public: const sp<os::ExternalVibration>& externalVibration); static void onExternalVibrationStop(const sp<os::ExternalVibration>& externalVibration); status_t addEffectToHal( const struct audio_port_config *device, const sp<EffectHalInterface>& effect); status_t removeEffectFromHal( const struct audio_port_config *device, const sp<EffectHalInterface>& effect); void updateDownStreamPatches_l(const struct audio_patch *patch, const std::set<audio_io_handle_t>& streams); Loading Loading @@ -665,7 +668,8 @@ private: // Thus it may fail by returning an ID of the wrong sign, // or by returning a non-unique ID. // This is the internal API. For the binder API see newAudioUniqueId(). audio_unique_id_t nextUniqueId(audio_unique_id_use_t use); // used by IAfDeviceEffectManagerCallback audio_unique_id_t nextUniqueId(audio_unique_id_use_t use) final; status_t moveEffectChain_l(audio_session_t sessionId, IAfPlaybackThread* srcThread, IAfPlaybackThread* dstThread); Loading Loading @@ -871,7 +875,7 @@ public: private: const sp<PatchCommandThread> mPatchCommandThread; sp<DeviceEffectManager> mDeviceEffectManager; /* const */ sp<DeviceEffectManager> mDeviceEffectManager; // set onFirstRef sp<MelReporter> mMelReporter; bool mSystemReady; Loading services/audioflinger/DeviceEffectManager.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -34,22 +34,23 @@ namespace android { using detail::AudioHalVersionInfo; using media::IEffectClient; DeviceEffectManager::DeviceEffectManager(AudioFlinger& audioFlinger) : mAudioFlinger(audioFlinger), DeviceEffectManager::DeviceEffectManager( const sp<IAfDeviceEffectManagerCallback>& afDeviceEffectManagerCallback) : mAfDeviceEffectManagerCallback(afDeviceEffectManagerCallback), mMyCallback(new DeviceEffectManagerCallback(*this)) {} void DeviceEffectManager::onFirstRef() { mAudioFlinger.mPatchCommandThread->addListener(this); mAfDeviceEffectManagerCallback->getPatchCommandThread()->addListener(this); } status_t DeviceEffectManager::addEffectToHal(const struct audio_port_config* device, const sp<EffectHalInterface>& effect) { return mAudioFlinger.addEffectToHal(device, effect); return mAfDeviceEffectManagerCallback->addEffectToHal(device, effect); }; status_t DeviceEffectManager::removeEffectFromHal(const struct audio_port_config* device, const sp<EffectHalInterface>& effect) { return mAudioFlinger.removeEffectFromHal(device, effect); return mAfDeviceEffectManagerCallback->removeEffectFromHal(device, effect); }; void DeviceEffectManager::onCreateAudioPatch(audio_patch_handle_t handle, Loading Loading @@ -101,7 +102,8 @@ sp<IAfEffectHandle> DeviceEffectManager::createEffect_l( effect = iter->second; } else { effect = IAfDeviceEffectProxy::create(device, mMyCallback, descriptor, mAudioFlinger.nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT), descriptor, mAfDeviceEffectManagerCallback->nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT), notifyFramesProcessed); } // create effect handle and connect it to effect module Loading Loading @@ -221,11 +223,11 @@ bool DeviceEffectManagerCallback::disconnectEffectHandle( } bool DeviceEffectManagerCallback::isAudioPolicyReady() const { return mManager.audioFlinger().isAudioPolicyReady(); return mManager.afDeviceEffectManagerCallback()->isAudioPolicyReady(); } int DeviceEffectManagerCallback::newEffectId() const { return mManager.audioFlinger().nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT); return mManager.afDeviceEffectManagerCallback()->nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT); } } // namespace android services/audioflinger/DeviceEffectManager.h +15 −3 Original line number Diff line number Diff line Loading @@ -19,12 +19,24 @@ namespace android { class IAfDeviceEffectManagerCallback : public virtual RefBase { public: virtual bool isAudioPolicyReady() const = 0; virtual audio_unique_id_t nextUniqueId(audio_unique_id_use_t use) = 0; virtual const sp<PatchCommandThread>& getPatchCommandThread() = 0; virtual status_t addEffectToHal( const struct audio_port_config* device, const sp<EffectHalInterface>& effect) = 0; virtual status_t removeEffectFromHal( const struct audio_port_config* device, const sp<EffectHalInterface>& effect) = 0; }; class DeviceEffectManagerCallback; // DeviceEffectManager is concealed within AudioFlinger, their lifetimes are the same. class DeviceEffectManager : public PatchCommandThread::PatchCommandListener { public: explicit DeviceEffectManager(AudioFlinger& audioFlinger); explicit DeviceEffectManager( const sp<IAfDeviceEffectManagerCallback>& afDeviceEffectManagerCallback); void onFirstRef() override; Loading @@ -47,7 +59,7 @@ public: status_t removeEffectFromHal(const struct audio_port_config *device, const sp<EffectHalInterface>& effect); AudioFlinger& audioFlinger() const { return mAudioFlinger; } const auto& afDeviceEffectManagerCallback() const { return mAfDeviceEffectManagerCallback; } void dump(int fd); Loading @@ -61,7 +73,7 @@ private: status_t checkEffectCompatibility(const effect_descriptor_t *desc); Mutex mLock; AudioFlinger &mAudioFlinger; const sp<IAfDeviceEffectManagerCallback> mAfDeviceEffectManagerCallback; const sp<DeviceEffectManagerCallback> mMyCallback; std::map<AudioDeviceTypeAddr, sp<IAfDeviceEffectProxy>> mDeviceEffects; }; Loading Loading
services/audioflinger/AudioFlinger.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -329,7 +329,6 @@ AudioFlinger::AudioFlinger() mClientSharedHeapSize(kMinimumClientSharedHeapSizeBytes), mGlobalEffectEnableTime(0), mPatchCommandThread(sp<PatchCommandThread>::make()), mDeviceEffectManager(sp<DeviceEffectManager>::make(*this)), mMelReporter(sp<MelReporter>::make(*this)), mSystemReady(false), mBluetoothLatencyModesEnabled(true) Loading Loading @@ -404,7 +403,8 @@ void AudioFlinger::onFirstRef() mMode = AUDIO_MODE_NORMAL; gAudioFlinger = this; // we are already refcounted, store into atomic pointer. mDeviceEffectManager = sp<DeviceEffectManager>::make( sp<IAfDeviceEffectManagerCallback>::fromExisting(this)), mDevicesFactoryHalCallback = new DevicesFactoryHalCallbackImpl; mDevicesFactoryHal->setCallbackOnce(mDevicesFactoryHalCallback); Loading
services/audioflinger/AudioFlinger.h +14 −10 Original line number Diff line number Diff line Loading @@ -165,11 +165,10 @@ struct stream_type_t { class AudioFlinger : public AudioFlingerServerAdapter::Delegate // IAudioFlinger client interface , public IAfClientCallback , public IAfDeviceEffectManagerCallback { friend class sp<AudioFlinger>; // TODO(b/291319167) Create interface and remove friends. friend class DeviceEffectManager; friend class DeviceEffectManagerCallback; friend class MelReporter; friend class PatchPanel; // TODO(b/291012167) replace the Thread friends with an interface. Loading Loading @@ -373,7 +372,16 @@ public: // ---- end of IAfClientCallback interface bool isAudioPolicyReady() const { return mAudioPolicyReady.load(); } // ---- begin IAfDeviceEffectManagerCallback interface bool isAudioPolicyReady() const final { return mAudioPolicyReady.load(); } const sp<PatchCommandThread>& getPatchCommandThread() final { return mPatchCommandThread; } status_t addEffectToHal( const struct audio_port_config* device, const sp<EffectHalInterface>& effect) final; status_t removeEffectFromHal( const struct audio_port_config* device, const sp<EffectHalInterface>& effect) final; // ---- end of IAfDeviceEffectManagerCallback interface /* List available audio ports and their attributes */ status_t listAudioPorts(unsigned int* num_ports, struct audio_port* ports) const; Loading @@ -396,11 +404,6 @@ public: const sp<os::ExternalVibration>& externalVibration); static void onExternalVibrationStop(const sp<os::ExternalVibration>& externalVibration); status_t addEffectToHal( const struct audio_port_config *device, const sp<EffectHalInterface>& effect); status_t removeEffectFromHal( const struct audio_port_config *device, const sp<EffectHalInterface>& effect); void updateDownStreamPatches_l(const struct audio_patch *patch, const std::set<audio_io_handle_t>& streams); Loading Loading @@ -665,7 +668,8 @@ private: // Thus it may fail by returning an ID of the wrong sign, // or by returning a non-unique ID. // This is the internal API. For the binder API see newAudioUniqueId(). audio_unique_id_t nextUniqueId(audio_unique_id_use_t use); // used by IAfDeviceEffectManagerCallback audio_unique_id_t nextUniqueId(audio_unique_id_use_t use) final; status_t moveEffectChain_l(audio_session_t sessionId, IAfPlaybackThread* srcThread, IAfPlaybackThread* dstThread); Loading Loading @@ -871,7 +875,7 @@ public: private: const sp<PatchCommandThread> mPatchCommandThread; sp<DeviceEffectManager> mDeviceEffectManager; /* const */ sp<DeviceEffectManager> mDeviceEffectManager; // set onFirstRef sp<MelReporter> mMelReporter; bool mSystemReady; Loading
services/audioflinger/DeviceEffectManager.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -34,22 +34,23 @@ namespace android { using detail::AudioHalVersionInfo; using media::IEffectClient; DeviceEffectManager::DeviceEffectManager(AudioFlinger& audioFlinger) : mAudioFlinger(audioFlinger), DeviceEffectManager::DeviceEffectManager( const sp<IAfDeviceEffectManagerCallback>& afDeviceEffectManagerCallback) : mAfDeviceEffectManagerCallback(afDeviceEffectManagerCallback), mMyCallback(new DeviceEffectManagerCallback(*this)) {} void DeviceEffectManager::onFirstRef() { mAudioFlinger.mPatchCommandThread->addListener(this); mAfDeviceEffectManagerCallback->getPatchCommandThread()->addListener(this); } status_t DeviceEffectManager::addEffectToHal(const struct audio_port_config* device, const sp<EffectHalInterface>& effect) { return mAudioFlinger.addEffectToHal(device, effect); return mAfDeviceEffectManagerCallback->addEffectToHal(device, effect); }; status_t DeviceEffectManager::removeEffectFromHal(const struct audio_port_config* device, const sp<EffectHalInterface>& effect) { return mAudioFlinger.removeEffectFromHal(device, effect); return mAfDeviceEffectManagerCallback->removeEffectFromHal(device, effect); }; void DeviceEffectManager::onCreateAudioPatch(audio_patch_handle_t handle, Loading Loading @@ -101,7 +102,8 @@ sp<IAfEffectHandle> DeviceEffectManager::createEffect_l( effect = iter->second; } else { effect = IAfDeviceEffectProxy::create(device, mMyCallback, descriptor, mAudioFlinger.nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT), descriptor, mAfDeviceEffectManagerCallback->nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT), notifyFramesProcessed); } // create effect handle and connect it to effect module Loading Loading @@ -221,11 +223,11 @@ bool DeviceEffectManagerCallback::disconnectEffectHandle( } bool DeviceEffectManagerCallback::isAudioPolicyReady() const { return mManager.audioFlinger().isAudioPolicyReady(); return mManager.afDeviceEffectManagerCallback()->isAudioPolicyReady(); } int DeviceEffectManagerCallback::newEffectId() const { return mManager.audioFlinger().nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT); return mManager.afDeviceEffectManagerCallback()->nextUniqueId(AUDIO_UNIQUE_ID_USE_EFFECT); } } // namespace android
services/audioflinger/DeviceEffectManager.h +15 −3 Original line number Diff line number Diff line Loading @@ -19,12 +19,24 @@ namespace android { class IAfDeviceEffectManagerCallback : public virtual RefBase { public: virtual bool isAudioPolicyReady() const = 0; virtual audio_unique_id_t nextUniqueId(audio_unique_id_use_t use) = 0; virtual const sp<PatchCommandThread>& getPatchCommandThread() = 0; virtual status_t addEffectToHal( const struct audio_port_config* device, const sp<EffectHalInterface>& effect) = 0; virtual status_t removeEffectFromHal( const struct audio_port_config* device, const sp<EffectHalInterface>& effect) = 0; }; class DeviceEffectManagerCallback; // DeviceEffectManager is concealed within AudioFlinger, their lifetimes are the same. class DeviceEffectManager : public PatchCommandThread::PatchCommandListener { public: explicit DeviceEffectManager(AudioFlinger& audioFlinger); explicit DeviceEffectManager( const sp<IAfDeviceEffectManagerCallback>& afDeviceEffectManagerCallback); void onFirstRef() override; Loading @@ -47,7 +59,7 @@ public: status_t removeEffectFromHal(const struct audio_port_config *device, const sp<EffectHalInterface>& effect); AudioFlinger& audioFlinger() const { return mAudioFlinger; } const auto& afDeviceEffectManagerCallback() const { return mAfDeviceEffectManagerCallback; } void dump(int fd); Loading @@ -61,7 +73,7 @@ private: status_t checkEffectCompatibility(const effect_descriptor_t *desc); Mutex mLock; AudioFlinger &mAudioFlinger; const sp<IAfDeviceEffectManagerCallback> mAfDeviceEffectManagerCallback; const sp<DeviceEffectManagerCallback> mMyCallback; std::map<AudioDeviceTypeAddr, sp<IAfDeviceEffectProxy>> mDeviceEffects; }; Loading