Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8811815 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "APM: fix log spam from getDevicesForStrategyInt when booting devices." into udc-dev

parents 3f012a26 2923018b
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -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
@@ -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
+20 −0
Original line number Diff line number Diff line
@@ -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, "");
+10 −0
Original line number Diff line number Diff line
@@ -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:
+0 −8
Original line number Diff line number Diff line
@@ -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)
{
+5 −5
Original line number Diff line number Diff line
@@ -67,8 +67,6 @@ public:
                                                     sp<AudioPolicyMix> *mix = nullptr)
                                                     const override;

    void updateDeviceSelectionCache() override;

    ///
    /// from AudioPolicyPluginInterface
    ///
@@ -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