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

Commit d4d55cdf authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Merge "Updates to AudioPolicyManager refactor"

parents da2246b5 887a9ed4
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -54,6 +54,8 @@ public:


private:
private:
    audio_devices_t mDeviceType;
    audio_devices_t mDeviceType;

friend class DeviceVector;
};
};


class DeviceVector : public SortedVector< sp<DeviceDescriptor> >
class DeviceVector : public SortedVector< sp<DeviceDescriptor> >
+4 −3
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


#pragma once
#pragma once



/////////////////////////////////////////////////
/////////////////////////////////////////////////
//      Definitions for audio policy configuration file (audio_policy.conf)
//      Definitions for audio policy configuration file (audio_policy.conf)
/////////////////////////////////////////////////
/////////////////////////////////////////////////
@@ -50,9 +51,9 @@
                                    // "formats" in outputs descriptors indicating that supported
                                    // "formats" in outputs descriptors indicating that supported
                                    // values should be queried after opening the output.
                                    // values should be queried after opening the output.


#define DEVICES_TAG "devices"
#define APM_DEVICES_TAG "devices"
#define DEVICE_TYPE "type"
#define APM_DEVICE_TYPE "type"
#define DEVICE_ADDRESS "address"
#define APM_DEVICE_ADDRESS "address"


#define MIXERS_TAG "mixers"
#define MIXERS_TAG "mixers"
#define MIXER_TYPE "type"
#define MIXER_TYPE "type"
+2 −2
Original line number Original line Diff line number Diff line
@@ -142,7 +142,7 @@ status_t HwModule::loadDevice(cnode *root)


    audio_devices_t type = AUDIO_DEVICE_NONE;
    audio_devices_t type = AUDIO_DEVICE_NONE;
    while (node) {
    while (node) {
        if (strcmp(node->name, DEVICE_TYPE) == 0) {
        if (strcmp(node->name, APM_DEVICE_TYPE) == 0) {
            type = ConfigParsingUtils::parseDeviceNames((char *)node->value);
            type = ConfigParsingUtils::parseDeviceNames((char *)node->value);
            break;
            break;
        }
        }
@@ -158,7 +158,7 @@ status_t HwModule::loadDevice(cnode *root)


    node = root->first_child;
    node = root->first_child;
    while (node) {
    while (node) {
        if (strcmp(node->name, DEVICE_ADDRESS) == 0) {
        if (strcmp(node->name, APM_DEVICE_ADDRESS) == 0) {
            deviceDesc->mAddress = String8((char *)node->value);
            deviceDesc->mAddress = String8((char *)node->value);
        } else if (strcmp(node->name, CHANNELS_TAG) == 0) {
        } else if (strcmp(node->name, CHANNELS_TAG) == 0) {
            if (audio_is_input_device(type)) {
            if (audio_is_input_device(type)) {
+4 −0
Original line number Original line Diff line number Diff line
@@ -521,6 +521,10 @@ void AudioPolicyManager::setPhoneState(audio_mode_t state)
    }
    }
}
}


audio_mode_t AudioPolicyManager::getPhoneState() {
    return mEngine->getPhoneState();
}

void AudioPolicyManager::setForceUse(audio_policy_force_use_t usage,
void AudioPolicyManager::setForceUse(audio_policy_force_use_t usage,
                                         audio_policy_forced_cfg_t config)
                                         audio_policy_forced_cfg_t config)
{
{
+9 −8
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@
#include <media/AudioPolicy.h>
#include <media/AudioPolicy.h>
#include "AudioPolicyInterface.h"
#include "AudioPolicyInterface.h"


#include <AudioPolicyManagerInterface.h>
#include <AudioPolicyManagerObserver.h>
#include <AudioPolicyManagerObserver.h>
#include <AudioGain.h>
#include <AudioGain.h>
#include <AudioPort.h>
#include <AudioPort.h>
@@ -44,8 +45,6 @@


namespace android {
namespace android {


class AudioPolicyManagerInterface;

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


// Attenuation applied to STRATEGY_SONIFICATION streams when a headset is connected: 6dB
// Attenuation applied to STRATEGY_SONIFICATION streams when a headset is connected: 6dB
@@ -284,6 +283,9 @@ protected:
        virtual audio_devices_t getDeviceForStrategy(routing_strategy strategy,
        virtual audio_devices_t getDeviceForStrategy(routing_strategy strategy,
                                                     bool fromCache);
                                                     bool fromCache);


        bool isStrategyActive(const sp<AudioOutputDescriptor> outputDesc, routing_strategy strategy,
                              uint32_t inPastMs = 0, nsecs_t sysTime = 0) const;

        // change the route of the specified output. Returns the number of ms we have slept to
        // change the route of the specified output. Returns the number of ms we have slept to
        // allow new routing to take effect in certain cases.
        // allow new routing to take effect in certain cases.
        virtual uint32_t setOutputDevice(audio_io_handle_t output,
        virtual uint32_t setOutputDevice(audio_io_handle_t output,
@@ -337,6 +339,8 @@ protected:
        // a special tone in the device used for communication
        // a special tone in the device used for communication
        void handleIncallSonification(audio_stream_type_t stream, bool starting, bool stateChange);
        void handleIncallSonification(audio_stream_type_t stream, bool starting, bool stateChange);


        audio_mode_t getPhoneState();

        // true if device is in a telephony or VoIP call
        // true if device is in a telephony or VoIP call
        virtual bool isInCall();
        virtual bool isInCall();
        // true if given state represents a device in a telephony or VoIP call
        // true if given state represents a device in a telephony or VoIP call
@@ -523,6 +527,9 @@ protected:
#endif //AUDIO_POLICY_TEST
#endif //AUDIO_POLICY_TEST


        uint32_t nextAudioPortGeneration();
        uint32_t nextAudioPortGeneration();

        // Audio Policy Engine Interface.
        AudioPolicyManagerInterface *mEngine;
private:
private:
        // updates device caching and output for streams that can influence the
        // updates device caching and output for streams that can influence the
        //    routing of notifications
        //    routing of notifications
@@ -566,12 +573,6 @@ private:
                                                          audio_policy_dev_state_t state,
                                                          audio_policy_dev_state_t state,
                                                          const char *device_address,
                                                          const char *device_address,
                                                          const char *device_name);
                                                          const char *device_name);

        bool isStrategyActive(const sp<AudioOutputDescriptor> outputDesc, routing_strategy strategy,
                              uint32_t inPastMs = 0, nsecs_t sysTime = 0) const;

        // Audio Policy Engine Interface.
        AudioPolicyManagerInterface *mEngine;
};
};


};
};