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

Commit c5fcd06e authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "audio policy: clarify tag and name for device description"

parents 8df0533d 1d4481fb
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -90,8 +90,7 @@ public:
    {
        mDefaultOutputDevices = new DeviceDescriptor(AUDIO_DEVICE_OUT_SPEAKER);
        sp<HwModule> module;
        sp<DeviceDescriptor> defaultInputDevice =
                        new DeviceDescriptor(AUDIO_DEVICE_IN_BUILTIN_MIC);
        sp<DeviceDescriptor> defaultInputDevice = new DeviceDescriptor(AUDIO_DEVICE_IN_BUILTIN_MIC);
        mAvailableOutputDevices.add(mDefaultOutputDevices);
        mAvailableInputDevices.add(defaultInputDevice);

+2 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public:

    virtual ~AudioPort() {}

    void setName(const String8 &name) { mName = name; }
    const String8 &getName() const { return mName; }

    audio_port_type_t getType() const { return mType; }
@@ -107,7 +108,6 @@ public:
    void dump(int fd, int spaces) const;
    void log(const char* indent) const;

    String8           mName;
    // by convention, "0' in the first entry in mSamplingRates, mChannelMasks or mFormats
    // indicates the supported parameters should be read from the output stream
    // after it is opened for the first time
@@ -118,6 +118,7 @@ public:
    sp<HwModule> mModule;                 // audio HW module exposing this I/O stream

private:
    String8           mName;
    audio_port_type_t mType;
    audio_port_role_t mRole;
    uint32_t mFlags; // attribute flags mask (e.g primary output, direct output...).
+5 −3
Original line number Diff line number Diff line
@@ -29,11 +29,13 @@ namespace android {
class DeviceDescriptor : public AudioPort, public AudioPortConfig
{
public:
    DeviceDescriptor(audio_devices_t type);
     // Note that empty name refers by convention to a generic device.
    DeviceDescriptor(audio_devices_t type, const String8 &tagName = String8(""));

    virtual ~DeviceDescriptor() {}

    audio_devices_t type() const { return mDeviceType; }
    const String8 getTagName() const { return mTagName; }

    bool equals(const sp<DeviceDescriptor>& other) const;

@@ -51,10 +53,10 @@ public:
    status_t dump(int fd, int spaces, int index) const;
    void log() const;

    String8 mTag;
    String8 mAddress;

private:
    String8 mTagName;
    audio_devices_t     mDeviceType;
    audio_port_handle_t mId;

@@ -76,7 +78,7 @@ public:
    sp<DeviceDescriptor> getDevice(audio_devices_t type, String8 address) const;
    DeviceVector getDevicesFromType(audio_devices_t types) const;
    sp<DeviceDescriptor> getDeviceFromId(audio_port_handle_t id) const;
    sp<DeviceDescriptor> getDeviceFromTag(const String8& tag) const;
    sp<DeviceDescriptor> getDeviceFromTagName(const String8 &tagName) const;
    DeviceVector getDevicesFromTypeAddr(audio_devices_t type, String8 address) const;

    audio_devices_t getDevicesFromHwModule(audio_module_handle_t moduleHandle) const;
+4 −9
Original line number Diff line number Diff line
@@ -127,8 +127,7 @@ status_t ConfigParsingUtils::loadHwModuleDevice(cnode *root, DeviceVector &devic
        ALOGW("loadDevice() bad type %08x", type);
        return BAD_VALUE;
    }
    sp<DeviceDescriptor> deviceDesc = new DeviceDescriptor(type);
    deviceDesc->mTag = String8(root->name);
    sp<DeviceDescriptor> deviceDesc = new DeviceDescriptor(type, String8(root->name));

    node = root->first_child;
    while (node) {
@@ -146,8 +145,8 @@ status_t ConfigParsingUtils::loadHwModuleDevice(cnode *root, DeviceVector &devic
        node = node->next;
    }

    ALOGV("loadDevice() adding device tag %s type %08x address %s",
          deviceDesc->mTag.string(), type, deviceDesc->mAddress.string());
    ALOGV("loadDevice() adding device tag (literal type) %s type %08x address %s",
          deviceDesc->getTagName().string(), type, deviceDesc->mAddress.string());

    devices.add(deviceDesc);
    return NO_ERROR;
@@ -323,14 +322,10 @@ void ConfigParsingUtils::loadDevicesFromTag(const char *tag, DeviceVector &devic
            audio_devices_t type;
            if (DeviceConverter::fromString(devTag, type)) {
                sp<DeviceDescriptor> dev = new DeviceDescriptor(type);
                if (type == AUDIO_DEVICE_IN_REMOTE_SUBMIX ||
                        type == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ) {
                    dev->mAddress = String8("0");
                }
                devices.add(dev);
            } else {
                sp<DeviceDescriptor> deviceDesc =
                        declaredDevices.getDeviceFromTag(String8(devTag));
                        declaredDevices.getDeviceFromTagName(String8(devTag));
                if (deviceDesc != 0) {
                    devices.add(deviceDesc);
                }
+7 −6
Original line number Diff line number Diff line
@@ -24,13 +24,15 @@

namespace android {

DeviceDescriptor::DeviceDescriptor(audio_devices_t type) :
DeviceDescriptor::DeviceDescriptor(audio_devices_t type, const String8 &tagName) :
    AudioPort(String8(""), AUDIO_PORT_TYPE_DEVICE,
              audio_is_output_device(type) ? AUDIO_PORT_ROLE_SINK :
                                             AUDIO_PORT_ROLE_SOURCE),
    mTag(""), mAddress(""), mDeviceType(type), mId(0)
    mAddress(""), mTagName(tagName), mDeviceType(type), mId(0)
{

    if (type == AUDIO_DEVICE_IN_REMOTE_SUBMIX || type == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ) {
        mAddress = String8("0");
    }
}

audio_port_handle_t DeviceDescriptor::getId() const
@@ -193,11 +195,11 @@ DeviceVector DeviceVector::getDevicesFromTypeAddr(
    return devices;
}

sp<DeviceDescriptor> DeviceVector::getDeviceFromTag(const String8& tag) const
sp<DeviceDescriptor> DeviceVector::getDeviceFromTagName(const String8 &tagName) const
{
    sp<DeviceDescriptor> device;
    for (size_t i = 0; i < size(); i++) {
        if (itemAt(i)->mTag == tag) {
        if (itemAt(i)->getTagName() == tagName) {
            device = itemAt(i);
            break;
        }
@@ -205,7 +207,6 @@ sp<DeviceDescriptor> DeviceVector::getDeviceFromTag(const String8& tag) const
    return device;
}


status_t DeviceVector::dump(int fd, const String8 &direction) const
{
    const size_t SIZE = 256;
Loading