summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-10-06 12:39:32 -0700
committerEric Laurent <elaurent@google.com>2013-10-07 10:10:44 -0700
commitb40b96a78537d63d801af7e706764c68acf8f182 (patch)
treeb2bd58dbd0d352ced8ba34e4f19db51c8f3401d8 /audio
parent87e28f7b352fb77f46e16ebcdd85cbf01396a203 (diff)
downloadhardware_libhardware_legacy-b40b96a78537d63d801af7e706764c68acf8f182.zip
hardware_libhardware_legacy-b40b96a78537d63d801af7e706764c68acf8f182.tar.gz
hardware_libhardware_legacy-b40b96a78537d63d801af7e706764c68acf8f182.tar.bz2
audio policy: fix direct output selection
commit a527ffd broke the selection of an available direct output profile in getProfileForDirectOutput(). getProfileForDirectOutput() should check for direct output profiles regardless of the flags provided to getOutput(). Bug: 11051912. Change-Id: I4a84734331bfed03d6024ea1c2e8776c27d0b28f
Diffstat (limited to 'audio')
-rw-r--r--audio/AudioPolicyManagerBase.cpp91
1 files changed, 45 insertions, 46 deletions
diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp
index d7eb273..c176146 100644
--- a/audio/AudioPolicyManagerBase.cpp
+++ b/audio/AudioPolicyManagerBase.cpp
@@ -490,6 +490,8 @@ void AudioPolicyManagerBase::setSystemProperty(const char* property, const char*
ALOGV("setSystemProperty() property %s, value %s", property, value);
}
+// Find a direct output profile compatible with the parameters passed, even if the input flags do
+// not explicitly request a direct output
AudioPolicyManagerBase::IOProfile *AudioPolicyManagerBase::getProfileForDirectOutput(
audio_devices_t device,
uint32_t samplingRate,
@@ -511,7 +513,7 @@ AudioPolicyManagerBase::IOProfile *AudioPolicyManagerBase::getProfileForDirectOu
return mHwModules[i]->mOutputProfiles[j];
}
}
- } else if (flags & AUDIO_OUTPUT_FLAG_DIRECT) {
+ } else {
if (profile->isCompatibleProfile(device, samplingRate, format,
channelMask,
AUDIO_OUTPUT_FLAG_DIRECT)) {
@@ -3483,57 +3485,54 @@ AudioPolicyManagerBase::IOProfile::~IOProfile()
{
}
-// checks if the IO profile is compatible with specified parameters. By convention a value of 0
-// means a parameter is don't care
+// checks if the IO profile is compatible with specified parameters.
+// Sampling rate, format and channel mask must be specified in order to
+// get a valid a match
bool AudioPolicyManagerBase::IOProfile::isCompatibleProfile(audio_devices_t device,
uint32_t samplingRate,
uint32_t format,
uint32_t channelMask,
audio_output_flags_t flags) const
{
- if ((mSupportedDevices & device) != device) {
- return false;
- }
- if ((mFlags & flags) != flags) {
- return false;
- }
- if (samplingRate != 0) {
- size_t i;
- for (i = 0; i < mSamplingRates.size(); i++)
- {
- if (mSamplingRates[i] == samplingRate) {
- break;
- }
- }
- if (i == mSamplingRates.size()) {
- return false;
- }
- }
- if (format != 0) {
- size_t i;
- for (i = 0; i < mFormats.size(); i++)
- {
- if (mFormats[i] == format) {
- break;
- }
- }
- if (i == mFormats.size()) {
- return false;
- }
- }
- if (channelMask != 0) {
- size_t i;
- for (i = 0; i < mChannelMasks.size(); i++)
- {
- if (mChannelMasks[i] == channelMask) {
- break;
- }
- }
- if (i == mChannelMasks.size()) {
- return false;
- }
- }
- return true;
+ if (samplingRate == 0 || format == 0 || channelMask == 0) {
+ return false;
+ }
+
+ if ((mSupportedDevices & device) != device) {
+ return false;
+ }
+ if ((mFlags & flags) != flags) {
+ return false;
+ }
+ size_t i;
+ for (i = 0; i < mSamplingRates.size(); i++)
+ {
+ if (mSamplingRates[i] == samplingRate) {
+ break;
+ }
+ }
+ if (i == mSamplingRates.size()) {
+ return false;
+ }
+ for (i = 0; i < mFormats.size(); i++)
+ {
+ if (mFormats[i] == format) {
+ break;
+ }
+ }
+ if (i == mFormats.size()) {
+ return false;
+ }
+ for (i = 0; i < mChannelMasks.size(); i++)
+ {
+ if (mChannelMasks[i] == channelMask) {
+ break;
+ }
+ }
+ if (i == mChannelMasks.size()) {
+ return false;
+ }
+ return true;
}
void AudioPolicyManagerBase::IOProfile::dump(int fd)