diff options
author | Eric Laurent <elaurent@google.com> | 2014-09-08 16:07:06 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-09-08 16:07:06 +0000 |
commit | 8636d03dd14fa996bb0f8bf2f4714319173d886e (patch) | |
tree | 6849480b39148f26af8a6a86b4d1f48c0a3be9ab /services | |
parent | 693f83c2d739380c108707887fd2cd9542e0eea6 (diff) | |
parent | d8ec8e3db145ae81c0958527bbe48b0dd7a78181 (diff) | |
download | frameworks_av-8636d03dd14fa996bb0f8bf2f4714319173d886e.zip frameworks_av-8636d03dd14fa996bb0f8bf2f4714319173d886e.tar.gz frameworks_av-8636d03dd14fa996bb0f8bf2f4714319173d886e.tar.bz2 |
am d8ec8e3d: am 2e97b01c: Merge "audiopolicy: fix direct output profile probing" into lmp-dev
* commit 'd8ec8e3db145ae81c0958527bbe48b0dd7a78181':
audiopolicy: fix direct output profile probing
Diffstat (limited to 'services')
-rw-r--r-- | services/audiopolicy/AudioPolicyManager.cpp | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index 084c853..6446a6e 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -6039,14 +6039,26 @@ uint32_t AudioPolicyManager::AudioPort::pickSamplingRate() const return 0; } + // For direct outputs, pick minimum sampling rate: this helps ensuring that the + // channel count / sampling rate combination chosen will be supported by the connected + // sink + if ((mType == AUDIO_PORT_TYPE_MIX) && (mRole == AUDIO_PORT_ROLE_SOURCE) && + (mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD))) { + uint32_t samplingRate = UINT_MAX; + for (size_t i = 0; i < mSamplingRates.size(); i ++) { + if ((mSamplingRates[i] < samplingRate) && (mSamplingRates[i] > 0)) { + samplingRate = mSamplingRates[i]; + } + } + return (samplingRate == UINT_MAX) ? 0 : samplingRate; + } + uint32_t samplingRate = 0; uint32_t maxRate = MAX_MIXER_SAMPLING_RATE; // For mixed output and inputs, use max mixer sampling rates. Do not // limit sampling rate otherwise - if ((mType != AUDIO_PORT_TYPE_MIX) || - ((mRole == AUDIO_PORT_ROLE_SOURCE) && - (mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)))) { + if (mType != AUDIO_PORT_TYPE_MIX) { maxRate = UINT_MAX; } for (size_t i = 0; i < mSamplingRates.size(); i ++) { @@ -6063,16 +6075,35 @@ audio_channel_mask_t AudioPolicyManager::AudioPort::pickChannelMask() const if (mChannelMasks.size() == 1 && mChannelMasks[0] == 0) { return AUDIO_CHANNEL_NONE; } - audio_channel_mask_t channelMask = AUDIO_CHANNEL_NONE; + + // For direct outputs, pick minimum channel count: this helps ensuring that the + // channel count / sampling rate combination chosen will be supported by the connected + // sink + if ((mType == AUDIO_PORT_TYPE_MIX) && (mRole == AUDIO_PORT_ROLE_SOURCE) && + (mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD))) { + uint32_t channelCount = UINT_MAX; + for (size_t i = 0; i < mChannelMasks.size(); i ++) { + uint32_t cnlCount; + if (mUseInChannelMask) { + cnlCount = audio_channel_count_from_in_mask(mChannelMasks[i]); + } else { + cnlCount = audio_channel_count_from_out_mask(mChannelMasks[i]); + } + if ((cnlCount < channelCount) && (cnlCount > 0)) { + channelMask = mChannelMasks[i]; + channelCount = cnlCount; + } + } + return channelMask; + } + uint32_t channelCount = 0; uint32_t maxCount = MAX_MIXER_CHANNEL_COUNT; // For mixed output and inputs, use max mixer channel count. Do not // limit channel count otherwise - if ((mType != AUDIO_PORT_TYPE_MIX) || - ((mRole == AUDIO_PORT_ROLE_SOURCE) && - (mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)))) { + if (mType != AUDIO_PORT_TYPE_MIX) { maxCount = UINT_MAX; } for (size_t i = 0; i < mChannelMasks.size(); i ++) { @@ -6084,6 +6115,7 @@ audio_channel_mask_t AudioPolicyManager::AudioPort::pickChannelMask() const } if ((cnlCount > channelCount) && (cnlCount <= maxCount)) { channelMask = mChannelMasks[i]; + channelCount = cnlCount; } } return channelMask; |