summaryrefslogtreecommitdiffstats
path: root/services/audiopolicy/common/managerdefinitions/src
diff options
context:
space:
mode:
Diffstat (limited to 'services/audiopolicy/common/managerdefinitions/src')
-rw-r--r--services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp20
-rw-r--r--services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp23
-rw-r--r--services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp8
-rw-r--r--services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp27
-rw-r--r--services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp8
-rw-r--r--services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp31
-rw-r--r--services/audiopolicy/common/managerdefinitions/src/HwModule.cpp14
-rw-r--r--services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp5
8 files changed, 92 insertions, 44 deletions
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
index fa66728..937160b 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
@@ -27,9 +27,9 @@
namespace android {
AudioInputDescriptor::AudioInputDescriptor(const sp<IOProfile>& profile)
- : mId(0), mIoHandle(0),
+ : mIoHandle(0),
mDevice(AUDIO_DEVICE_NONE), mPolicyMix(NULL), mPatchHandle(0), mRefCount(0),
- mInputSource(AUDIO_SOURCE_DEFAULT), mProfile(profile), mIsSoundTrigger(false)
+ mInputSource(AUDIO_SOURCE_DEFAULT), mProfile(profile), mIsSoundTrigger(false), mId(0)
{
if (profile != NULL) {
mSamplingRate = profile->pickSamplingRate();
@@ -49,9 +49,17 @@ void AudioInputDescriptor::setIoHandle(audio_io_handle_t ioHandle)
audio_module_handle_t AudioInputDescriptor::getModuleHandle() const
{
+ if (mProfile == 0) {
+ return 0;
+ }
return mProfile->getModuleHandle();
}
+audio_port_handle_t AudioInputDescriptor::getId() const
+{
+ return mId;
+}
+
void AudioInputDescriptor::toAudioPortConfig(struct audio_port_config *dstConfig,
const struct audio_port_config *srcConfig) const
{
@@ -68,7 +76,7 @@ void AudioInputDescriptor::toAudioPortConfig(struct audio_port_config *dstConfig
dstConfig->id = mId;
dstConfig->role = AUDIO_PORT_ROLE_SINK;
dstConfig->type = AUDIO_PORT_TYPE_MIX;
- dstConfig->ext.mix.hw_module = mProfile->mModule->mHandle;
+ dstConfig->ext.mix.hw_module = getModuleHandle();
dstConfig->ext.mix.handle = mIoHandle;
dstConfig->ext.mix.usecase.source = mInputSource;
}
@@ -80,7 +88,7 @@ void AudioInputDescriptor::toAudioPort(struct audio_port *port) const
mProfile->toAudioPort(port);
port->id = mId;
toAudioPortConfig(&port->active_config);
- port->ext.mix.hw_module = mProfile->mModule->mHandle;
+ port->ext.mix.hw_module = getModuleHandle();
port->ext.mix.handle = mIoHandle;
port->ext.mix.latency_class = AUDIO_LATENCY_NORMAL;
}
@@ -91,7 +99,7 @@ status_t AudioInputDescriptor::dump(int fd)
char buffer[SIZE];
String8 result;
- snprintf(buffer, SIZE, " ID: %d\n", mId);
+ snprintf(buffer, SIZE, " ID: %d\n", getId());
result.append(buffer);
snprintf(buffer, SIZE, " Sampling rate: %d\n", mSamplingRate);
result.append(buffer);
@@ -130,7 +138,7 @@ sp<AudioInputDescriptor> AudioInputCollection::getInputFromId(audio_port_handle_
sp<AudioInputDescriptor> inputDesc = NULL;
for (size_t i = 0; i < size(); i++) {
inputDesc = valueAt(i);
- if (inputDesc->mId == id) {
+ if (inputDesc->getId() == id) {
break;
}
}
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
index 7207a71..8de8cd8 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
@@ -30,10 +30,11 @@
namespace android {
AudioOutputDescriptor::AudioOutputDescriptor(const sp<IOProfile>& profile)
- : mId(0), mIoHandle(0), mLatency(0),
+ : mIoHandle(0), mLatency(0),
mFlags((audio_output_flags_t)0), mDevice(AUDIO_DEVICE_NONE), mPolicyMix(NULL),
mPatchHandle(0),
- mOutput1(0), mOutput2(0), mProfile(profile), mDirectOpenCount(0)
+ mOutput1(0), mOutput2(0), mProfile(profile), mDirectOpenCount(0),
+ mId(0)
{
// clear usage count for all stream types
for (int i = 0; i < AUDIO_STREAM_CNT; i++) {
@@ -58,9 +59,17 @@ AudioOutputDescriptor::AudioOutputDescriptor(const sp<IOProfile>& profile)
audio_module_handle_t AudioOutputDescriptor::getModuleHandle() const
{
+ if (mProfile == 0) {
+ return 0;
+ }
return mProfile->getModuleHandle();
}
+audio_port_handle_t AudioOutputDescriptor::getId() const
+{
+ return mId;
+}
+
audio_devices_t AudioOutputDescriptor::device() const
{
if (isDuplicated()) {
@@ -93,7 +102,7 @@ bool AudioOutputDescriptor::sharesHwModuleWith(
} else if (outputDesc->isDuplicated()){
return sharesHwModuleWith(outputDesc->mOutput1) || sharesHwModuleWith(outputDesc->mOutput2);
} else {
- return (mProfile->mModule == outputDesc->mProfile->mModule);
+ return (getModuleHandle() == outputDesc->getModuleHandle());
}
}
@@ -176,7 +185,7 @@ void AudioOutputDescriptor::toAudioPortConfig(
dstConfig->id = mId;
dstConfig->role = AUDIO_PORT_ROLE_SOURCE;
dstConfig->type = AUDIO_PORT_TYPE_MIX;
- dstConfig->ext.mix.hw_module = mProfile->mModule->mHandle;
+ dstConfig->ext.mix.hw_module = getModuleHandle();
dstConfig->ext.mix.handle = mIoHandle;
dstConfig->ext.mix.usecase.stream = AUDIO_STREAM_DEFAULT;
}
@@ -188,7 +197,7 @@ void AudioOutputDescriptor::toAudioPort(
mProfile->toAudioPort(port);
port->id = mId;
toAudioPortConfig(&port->active_config);
- port->ext.mix.hw_module = mProfile->mModule->mHandle;
+ port->ext.mix.hw_module = getModuleHandle();
port->ext.mix.handle = mIoHandle;
port->ext.mix.latency_class =
mFlags & AUDIO_OUTPUT_FLAG_FAST ? AUDIO_LATENCY_LOW : AUDIO_LATENCY_NORMAL;
@@ -200,7 +209,7 @@ status_t AudioOutputDescriptor::dump(int fd)
char buffer[SIZE];
String8 result;
- snprintf(buffer, SIZE, " ID: %d\n", mId);
+ snprintf(buffer, SIZE, " ID: %d\n", getId());
result.append(buffer);
snprintf(buffer, SIZE, " Sampling rate: %d\n", mSamplingRate);
result.append(buffer);
@@ -289,7 +298,7 @@ sp<AudioOutputDescriptor> AudioOutputCollection::getOutputFromId(audio_port_hand
sp<AudioOutputDescriptor> outputDesc = NULL;
for (size_t i = 0; i < size(); i++) {
outputDesc = valueAt(i);
- if (outputDesc->mId == id) {
+ if (outputDesc->getId() == id) {
break;
}
}
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp
index 3a317fa..a06d867 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp
@@ -54,8 +54,8 @@ status_t AudioPatch::dump(int fd, int spaces, int index) const
for (size_t i = 0; i < mPatch.num_sources; i++) {
if (mPatch.sources[i].type == AUDIO_PORT_TYPE_DEVICE) {
snprintf(buffer, SIZE, "%*s- Device ID %d %s\n", spaces + 2, "",
- mPatch.sources[i].id, ConfigParsingUtils::enumToString(sDeviceNameToEnumTable,
- ARRAY_SIZE(sDeviceNameToEnumTable),
+ mPatch.sources[i].id, ConfigParsingUtils::enumToString(sDeviceTypeToEnumTable,
+ ARRAY_SIZE(sDeviceTypeToEnumTable),
mPatch.sources[i].ext.device.type));
} else {
snprintf(buffer, SIZE, "%*s- Mix ID %d I/O handle %d\n", spaces + 2, "",
@@ -68,8 +68,8 @@ status_t AudioPatch::dump(int fd, int spaces, int index) const
for (size_t i = 0; i < mPatch.num_sinks; i++) {
if (mPatch.sinks[i].type == AUDIO_PORT_TYPE_DEVICE) {
snprintf(buffer, SIZE, "%*s- Device ID %d %s\n", spaces + 2, "",
- mPatch.sinks[i].id, ConfigParsingUtils::enumToString(sDeviceNameToEnumTable,
- ARRAY_SIZE(sDeviceNameToEnumTable),
+ mPatch.sinks[i].id, ConfigParsingUtils::enumToString(sDeviceTypeToEnumTable,
+ ARRAY_SIZE(sDeviceTypeToEnumTable),
mPatch.sinks[i].ext.device.type));
} else {
snprintf(buffer, SIZE, "%*s- Mix ID %d I/O handle %d\n", spaces + 2, "",
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp
index 2bbcc05..e8191dd 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp
@@ -31,8 +31,8 @@ int32_t volatile AudioPort::mNextUniqueId = 1;
// --- AudioPort class implementation
AudioPort::AudioPort(const String8& name, audio_port_type_t type,
- audio_port_role_t role, const sp<HwModule>& module) :
- mName(name), mType(type), mRole(role), mModule(module), mFlags(0), mId(0)
+ audio_port_role_t role) :
+ mName(name), mType(type), mRole(role), mFlags(0)
{
mUseInChannelMask = ((type == AUDIO_PORT_TYPE_DEVICE) && (role == AUDIO_PORT_ROLE_SOURCE)) ||
((type == AUDIO_PORT_TYPE_MIX) && (role == AUDIO_PORT_ROLE_SINK));
@@ -40,7 +40,6 @@ AudioPort::AudioPort(const String8& name, audio_port_type_t type,
void AudioPort::attach(const sp<HwModule>& module)
{
- mId = getNextUniqueId();
mModule = module;
}
@@ -51,9 +50,28 @@ audio_port_handle_t AudioPort::getNextUniqueId()
audio_module_handle_t AudioPort::getModuleHandle() const
{
+ if (mModule == 0) {
+ return 0;
+ }
return mModule->mHandle;
}
+uint32_t AudioPort::getModuleVersion() const
+{
+ if (mModule == 0) {
+ return 0;
+ }
+ return mModule->mHalVersion;
+}
+
+const char *AudioPort::getModuleName() const
+{
+ if (mModule == 0) {
+ return "";
+ }
+ return mModule->mName;
+}
+
void AudioPort::toAudioPort(struct audio_port *port) const
{
port->role = mRole;
@@ -629,7 +647,7 @@ void AudioPort::dump(int fd, int spaces) const
char buffer[SIZE];
String8 result;
- if (mName.size() != 0) {
+ if (mName.length() != 0) {
snprintf(buffer, SIZE, "%*s- name: %s\n", spaces, "", mName.string());
result.append(buffer);
}
@@ -687,7 +705,6 @@ void AudioPort::dump(int fd, int spaces) const
if (mGains.size() != 0) {
snprintf(buffer, SIZE, "%*s- gains:\n", spaces, "");
write(fd, buffer, strlen(buffer) + 1);
- result.append(buffer);
for (size_t i = 0; i < mGains.size(); i++) {
mGains[i]->dump(fd, spaces + 2, i);
}
diff --git a/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp b/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp
index fe5bc5f..9ab1d61 100644
--- a/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp
@@ -113,8 +113,8 @@ audio_devices_t ConfigParsingUtils::parseDeviceNames(char *name)
char *devName = strtok(name, "|");
while (devName != NULL) {
if (strlen(devName) != 0) {
- device |= stringToEnum(sDeviceNameToEnumTable,
- ARRAY_SIZE(sDeviceNameToEnumTable),
+ device |= stringToEnum(sDeviceTypeToEnumTable,
+ ARRAY_SIZE(sDeviceTypeToEnumTable),
devName);
}
devName = strtok(NULL, "|");
@@ -224,8 +224,8 @@ void ConfigParsingUtils::loadGlobalConfig(cnode *root, const sp<HwModule>& modul
availableOutputDevices.types());
} else if (strcmp(DEFAULT_OUTPUT_DEVICE_TAG, node->name) == 0) {
audio_devices_t device = (audio_devices_t)stringToEnum(
- sDeviceNameToEnumTable,
- ARRAY_SIZE(sDeviceNameToEnumTable),
+ sDeviceTypeToEnumTable,
+ ARRAY_SIZE(sDeviceTypeToEnumTable),
(char *)node->value);
if (device != AUDIO_DEVICE_NONE) {
defaultOutputDevice = new DeviceDescriptor(String8("default-output"), device);
diff --git a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
index 9249d47..9573583 100644
--- a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
@@ -29,13 +29,23 @@ String8 DeviceDescriptor::emptyNameStr = String8("");
DeviceDescriptor::DeviceDescriptor(const String8& name, audio_devices_t type) :
AudioPort(name, AUDIO_PORT_TYPE_DEVICE,
audio_is_output_device(type) ? AUDIO_PORT_ROLE_SINK :
- AUDIO_PORT_ROLE_SOURCE,
- NULL),
- mAddress(""), mDeviceType(type)
+ AUDIO_PORT_ROLE_SOURCE),
+ mAddress(""), mDeviceType(type), mId(0)
{
}
+audio_port_handle_t DeviceDescriptor::getId() const
+{
+ return mId;
+}
+
+void DeviceDescriptor::attach(const sp<HwModule>& module)
+{
+ AudioPort::attach(module);
+ mId = getNextUniqueId();
+}
+
bool DeviceDescriptor::equals(const sp<DeviceDescriptor>& other) const
{
// Devices are considered equal if they:
@@ -139,11 +149,14 @@ void DeviceVector::loadDevicesFromName(char *name,
char *devName = strtok(name, "|");
while (devName != NULL) {
if (strlen(devName) != 0) {
- audio_devices_t type = ConfigParsingUtils::stringToEnum(sDeviceNameToEnumTable,
- ARRAY_SIZE(sDeviceNameToEnumTable),
+ audio_devices_t type = ConfigParsingUtils::stringToEnum(sDeviceTypeToEnumTable,
+ ARRAY_SIZE(sDeviceTypeToEnumTable),
devName);
if (type != AUDIO_DEVICE_NONE) {
- sp<DeviceDescriptor> dev = new DeviceDescriptor(String8(name), type);
+ devName = (char *)ConfigParsingUtils::enumToString(sDeviceNameToEnumTable,
+ ARRAY_SIZE(sDeviceNameToEnumTable),
+ type);
+ sp<DeviceDescriptor> dev = new DeviceDescriptor(String8(devName), type);
if (type == AUDIO_DEVICE_IN_REMOTE_SUBMIX ||
type == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ) {
dev->mAddress = String8("0");
@@ -183,7 +196,7 @@ sp<DeviceDescriptor> DeviceVector::getDeviceFromId(audio_port_handle_t id) const
{
sp<DeviceDescriptor> device;
for (size_t i = 0; i < size(); i++) {
- if (itemAt(i)->getHandle() == id) {
+ if (itemAt(i)->getId() == id) {
device = itemAt(i);
break;
}
@@ -303,8 +316,8 @@ status_t DeviceDescriptor::dump(int fd, int spaces, int index) const
result.append(buffer);
}
snprintf(buffer, SIZE, "%*s- type: %-48s\n", spaces, "",
- ConfigParsingUtils::enumToString(sDeviceNameToEnumTable,
- ARRAY_SIZE(sDeviceNameToEnumTable),
+ ConfigParsingUtils::enumToString(sDeviceTypeToEnumTable,
+ ARRAY_SIZE(sDeviceTypeToEnumTable),
mDeviceType));
result.append(buffer);
if (mAddress.size() != 0) {
diff --git a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
index 0097d69..e955447 100644
--- a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
@@ -48,7 +48,7 @@ status_t HwModule::loadInput(cnode *root)
{
cnode *node = root->first_child;
- sp<IOProfile> profile = new IOProfile(String8(root->name), AUDIO_PORT_ROLE_SINK, this);
+ sp<IOProfile> profile = new IOProfile(String8(root->name), AUDIO_PORT_ROLE_SINK);
while (node) {
if (strcmp(node->name, SAMPLING_RATES_TAG) == 0) {
@@ -83,6 +83,7 @@ status_t HwModule::loadInput(cnode *root)
ALOGV("loadInput() adding input Supported Devices %04x",
profile->mSupportedDevices.types());
+ profile->attach(this);
mInputProfiles.add(profile);
return NO_ERROR;
} else {
@@ -94,7 +95,7 @@ status_t HwModule::loadOutput(cnode *root)
{
cnode *node = root->first_child;
- sp<IOProfile> profile = new IOProfile(String8(root->name), AUDIO_PORT_ROLE_SOURCE, this);
+ sp<IOProfile> profile = new IOProfile(String8(root->name), AUDIO_PORT_ROLE_SOURCE);
while (node) {
if (strcmp(node->name, SAMPLING_RATES_TAG) == 0) {
@@ -128,7 +129,7 @@ status_t HwModule::loadOutput(cnode *root)
ALOGV("loadOutput() adding output Supported Devices %04x, mFlags %04x",
profile->mSupportedDevices.types(), profile->mFlags);
-
+ profile->attach(this);
mOutputProfiles.add(profile);
return NO_ERROR;
} else {
@@ -154,7 +155,6 @@ status_t HwModule::loadDevice(cnode *root)
return BAD_VALUE;
}
sp<DeviceDescriptor> deviceDesc = new DeviceDescriptor(String8(root->name), type);
- deviceDesc->mModule = this;
node = root->first_child;
while (node) {
@@ -183,7 +183,7 @@ status_t HwModule::loadDevice(cnode *root)
status_t HwModule::addOutputProfile(String8 name, const audio_config_t *config,
audio_devices_t device, String8 address)
{
- sp<IOProfile> profile = new IOProfile(name, AUDIO_PORT_ROLE_SOURCE, this);
+ sp<IOProfile> profile = new IOProfile(name, AUDIO_PORT_ROLE_SOURCE);
profile->mSamplingRates.add(config->sample_rate);
profile->mChannelMasks.add(config->channel_mask);
@@ -193,6 +193,7 @@ status_t HwModule::addOutputProfile(String8 name, const audio_config_t *config,
devDesc->mAddress = address;
profile->mSupportedDevices.add(devDesc);
+ profile->attach(this);
mOutputProfiles.add(profile);
return NO_ERROR;
@@ -213,7 +214,7 @@ status_t HwModule::removeOutputProfile(String8 name)
status_t HwModule::addInputProfile(String8 name, const audio_config_t *config,
audio_devices_t device, String8 address)
{
- sp<IOProfile> profile = new IOProfile(name, AUDIO_PORT_ROLE_SINK, this);
+ sp<IOProfile> profile = new IOProfile(name, AUDIO_PORT_ROLE_SINK);
profile->mSamplingRates.add(config->sample_rate);
profile->mChannelMasks.add(config->channel_mask);
@@ -225,6 +226,7 @@ status_t HwModule::addInputProfile(String8 name, const audio_config_t *config,
ALOGV("addInputProfile() name %s rate %d mask 0x08", name.string(), config->sample_rate, config->channel_mask);
+ profile->attach(this);
mInputProfiles.add(profile);
return NO_ERROR;
diff --git a/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp b/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp
index 376dd22..de6539c 100644
--- a/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/IOProfile.cpp
@@ -23,9 +23,8 @@
namespace android {
-IOProfile::IOProfile(const String8& name, audio_port_role_t role,
- const sp<HwModule>& module)
- : AudioPort(name, AUDIO_PORT_TYPE_MIX, role, module)
+IOProfile::IOProfile(const String8& name, audio_port_role_t role)
+ : AudioPort(name, AUDIO_PORT_TYPE_MIX, role)
{
}