diff options
author | Eric Laurent <elaurent@google.com> | 2015-06-25 11:48:20 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2015-06-25 11:48:20 -0700 |
commit | cc750d3604b33a92374253b12dd739dc06440aad (patch) | |
tree | d2fb46dbd9994624d5da2dcd6141add90d79d562 /services/audiopolicy | |
parent | ed8505836c0b2fba0ab4be0c1eff31d4f241bc1d (diff) | |
download | frameworks_av-cc750d3604b33a92374253b12dd739dc06440aad.zip frameworks_av-cc750d3604b33a92374253b12dd739dc06440aad.tar.gz frameworks_av-cc750d3604b33a92374253b12dd739dc06440aad.tar.bz2 |
audio policy: fix several device descriptor issues.
- checkOutputsForDevice() should only clear device descriptor attributes
if the device is digital.
- checkInputsForDevice() did not clear device descriptor attributes at all.
- AudioPort::clearCapabilities() and importAudioPort() should not
manage gains as these are device specific.
- importAudioPort() should load a default port config.
Bug: 21990937.
Change-Id: Ida762ed8f9baaabae392cb4291eff1a8d3009751
Diffstat (limited to 'services/audiopolicy')
5 files changed, 20 insertions, 20 deletions
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioPort.h b/services/audiopolicy/common/managerdefinitions/include/AudioPort.h index 82e2c43..4fdf5b4 100644 --- a/services/audiopolicy/common/managerdefinitions/include/AudioPort.h +++ b/services/audiopolicy/common/managerdefinitions/include/AudioPort.h @@ -42,7 +42,7 @@ public: virtual void toAudioPort(struct audio_port *port) const; - void importAudioPort(const sp<AudioPort> port); + virtual void importAudioPort(const sp<AudioPort> port); void clearCapabilities(); void loadSamplingRates(char *name); diff --git a/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h index d1a2f4f..c42ece6 100644 --- a/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h +++ b/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h @@ -44,6 +44,7 @@ public: virtual void attach(const sp<HwModule>& module); virtual void loadGains(cnode *root); virtual void toAudioPort(struct audio_port *port) const; + virtual void importAudioPort(const sp<AudioPort> port); audio_port_handle_t getId() const; audio_devices_t type() const { return mDeviceType; } diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp index afcd073..4e24f19 100644 --- a/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp @@ -151,28 +151,12 @@ void AudioPort::importAudioPort(const sp<AudioPort> port) { } } } - for (size_t k = 0 ; k < port->mGains.size() ; k++) { - sp<AudioGain> gain = port->mGains.itemAt(k); - if (gain != 0) { - bool hasGain = false; - for (size_t l = 0 ; l < mGains.size() ; l++) { - if (gain == mGains.itemAt(l)) { - hasGain = true; - break; - } - } - if (!hasGain) { // never import a gain twice - mGains.add(gain); - } - } - } } void AudioPort::clearCapabilities() { mChannelMasks.clear(); mFormats.clear(); mSamplingRates.clear(); - mGains.clear(); } void AudioPort::loadSamplingRates(char *name) diff --git a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp index 797077a..1f1fca3 100644 --- a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp @@ -301,6 +301,13 @@ void DeviceDescriptor::toAudioPort(struct audio_port *port) const strncpy(port->ext.device.address, mAddress.string(), AUDIO_DEVICE_MAX_ADDRESS_LEN); } +void DeviceDescriptor::importAudioPort(const sp<AudioPort> port) { + AudioPort::importAudioPort(port); + mSamplingRate = port->pickSamplingRate(); + mFormat = port->pickFormat(); + mChannelMask = port->pickChannelMask(); +} + status_t DeviceDescriptor::dump(int fd, int spaces, int index) const { const size_t SIZE = 256; diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp index a0de34d..ee25b71 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp @@ -3140,8 +3140,11 @@ status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor> de { audio_devices_t device = devDesc->type(); sp<SwAudioOutputDescriptor> desc; - // erase all current sample rates, formats and channel masks - devDesc->clearCapabilities(); + + if (audio_device_is_digital(device)) { + // erase all current sample rates, formats and channel masks + devDesc->clearCapabilities(); + } if (state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) { // first list already open outputs that can be routed to this device @@ -3433,8 +3436,13 @@ status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor> dev const String8 address) { audio_devices_t device = devDesc->type(); - sp<AudioInputDescriptor> desc; + + if (audio_device_is_digital(device)) { + // erase all current sample rates, formats and channel masks + devDesc->clearCapabilities(); + } + if (state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) { // first list already open inputs that can be routed to this device for (size_t input_index = 0; input_index < mInputs.size(); input_index++) { |