diff options
author | Eric Laurent <elaurent@google.com> | 2015-05-06 18:44:02 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2015-05-06 18:44:02 -0700 |
commit | 7288ab87a7aa730ffe97d7dc7e118123107bfcea (patch) | |
tree | c12aa50cbf887e27579bdf4bb79d170f51dcebf1 /services/audiopolicy/common/managerdefinitions/src | |
parent | 464c7e085b68dd63ce8cdbb2c389d3827f8d586a (diff) | |
download | frameworks_av-7288ab87a7aa730ffe97d7dc7e118123107bfcea.tar.gz frameworks_av-7288ab87a7aa730ffe97d7dc7e118123107bfcea.tar.bz2 frameworks_av-7288ab87a7aa730ffe97d7dc7e118123107bfcea.zip |
audio policy: clarify use of mName field for audio devices
The audio port field mName was used for two different purposes
which caused a problem when exposing this information at the SDK API.
Create a new "mTag" field storing the audio_policy.conf device tag
if needed.
Field "mName" is now used to store any additional name associated to
a given device when available (e.g Manufacturer and model name for a USB device).
Change-Id: I17fa872e4a3a2e1b7cbb807c6f72e095a8a2c9c5
Diffstat (limited to 'services/audiopolicy/common/managerdefinitions/src')
3 files changed, 27 insertions, 30 deletions
diff --git a/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp b/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp index 9ab1d61623..89ef0458e3 100644 --- a/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp @@ -218,7 +218,7 @@ void ConfigParsingUtils::loadGlobalConfig(cnode *root, const sp<HwModule>& modul node = node->first_child; while (node) { if (strcmp(ATTACHED_OUTPUT_DEVICES_TAG, node->name) == 0) { - availableOutputDevices.loadDevicesFromName((char *)node->value, + availableOutputDevices.loadDevicesFromTag((char *)node->value, declaredDevices); ALOGV("loadGlobalConfig() Attached Output Devices %08x", availableOutputDevices.types()); @@ -228,13 +228,13 @@ void ConfigParsingUtils::loadGlobalConfig(cnode *root, const sp<HwModule>& modul ARRAY_SIZE(sDeviceTypeToEnumTable), (char *)node->value); if (device != AUDIO_DEVICE_NONE) { - defaultOutputDevice = new DeviceDescriptor(String8("default-output"), device); + defaultOutputDevice = new DeviceDescriptor(device); } else { ALOGW("loadGlobalConfig() default device not specified"); } ALOGV("loadGlobalConfig() mDefaultOutputDevice %08x", defaultOutputDevice->type()); } else if (strcmp(ATTACHED_INPUT_DEVICES_TAG, node->name) == 0) { - availableInputDevices.loadDevicesFromName((char *)node->value, + availableInputDevices.loadDevicesFromTag((char *)node->value, declaredDevices); ALOGV("loadGlobalConfig() Available InputDevices %08x", availableInputDevices.types()); } else if (strcmp(SPEAKER_DRC_ENABLED_TAG, node->name) == 0) { diff --git a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp index 0715eea01c..797077ae38 100644 --- a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp @@ -24,13 +24,11 @@ namespace android { -String8 DeviceDescriptor::emptyNameStr = String8(""); - -DeviceDescriptor::DeviceDescriptor(const String8& name, audio_devices_t type) : - AudioPort(name, AUDIO_PORT_TYPE_DEVICE, +DeviceDescriptor::DeviceDescriptor(audio_devices_t type) : + AudioPort(String8(""), AUDIO_PORT_TYPE_DEVICE, audio_is_output_device(type) ? AUDIO_PORT_ROLE_SINK : AUDIO_PORT_ROLE_SOURCE), - mAddress(""), mDeviceType(type), mId(0) + mTag(""), mAddress(""), mDeviceType(type), mId(0) { } @@ -142,24 +140,21 @@ void DeviceVector::loadDevicesFromType(audio_devices_t types) uint32_t i = 31 - __builtin_clz(types); uint32_t type = 1 << i; types &= ~type; - add(new DeviceDescriptor(String8("device_type"), type | role_bit)); + add(new DeviceDescriptor(type | role_bit)); } } -void DeviceVector::loadDevicesFromName(char *name, +void DeviceVector::loadDevicesFromTag(char *tag, const DeviceVector& declaredDevices) { - char *devName = strtok(name, "|"); - while (devName != NULL) { - if (strlen(devName) != 0) { + char *devTag = strtok(tag, "|"); + while (devTag != NULL) { + if (strlen(devTag) != 0) { audio_devices_t type = ConfigParsingUtils::stringToEnum(sDeviceTypeToEnumTable, ARRAY_SIZE(sDeviceTypeToEnumTable), - devName); + devTag); if (type != AUDIO_DEVICE_NONE) { - devName = (char *)ConfigParsingUtils::enumToString(sDeviceNameToEnumTable, - ARRAY_SIZE(sDeviceNameToEnumTable), - type); - sp<DeviceDescriptor> dev = new DeviceDescriptor(String8(devName), type); + sp<DeviceDescriptor> dev = new DeviceDescriptor(type); if (type == AUDIO_DEVICE_IN_REMOTE_SUBMIX || type == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ) { dev->mAddress = String8("0"); @@ -167,13 +162,13 @@ void DeviceVector::loadDevicesFromName(char *name, add(dev); } else { sp<DeviceDescriptor> deviceDesc = - declaredDevices.getDeviceFromName(String8(devName)); + declaredDevices.getDeviceFromTag(String8(devTag)); if (deviceDesc != 0) { add(deviceDesc); } } } - devName = strtok(NULL, "|"); + devTag = strtok(NULL, "|"); } } @@ -239,11 +234,11 @@ DeviceVector DeviceVector::getDevicesFromTypeAddr( return devices; } -sp<DeviceDescriptor> DeviceVector::getDeviceFromName(const String8& name) const +sp<DeviceDescriptor> DeviceVector::getDeviceFromTag(const String8& tag) const { sp<DeviceDescriptor> device; for (size_t i = 0; i < size(); i++) { - if (itemAt(i)->mName == name) { + if (itemAt(i)->mTag == tag) { device = itemAt(i); break; } diff --git a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp index e9554478b8..7e2050b0eb 100644 --- a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp @@ -58,7 +58,7 @@ status_t HwModule::loadInput(cnode *root) } else if (strcmp(node->name, CHANNELS_TAG) == 0) { profile->loadInChannels((char *)node->value); } else if (strcmp(node->name, DEVICES_TAG) == 0) { - profile->mSupportedDevices.loadDevicesFromName((char *)node->value, + profile->mSupportedDevices.loadDevicesFromTag((char *)node->value, mDeclaredDevices); } else if (strcmp(node->name, FLAGS_TAG) == 0) { profile->mFlags = ConfigParsingUtils::parseInputFlagNames((char *)node->value); @@ -105,7 +105,7 @@ status_t HwModule::loadOutput(cnode *root) } else if (strcmp(node->name, CHANNELS_TAG) == 0) { profile->loadOutChannels((char *)node->value); } else if (strcmp(node->name, DEVICES_TAG) == 0) { - profile->mSupportedDevices.loadDevicesFromName((char *)node->value, + profile->mSupportedDevices.loadDevicesFromTag((char *)node->value, mDeclaredDevices); } else if (strcmp(node->name, FLAGS_TAG) == 0) { profile->mFlags = ConfigParsingUtils::parseOutputFlagNames((char *)node->value); @@ -154,7 +154,8 @@ status_t HwModule::loadDevice(cnode *root) ALOGW("loadDevice() bad type %08x", type); return BAD_VALUE; } - sp<DeviceDescriptor> deviceDesc = new DeviceDescriptor(String8(root->name), type); + sp<DeviceDescriptor> deviceDesc = new DeviceDescriptor(type); + deviceDesc->mTag = String8(root->name); node = root->first_child; while (node) { @@ -172,8 +173,8 @@ status_t HwModule::loadDevice(cnode *root) node = node->next; } - ALOGV("loadDevice() adding device name %s type %08x address %s", - deviceDesc->mName.string(), type, deviceDesc->mAddress.string()); + ALOGV("loadDevice() adding device tag %s type %08x address %s", + deviceDesc->mTag.string(), type, deviceDesc->mAddress.string()); mDeclaredDevices.add(deviceDesc); @@ -189,7 +190,7 @@ status_t HwModule::addOutputProfile(String8 name, const audio_config_t *config, profile->mChannelMasks.add(config->channel_mask); profile->mFormats.add(config->format); - sp<DeviceDescriptor> devDesc = new DeviceDescriptor(name, device); + sp<DeviceDescriptor> devDesc = new DeviceDescriptor(device); devDesc->mAddress = address; profile->mSupportedDevices.add(devDesc); @@ -220,7 +221,7 @@ status_t HwModule::addInputProfile(String8 name, const audio_config_t *config, profile->mChannelMasks.add(config->channel_mask); profile->mFormats.add(config->format); - sp<DeviceDescriptor> devDesc = new DeviceDescriptor(name, device); + sp<DeviceDescriptor> devDesc = new DeviceDescriptor(device); devDesc->mAddress = address; profile->mSupportedDevices.add(devDesc); @@ -350,7 +351,8 @@ sp<DeviceDescriptor> HwModuleCollection::getDeviceDescriptor(const audio_device } sp<DeviceDescriptor> devDesc = - new DeviceDescriptor(String8(device_name != NULL ? device_name : ""), device); + new DeviceDescriptor(device); + devDesc->mName = device_name; devDesc->mAddress = address; return devDesc; } |