From 6d4ef37017f9806026713d5451f8b550c4129a0b Mon Sep 17 00:00:00 2001 From: Gao Jie Date: Thu, 12 Nov 2015 08:51:22 +0800 Subject: Merge DAX2 changes Change-Id: If6fcfdef0b051f9015c127bdd7d28e3668e47435 (cherry picked from commit 4879ebb6d14558695044be0a22a89fc8b7ac24ec) Change-Id: I5ecf6c792bf1d5c481879a38231acfdb2a3ccc3e --- policy_hal/AudioPolicyManager.cpp | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp index 2b567b18..c32fafb6 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 #include "AudioPolicyManager.h" #include +#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); @@ -1619,7 +1645,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 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); -- cgit v1.2.3 From b4eabafa914f154362df253a193fa9af5fca21b0 Mon Sep 17 00:00:00 2001 From: Karthik Reddy Katta Date: Wed, 25 Nov 2015 11:18:27 +0530 Subject: audio: update flags for selection of VoIP direct output Ringtone mute is observed in LINE app MT call over BT headset. VoIP direct output isn't returned due to incorrect flags update. Primary output is returned even though the FLAG_DIRECT is set, this in turn causing issues when renderer queries for getPosition(), which is resulting in mute. Fix this by updating flags, so that track gets VoIP direct output in this scenario. Change-Id: I6d570ae6ed9e0a7506cb29be5b41687417b7d221 CRs-Fixed: 893558 --- policy_hal/AudioPolicyManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp index c32fafb6..2a604bab 100644 --- a/policy_hal/AudioPolicyManager.cpp +++ b/policy_hal/AudioPolicyManager.cpp @@ -1382,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"); } } -- cgit v1.2.3 From 5df33b292fc966596489a8cee6fa56e8d57464b0 Mon Sep 17 00:00:00 2001 From: vivek mehta Date: Wed, 25 Nov 2015 13:28:55 -0800 Subject: libaudiopolicymanager: DirectPCM: fix 44.1 clip playing noisy issue - adding both deepbuffer and direct pcm is causing issue where wrong config is set to ADM - add deepbuffer flag when fail to get direct output if deepbuffer was forced Change-Id: I3bd65002c7a8895d461df257111faf22101cbe30 --- policy_hal/AudioPolicyManager.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp index c32fafb6..927aeca1 100644 --- a/policy_hal/AudioPolicyManager.cpp +++ b/policy_hal/AudioPolicyManager.cpp @@ -1518,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); } @@ -1537,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; @@ -1560,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 outputDesc = NULL; for (size_t i = 0; i < mOutputs.size(); i++) { @@ -1676,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 outputs = getOutputsForDevice(device, mOutputs); -- cgit v1.2.3 From 3a44f582d97f9583403cde215f3e19a95dab2bec Mon Sep 17 00:00:00 2001 From: Sharad Sangle Date: Thu, 10 Dec 2015 18:39:17 +0530 Subject: HAL: Identify the track offload session The current logic for identifying the track offload session is using strlcat in wrong way, third parameter is given the string length to be appended, but in fact it should be the size of the destination buffer. Due to this the string returned is missing the last character, in case of "true", it contains "tru" due this the session is not considered as a track offload by the calling module. To fix this use sizeof of the destination buffer instead of string length of string to be appended. Change-Id: I3d456aad2ca49095a0dfe5883f4374e22a437256 CRs-Fixed: 946670 --- hal/audio_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 45b8095f..08df4624 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -2033,10 +2033,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); -- cgit v1.2.3