Loading services/audiopolicy/engine/common/include/EngineBase.h +26 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,10 @@ public: DeviceVector getActiveMediaDevices(const DeviceVector& availableDevices) const override; void initializeDeviceSelectionCache() override; void updateDeviceSelectionCache() override; private: /** * Get media devices as the given role Loading Loading @@ -193,6 +197,28 @@ private: /** current forced use configuration. */ audio_policy_forced_cfg_t mForceUse[AUDIO_POLICY_FORCE_USE_CNT] = {}; protected: /** * Set the device information for a given strategy. * * @param strategy the strategy to set devices information * @param devices the devices selected for the strategy */ virtual void setStrategyDevices(const sp<ProductStrategy>& /*strategy*/, const DeviceVector& /*devices*/) { // In EngineBase, do nothing. It is up to the actual engine to decide if it is needed to // set devices information for the given strategy. } /** * Get devices that will be used for the given product strategy. * * @param strategy the strategy to query */ virtual DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const = 0; DeviceStrategyMap mDevicesForStrategies; }; } // namespace audio_policy Loading services/audiopolicy/engine/common/src/EngineBase.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -685,6 +685,26 @@ DeviceVector EngineBase::getActiveMediaDevices(const DeviceVector& availableDevi return activeDevices; } void EngineBase::initializeDeviceSelectionCache() { // Initializing the device selection cache with default device won't be harmful, it will be // updated after the audio modules are initialized. auto defaultDevices = DeviceVector(getApmObserver()->getDefaultOutputDevice()); for (const auto &iter : getProductStrategies()) { const auto &strategy = iter.second; mDevicesForStrategies[strategy->getId()] = defaultDevices; setStrategyDevices(strategy, defaultDevices); } } void EngineBase::updateDeviceSelectionCache() { for (const auto &iter : getProductStrategies()) { const auto& strategy = iter.second; auto devices = getDevicesForProductStrategy(strategy->getId()); mDevicesForStrategies[strategy->getId()] = devices; setStrategyDevices(strategy, devices); } } void EngineBase::dumpCapturePresetDevicesRoleMap(String8 *dst, int spaces) const { dst->appendFormat("\n%*sDevice role per capture preset dump:", spaces, ""); Loading services/audiopolicy/engine/interface/EngineInterface.h +10 −0 Original line number Diff line number Diff line Loading @@ -434,6 +434,16 @@ public: */ virtual DeviceVector getActiveMediaDevices(const DeviceVector& availableDevices) const = 0; /** * @brief initializeDeviceSelectionCache. Device selection for AudioAttribute / Streams is * cached in the engine in order to speed up process when the audio system is stable. When the * audio system is initializing, not all audio devices information will be available. In that * case, calling this function can allow the engine to initialize the device selection cache * with default values. * This must only be called when audio policy manager is initializing. */ virtual void initializeDeviceSelectionCache() = 0; virtual void dump(String8 *dst) const = 0; protected: Loading services/audiopolicy/engineconfigurable/src/Engine.cpp +0 −8 Original line number Diff line number Diff line Loading @@ -356,14 +356,6 @@ sp<DeviceDescriptor> Engine::getInputDeviceForAttributes(const audio_attributes_ return availableInputDevices.getDevice(deviceType, String8(address.c_str()), AUDIO_FORMAT_DEFAULT); } void Engine::updateDeviceSelectionCache() { for (const auto &iter : getProductStrategies()) { const auto &strategy = iter.second; mDevicesForStrategies[strategy->getId()] = getDevicesForProductStrategy(strategy->getId()); } } void Engine::setDeviceAddressForProductStrategy(product_strategy_t strategy, const std::string &address) { Loading services/audiopolicy/engineconfigurable/src/Engine.h +5 −5 Original line number Diff line number Diff line Loading @@ -67,8 +67,6 @@ public: sp<AudioPolicyMix> *mix = nullptr) const override; void updateDeviceSelectionCache() override; /// /// from AudioPolicyPluginInterface /// Loading Loading @@ -123,15 +121,17 @@ private: status_t loadAudioPolicyEngineConfig(); DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const; DeviceVector getCachedDevices(product_strategy_t ps) const; /// /// from EngineBase /// DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const override; /** * Policy Parameter Manager hidden through a wrapper. */ ParameterManagerWrapper *mPolicyParameterMgr; DeviceStrategyMap mDevicesForStrategies; }; } // namespace audio_policy Loading Loading
services/audiopolicy/engine/common/include/EngineBase.h +26 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,10 @@ public: DeviceVector getActiveMediaDevices(const DeviceVector& availableDevices) const override; void initializeDeviceSelectionCache() override; void updateDeviceSelectionCache() override; private: /** * Get media devices as the given role Loading Loading @@ -193,6 +197,28 @@ private: /** current forced use configuration. */ audio_policy_forced_cfg_t mForceUse[AUDIO_POLICY_FORCE_USE_CNT] = {}; protected: /** * Set the device information for a given strategy. * * @param strategy the strategy to set devices information * @param devices the devices selected for the strategy */ virtual void setStrategyDevices(const sp<ProductStrategy>& /*strategy*/, const DeviceVector& /*devices*/) { // In EngineBase, do nothing. It is up to the actual engine to decide if it is needed to // set devices information for the given strategy. } /** * Get devices that will be used for the given product strategy. * * @param strategy the strategy to query */ virtual DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const = 0; DeviceStrategyMap mDevicesForStrategies; }; } // namespace audio_policy Loading
services/audiopolicy/engine/common/src/EngineBase.cpp +20 −0 Original line number Diff line number Diff line Loading @@ -685,6 +685,26 @@ DeviceVector EngineBase::getActiveMediaDevices(const DeviceVector& availableDevi return activeDevices; } void EngineBase::initializeDeviceSelectionCache() { // Initializing the device selection cache with default device won't be harmful, it will be // updated after the audio modules are initialized. auto defaultDevices = DeviceVector(getApmObserver()->getDefaultOutputDevice()); for (const auto &iter : getProductStrategies()) { const auto &strategy = iter.second; mDevicesForStrategies[strategy->getId()] = defaultDevices; setStrategyDevices(strategy, defaultDevices); } } void EngineBase::updateDeviceSelectionCache() { for (const auto &iter : getProductStrategies()) { const auto& strategy = iter.second; auto devices = getDevicesForProductStrategy(strategy->getId()); mDevicesForStrategies[strategy->getId()] = devices; setStrategyDevices(strategy, devices); } } void EngineBase::dumpCapturePresetDevicesRoleMap(String8 *dst, int spaces) const { dst->appendFormat("\n%*sDevice role per capture preset dump:", spaces, ""); Loading
services/audiopolicy/engine/interface/EngineInterface.h +10 −0 Original line number Diff line number Diff line Loading @@ -434,6 +434,16 @@ public: */ virtual DeviceVector getActiveMediaDevices(const DeviceVector& availableDevices) const = 0; /** * @brief initializeDeviceSelectionCache. Device selection for AudioAttribute / Streams is * cached in the engine in order to speed up process when the audio system is stable. When the * audio system is initializing, not all audio devices information will be available. In that * case, calling this function can allow the engine to initialize the device selection cache * with default values. * This must only be called when audio policy manager is initializing. */ virtual void initializeDeviceSelectionCache() = 0; virtual void dump(String8 *dst) const = 0; protected: Loading
services/audiopolicy/engineconfigurable/src/Engine.cpp +0 −8 Original line number Diff line number Diff line Loading @@ -356,14 +356,6 @@ sp<DeviceDescriptor> Engine::getInputDeviceForAttributes(const audio_attributes_ return availableInputDevices.getDevice(deviceType, String8(address.c_str()), AUDIO_FORMAT_DEFAULT); } void Engine::updateDeviceSelectionCache() { for (const auto &iter : getProductStrategies()) { const auto &strategy = iter.second; mDevicesForStrategies[strategy->getId()] = getDevicesForProductStrategy(strategy->getId()); } } void Engine::setDeviceAddressForProductStrategy(product_strategy_t strategy, const std::string &address) { Loading
services/audiopolicy/engineconfigurable/src/Engine.h +5 −5 Original line number Diff line number Diff line Loading @@ -67,8 +67,6 @@ public: sp<AudioPolicyMix> *mix = nullptr) const override; void updateDeviceSelectionCache() override; /// /// from AudioPolicyPluginInterface /// Loading Loading @@ -123,15 +121,17 @@ private: status_t loadAudioPolicyEngineConfig(); DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const; DeviceVector getCachedDevices(product_strategy_t ps) const; /// /// from EngineBase /// DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const override; /** * Policy Parameter Manager hidden through a wrapper. */ ParameterManagerWrapper *mPolicyParameterMgr; DeviceStrategyMap mDevicesForStrategies; }; } // namespace audio_policy Loading