diff options
author | Scott Mertz <scott@cyngn.com> | 2016-01-11 11:50:35 -0800 |
---|---|---|
committer | Scott Mertz <scott@cyngn.com> | 2016-01-11 11:50:35 -0800 |
commit | 998901b1612e872630c7cae39d196cb0c7309de0 (patch) | |
tree | 67ca086f36fb2131d8286c9bd9b00d947c748c62 | |
parent | eec6acfa6feb0391529da0b5d0f6e3e88d3f1a5b (diff) | |
parent | 3a44f582d97f9583403cde215f3e19a95dab2bec (diff) | |
download | hardware_qcom_audio-998901b1612e872630c7cae39d196cb0c7309de0.tar.gz hardware_qcom_audio-998901b1612e872630c7cae39d196cb0c7309de0.tar.bz2 hardware_qcom_audio-998901b1612e872630c7cae39d196cb0c7309de0.zip |
Merge tag 'LA.BF64.1.2.2-02240-8x94.0' into cm-13.0-caf-8994
"LA.BF64.1.2.2-02240-8x94.0"
-rw-r--r-- | hal/audio_hw.c | 4 | ||||
-rw-r--r-- | policy_hal/AudioPolicyManager.cpp | 70 |
2 files changed, 64 insertions, 10 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 13940330..998954cc 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -2172,10 +2172,10 @@ static char* out_get_parameters(const struct audio_stream *stream, const char *k value[0] = '\0'; if (out->flags & AUDIO_OUTPUT_FLAG_DIRECT_PCM) { ALOGV("in direct_pcm"); - strlcat(value, "true", strlen("true")); + strlcat(value, "true", sizeof(value )); } else { ALOGV("not in direct_pcm"); - strlcat(value, "false", strlen("false")); + strlcat(value, "false", sizeof(value)); } str_parms_add_str(reply, "is_direct_pcm_track", value); str = str_parms_to_str(reply); diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp index 2b567b18..b005bfce 100644 --- a/policy_hal/AudioPolicyManager.cpp +++ b/policy_hal/AudioPolicyManager.cpp @@ -15,6 +15,24 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * This file was modified by Dolby Laboratories, Inc. The portions of the + * code that are surrounded by "DOLBY..." are copyrighted and + * licensed separately, as follows: + * + * (C) 2015 Dolby Laboratories, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #define LOG_TAG "AudioPolicyManagerCustom" @@ -46,6 +64,9 @@ #include <soundtrigger/SoundTrigger.h> #include "AudioPolicyManager.h" #include <policy.h> +#ifdef DOLBY_ENABLE +#include "DolbyAudioPolicy_impl.h" +#endif // DOLBY_END namespace android { #ifdef VOICE_CONCURRENCY @@ -246,6 +267,11 @@ status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t d } updateDevicesAndOutputs(); +#ifdef DOLBY_ENABLE + // Before closing the opened outputs, update endpoint property with device capabilities + audio_devices_t audioOutputDevice = getDeviceForStrategy(getStrategy(AUDIO_STREAM_MUSIC), true); + mDolbyAudioPolicy.setEndpointSystemProperty(audioOutputDevice, mHwModules); +#endif // DOLBY_END if (mEngine->getPhoneState() == AUDIO_MODE_IN_CALL && hasPrimaryOutput()) { audio_devices_t newDevice = getNewOutputDevice(mPrimaryOutput, false /*fromCache*/); updateCallRouting(newDevice); @@ -1356,8 +1382,8 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice( property_get("use.voice.path.for.pcm.voip", propValue, "0"); bool voipPcmSysPropEnabled = !strncmp("true", propValue, sizeof("true")); if (voipPcmSysPropEnabled && (format == AUDIO_FORMAT_PCM_16_BIT)) { - flags = (audio_output_flags_t)((flags &~AUDIO_OUTPUT_FLAG_FAST) | - AUDIO_OUTPUT_FLAG_VOIP_RX | AUDIO_OUTPUT_FLAG_DIRECT); + flags = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_VOIP_RX | + AUDIO_OUTPUT_FLAG_DIRECT); ALOGD("Set VoIP and Direct output flags for PCM format"); } } @@ -1492,18 +1518,18 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice( } else if (/* stream == AUDIO_STREAM_MUSIC && */ flags == AUDIO_OUTPUT_FLAG_NONE && property_get_bool("audio.deep_buffer.media", false /* default_value */)) { - flags = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_DEEP_BUFFER); - forced_deep = true; + forced_deep = true; } if (stream == AUDIO_STREAM_TTS) { flags = AUDIO_OUTPUT_FLAG_TTS; } // Do offload magic here - if (((flags == AUDIO_OUTPUT_FLAG_NONE) || forced_deep) && - (stream == AUDIO_STREAM_MUSIC) && (offloadInfo != NULL) && + if ((flags == AUDIO_OUTPUT_FLAG_NONE) && + (stream == AUDIO_STREAM_MUSIC) && + (offloadInfo != NULL) && ((offloadInfo->usage == AUDIO_USAGE_MEDIA) || (offloadInfo->usage == AUDIO_USAGE_GAME))) { - flags = (audio_output_flags_t)(flags | AUDIO_OUTPUT_FLAG_DIRECT); + flags = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_DIRECT_PCM); ALOGD("AudioCustomHAL --> Force Direct Flag .. flag (0x%x)", flags); } @@ -1511,7 +1537,7 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice( // skip direct output selection if the request can obviously be attached to a mixed output // and not explicitly requested - if (((flags & AUDIO_OUTPUT_FLAG_DIRECT) == 0) && + if (((flags & (AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_DIRECT_PCM)) == 0) && audio_is_linear_pcm(format) && samplingRate <= MAX_MIXER_SAMPLING_RATE && audio_channel_count_from_out_mask(channelMask) <= 2) { goto non_direct_output; @@ -1534,6 +1560,14 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice( } if (profile != 0) { + + if (!(flags & AUDIO_OUTPUT_FLAG_DIRECT_PCM) && + (profile->mFlags & AUDIO_OUTPUT_FLAG_DIRECT_PCM)) { + ALOGI("got Direct_PCM without requesting ... reject "); + profile = NULL; + goto non_direct_output; + } + sp<SwAudioOutputDescriptor> outputDesc = NULL; for (size_t i = 0; i < mOutputs.size(); i++) { @@ -1619,7 +1653,23 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice( addOutput(output, outputDesc); audio_io_handle_t dstOutput = getOutputForEffect(); if (dstOutput == output) { +#ifdef DOLBY_ENABLE + status_t status = mpClientInterface->moveEffects(AUDIO_SESSION_OUTPUT_MIX, srcOutput, dstOutput); + if (status == NO_ERROR) { + for (size_t i = 0; i < mEffects.size(); i++) { + sp<EffectDescriptor> desc = mEffects.valueAt(i); + if (desc->mSession == AUDIO_SESSION_OUTPUT_MIX) { + // update the mIo member of EffectDescriptor for the global effect + ALOGV("%s updating mIo", __FUNCTION__); + desc->mIo = dstOutput; + } + } + } else { + ALOGW("%s moveEffects from %d to %d failed", __FUNCTION__, srcOutput, dstOutput); + } +#else // DOLBY_END mpClientInterface->moveEffects(AUDIO_SESSION_OUTPUT_MIX, srcOutput, dstOutput); +#endif // LINE_ADDED_BY_DOLBY } mPreviousOutputs = mOutputs; ALOGV("getOutput() returns new direct output %d", output); @@ -1634,6 +1684,10 @@ non_direct_output: // for non direct outputs, only PCM is supported if (audio_is_linear_pcm(format)) { + if (forced_deep) { + flags = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_DEEP_BUFFER); + ALOGI("setting force DEEP buffer now "); + } // get which output is suitable for the specified stream. The actual // routing change will happen when startOutput() will be called SortedVector<audio_io_handle_t> outputs = getOutputsForDevice(device, mOutputs); |