diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2019-05-29 19:35:24 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2019-05-29 19:35:24 -0700 |
commit | 872fe2d8054269e39314af9c92cd783fd190d296 (patch) | |
tree | 1c17c2e54953687f32ad9fe00e029f759626f653 | |
parent | 429a3236e9b3fc1df06d143468393c57909e4585 (diff) | |
parent | 8353c1d8f10cca71b0e95a36a1c5b0b37f516e28 (diff) | |
download | android_vendor_qcom_opensource_audio-872fe2d8054269e39314af9c92cd783fd190d296.tar.gz android_vendor_qcom_opensource_audio-872fe2d8054269e39314af9c92cd783fd190d296.tar.bz2 android_vendor_qcom_opensource_audio-872fe2d8054269e39314af9c92cd783fd190d296.zip |
Merge 8353c1d8f10cca71b0e95a36a1c5b0b37f516e28 on remote branch
Change-Id: I1048f113958ffca001c08c75733f886d8fb9d3fb
-rwxr-xr-x | policy_hal/AudioPolicyManager.cpp | 138 |
1 files changed, 68 insertions, 70 deletions
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp index dac096c..9f7eb10 100755 --- a/policy_hal/AudioPolicyManager.cpp +++ b/policy_hal/AudioPolicyManager.cpp @@ -1745,82 +1745,80 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevices( goto non_direct_output; } - if ((*flags & AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) == 0 || output != AUDIO_IO_HANDLE_NONE) { - sp<SwAudioOutputDescriptor> outputDesc = NULL; - // if multiple concurrent offload decode is supported - // do no check for reuse and also don't close previous output if its offload - // previous output will be closed during track destruction - if (!mApmConfigs->isAudioMultipleOffloadEnable() && - ((*flags & AUDIO_OUTPUT_FLAG_DIRECT) != 0)) { - for (size_t i = 0; i < mOutputs.size(); i++) { - sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i); - if (!desc->isDuplicated() && (profile == desc->mProfile)) { - outputDesc = desc; - // reuse direct output if currently open by the same client - // and configured with same parameters - if ((config->sample_rate == desc->mSamplingRate) && - audio_formats_match(config->format, desc->mFormat) && - (channelMask == desc->mChannelMask) && - (session == desc->mDirectClientSession)) { - desc->mDirectOpenCount++; - ALOGV("getOutputForDevice() reusing direct output %d for session %d", - mOutputs.keyAt(i), session); - return mOutputs.keyAt(i); - } - } - if (outputDesc != NULL) { - if ((((*flags == AUDIO_OUTPUT_FLAG_DIRECT) && direct_pcm_already_in_use) || - ((*flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) && - compress_offload_already_in_use)) && - session != outputDesc->mDirectClientSession) { - ALOGV("getOutput() do not reuse direct pcm output because current client (%d) " - "is not the same as requesting client (%d) for different output conf", - outputDesc->mDirectClientSession, session); - goto non_direct_output; - } - closeOutput(outputDesc->mIoHandle); + sp<SwAudioOutputDescriptor> outputDesc = NULL; + // if multiple concurrent offload decode is supported + // do no check for reuse and also don't close previous output if its offload + // previous output will be closed during track destruction + if (!mApmConfigs->isAudioMultipleOffloadEnable() && + ((*flags & AUDIO_OUTPUT_FLAG_DIRECT) != 0)) { + for (size_t i = 0; i < mOutputs.size(); i++) { + sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i); + if (!desc->isDuplicated() && (profile == desc->mProfile)) { + outputDesc = desc; + // reuse direct output if currently open by the same client + // and configured with same parameters + if ((config->sample_rate == desc->mSamplingRate) && + audio_formats_match(config->format, desc->mFormat) && + (channelMask == desc->mChannelMask) && + (session == desc->mDirectClientSession)) { + desc->mDirectOpenCount++; + ALOGV("getOutputForDevice() reusing direct output %d for session %d", + mOutputs.keyAt(i), session); + return mOutputs.keyAt(i); } } - if (!profile->canOpenNewIo()) { - goto non_direct_output; + } + if (outputDesc != NULL) { + if ((((*flags == AUDIO_OUTPUT_FLAG_DIRECT) && direct_pcm_already_in_use) || + ((*flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) && + compress_offload_already_in_use)) && + session != outputDesc->mDirectClientSession) { + ALOGV("getOutput() do not reuse direct pcm output because current client (%d) " + "is not the same as requesting client (%d) for different output conf", + outputDesc->mDirectClientSession, session); + goto non_direct_output; } + closeOutput(outputDesc->mIoHandle); + } + } + if (!profile->canOpenNewIo()) { + goto non_direct_output; + } - outputDesc = - new SwAudioOutputDescriptor(profile, mpClientInterface); - DeviceVector outputDevices = mAvailableOutputDevices.getDevicesFromTypeMask(devices.types()); - String8 address = outputDevices.size() > 0 ? outputDevices.itemAt(0)->address() - : String8(""); - status = outputDesc->open(config, devices, stream, *flags, &output); - - // only accept an output with the requested parameters - if (status != NO_ERROR || - (config->sample_rate != 0 && config->sample_rate != outputDesc->mSamplingRate) || - (config->format != AUDIO_FORMAT_DEFAULT && - !audio_formats_match(config->format, outputDesc->mFormat)) || - (channelMask != 0 && channelMask != outputDesc->mChannelMask)) { - ALOGV("getOutputForDevice() failed opening direct output: output %d sample rate %d %d," - "format %d %d, channel mask %04x %04x", output, config->sample_rate, - outputDesc->mSamplingRate, config->format, outputDesc->mFormat, - channelMask, outputDesc->mChannelMask); - if (output != AUDIO_IO_HANDLE_NONE) { - outputDesc->close(); - } - // fall back to mixer output if possible when the direct output could not be open - if (audio_is_linear_pcm(config->format) && config->sample_rate <= SAMPLE_RATE_HZ_MAX) { - goto non_direct_output; - } - return AUDIO_IO_HANDLE_NONE; - } - outputDesc->mDirectOpenCount = 1; - outputDesc->mDirectClientSession = session; - - addOutput(output, outputDesc); - mPreviousOutputs = mOutputs; - ALOGV("getOutputForDevice() returns new direct output %d", output); - mpClientInterface->onAudioPortListUpdate(); - return output; + outputDesc = + new SwAudioOutputDescriptor(profile, mpClientInterface); + DeviceVector outputDevices = mAvailableOutputDevices.getDevicesFromTypeMask(devices.types()); + String8 address = outputDevices.size() > 0 ? outputDevices.itemAt(0)->address() + : String8(""); + status = outputDesc->open(config, devices, stream, *flags, &output); + + // only accept an output with the requested parameters + if (status != NO_ERROR || + (config->sample_rate != 0 && config->sample_rate != outputDesc->mSamplingRate) || + (config->format != AUDIO_FORMAT_DEFAULT && + !audio_formats_match(config->format, outputDesc->mFormat)) || + (channelMask != 0 && channelMask != outputDesc->mChannelMask)) { + ALOGV("getOutputForDevice() failed opening direct output: output %d sample rate %d %d," + "format %d %d, channel mask %04x %04x", output, config->sample_rate, + outputDesc->mSamplingRate, config->format, outputDesc->mFormat, + channelMask, outputDesc->mChannelMask); + if (output != AUDIO_IO_HANDLE_NONE) { + outputDesc->close(); } + // fall back to mixer output if possible when the direct output could not be open + if (audio_is_linear_pcm(config->format) && config->sample_rate <= SAMPLE_RATE_HZ_MAX) { + goto non_direct_output; + } + return AUDIO_IO_HANDLE_NONE; } + outputDesc->mDirectOpenCount = 1; + outputDesc->mDirectClientSession = session; + + addOutput(output, outputDesc); + mPreviousOutputs = mOutputs; + ALOGV("getOutputForDevice() returns new direct output %d", output); + mpClientInterface->onAudioPortListUpdate(); + return output; } non_direct_output: |