blob: 5de537398117211e0c1e9d4a5eb3318e611a2438 [file] [log] [blame]
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -07001/*
Sharad Sangleca67a022015-05-28 16:15:16 +05302 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -07003 * Not a contribution.
4 *
5 * Copyright (C) 2009 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
Sharad Sangleca67a022015-05-28 16:15:16 +053020#define LOG_TAG "AudioPolicyManagerCustom"
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -070021//#define LOG_NDEBUG 0
22
23//#define VERY_VERBOSE_LOGGING
24#ifdef VERY_VERBOSE_LOGGING
25#define ALOGVV ALOGV
26#else
27#define ALOGVV(a...) do { } while(0)
28#endif
29
Sharad Sangleca67a022015-05-28 16:15:16 +053030#define MIN(a, b) ((a) < (b) ? (a) : (b))
31
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -070032// A device mask for all audio output devices that are considered "remote" when evaluating
33// active output devices in isStreamActiveRemotely()
34#define APM_AUDIO_OUT_DEVICE_REMOTE_ALL AUDIO_DEVICE_OUT_REMOTE_SUBMIX
Sharad Sangleca67a022015-05-28 16:15:16 +053035// A device mask for all audio input and output devices where matching inputs/outputs on device
36// type alone is not enough: the address must match too
37#define APM_AUDIO_DEVICE_MATCH_ADDRESS_ALL (AUDIO_DEVICE_IN_REMOTE_SUBMIX | \
38 AUDIO_DEVICE_OUT_REMOTE_SUBMIX)
39// Following delay should be used if the calculated routing delay from all active
40// input streams is higher than this value
41#define MAX_VOICE_CALL_START_DELAY_MS 100
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -070042
Sharad Sangleca67a022015-05-28 16:15:16 +053043#include <inttypes.h>
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -070044#include <math.h>
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -070045
Sharad Sangleca67a022015-05-28 16:15:16 +053046#include <cutils/properties.h>
47#include <utils/Log.h>
48#include <hardware/audio.h>
49#include <hardware/audio_effect.h>
50#include <media/AudioParameter.h>
51#include <soundtrigger/SoundTrigger.h>
52#include "AudioPolicyManager.h"
53#include <policy.h>
54
55namespace android {
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -070056
57// ----------------------------------------------------------------------------
58// AudioPolicyInterface implementation
59// ----------------------------------------------------------------------------
Sharad Sangleca67a022015-05-28 16:15:16 +053060extern "C" AudioPolicyInterface* createAudioPolicyManager(
61 AudioPolicyClientInterface *clientInterface)
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -070062{
Sharad Sangleca67a022015-05-28 16:15:16 +053063 return new AudioPolicyManagerCustom(clientInterface);
64}
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -070065
Sharad Sangleca67a022015-05-28 16:15:16 +053066extern "C" void destroyAudioPolicyManager(AudioPolicyInterface *interface)
67{
68 delete interface;
69}
70
71status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t device,
72 audio_policy_dev_state_t state,
73 const char *device_address,
74 const char *device_name)
75{
76 ALOGV("setDeviceConnectionStateInt() device: 0x%X, state %d, address %s name %s",
77 device, state, device_address, device_name);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -070078
79 // connect/disconnect only 1 device at a time
80 if (!audio_is_output_device(device) && !audio_is_input_device(device)) return BAD_VALUE;
81
Sharad Sangleca67a022015-05-28 16:15:16 +053082 sp<DeviceDescriptor> devDesc =
83 mHwModules.getDeviceDescriptor(device, device_address, device_name);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -070084
85 // handle output devices
86 if (audio_is_output_device(device)) {
Sharad Sangleca67a022015-05-28 16:15:16 +053087 SortedVector <audio_io_handle_t> outputs;
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -070088
Sharad Sangleca67a022015-05-28 16:15:16 +053089 ssize_t index = mAvailableOutputDevices.indexOf(devDesc);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -070090
91 // save a copy of the opened output descriptors before any output is opened or closed
92 // by checkOutputsForDevice(). This will be needed by checkOutputForAllStrategies()
93 mPreviousOutputs = mOutputs;
94 switch (state)
95 {
96 // handle output device connection
Sharad Sangleca67a022015-05-28 16:15:16 +053097 case AUDIO_POLICY_DEVICE_STATE_AVAILABLE: {
98 if (index >= 0) {
Ramjee Singhae5f8902015-08-19 20:47:12 +053099#ifdef AUDIO_EXTN_HDMI_SPK_ENABLED
100 if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
101 if (!strncmp(device_address, "hdmi_spkr", 9)) {
102 mHdmiAudioDisabled = false;
103 } else {
104 mHdmiAudioEvent = true;
105 }
106 }
107#endif
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700108 ALOGW("setDeviceConnectionState() device already connected: %x", device);
109 return INVALID_OPERATION;
110 }
111 ALOGV("setDeviceConnectionState() connecting device %x", device);
112
Sharad Sangleca67a022015-05-28 16:15:16 +0530113 // register new device as available
114 index = mAvailableOutputDevices.add(devDesc);
Ramjee Singhae5f8902015-08-19 20:47:12 +0530115#ifdef AUDIO_EXTN_HDMI_SPK_ENABLED
116 if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
117 if (!strncmp(device_address, "hdmi_spkr", 9)) {
118 mHdmiAudioDisabled = false;
119 } else {
120 mHdmiAudioEvent = true;
121 }
122 if (mHdmiAudioDisabled || !mHdmiAudioEvent) {
123 mAvailableOutputDevices.remove(devDesc);
124 ALOGW("HDMI sink not connected, do not route audio to HDMI out");
125 return INVALID_OPERATION;
126 }
127 }
128#endif
Sharad Sangleca67a022015-05-28 16:15:16 +0530129 if (index >= 0) {
130 sp<HwModule> module = mHwModules.getModuleForDevice(device);
131 if (module == 0) {
132 ALOGD("setDeviceConnectionState() could not find HW module for device %08x",
133 device);
134 mAvailableOutputDevices.remove(devDesc);
135 return INVALID_OPERATION;
136 }
137 mAvailableOutputDevices[index]->attach(module);
138 } else {
139 return NO_MEMORY;
140 }
141
142 if (checkOutputsForDevice(devDesc, state, outputs, devDesc->mAddress) != NO_ERROR) {
143 mAvailableOutputDevices.remove(devDesc);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700144 return INVALID_OPERATION;
145 }
Sharad Sangleca67a022015-05-28 16:15:16 +0530146 // Propagate device availability to Engine
147 mEngine->setDeviceConnectionState(devDesc, state);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700148
Sharad Sangleca67a022015-05-28 16:15:16 +0530149 // outputs should never be empty here
150 ALOG_ASSERT(outputs.size() != 0, "setDeviceConnectionState():"
151 "checkOutputsForDevice() returned no outputs but status OK");
152 ALOGV("setDeviceConnectionState() checkOutputsForDevice() returned %zu outputs",
153 outputs.size());
154
155 // Send connect to HALs
156 AudioParameter param = AudioParameter(devDesc->mAddress);
157 param.addInt(String8(AUDIO_PARAMETER_DEVICE_CONNECT), device);
158 mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString());
159
160 } break;
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700161 // handle output device disconnection
Sharad Sangleca67a022015-05-28 16:15:16 +0530162 case AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE: {
163 if (index < 0) {
Ramjee Singhae5f8902015-08-19 20:47:12 +0530164#ifdef AUDIO_EXTN_HDMI_SPK_ENABLED
165 if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
166 if (!strncmp(device_address, "hdmi_spkr", 9)) {
167 mHdmiAudioDisabled = true;
168 } else {
169 mHdmiAudioEvent = false;
170 }
171 }
172#endif
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700173 ALOGW("setDeviceConnectionState() device not connected: %x", device);
174 return INVALID_OPERATION;
175 }
176
Sharad Sangleca67a022015-05-28 16:15:16 +0530177 ALOGV("setDeviceConnectionState() disconnecting output device %x", device);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700178
Sharad Sangleca67a022015-05-28 16:15:16 +0530179 // Send Disconnect to HALs
180 AudioParameter param = AudioParameter(devDesc->mAddress);
181 param.addInt(String8(AUDIO_PARAMETER_DEVICE_DISCONNECT), device);
182 mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString());
183
184 // remove device from available output devices
185 mAvailableOutputDevices.remove(devDesc);
Ramjee Singhae5f8902015-08-19 20:47:12 +0530186#ifdef AUDIO_EXTN_HDMI_SPK_ENABLED
187 if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
188 if (!strncmp(device_address, "hdmi_spkr", 9)) {
189 mHdmiAudioDisabled = true;
190 } else {
191 mHdmiAudioEvent = false;
192 }
193 }
194#endif
Sharad Sangleca67a022015-05-28 16:15:16 +0530195 checkOutputsForDevice(devDesc, state, outputs, devDesc->mAddress);
196
197 // Propagate device availability to Engine
198 mEngine->setDeviceConnectionState(devDesc, state);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700199 } break;
200
201 default:
202 ALOGE("setDeviceConnectionState() invalid state: %x", state);
203 return BAD_VALUE;
204 }
205
Sharad Sangleca67a022015-05-28 16:15:16 +0530206 // checkA2dpSuspend must run before checkOutputForAllStrategies so that A2DP
207 // output is suspended before any tracks are moved to it
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700208 checkA2dpSuspend();
209 checkOutputForAllStrategies();
210 // outputs must be closed after checkOutputForAllStrategies() is executed
211 if (!outputs.isEmpty()) {
212 for (size_t i = 0; i < outputs.size(); i++) {
Sharad Sangleca67a022015-05-28 16:15:16 +0530213 sp<SwAudioOutputDescriptor> desc = mOutputs.valueFor(outputs[i]);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700214 // close unused outputs after device disconnection or direct outputs that have been
215 // opened by checkOutputsForDevice() to query dynamic parameters
Sharad Sangleca67a022015-05-28 16:15:16 +0530216 if ((state == AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE) ||
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700217 (((desc->mFlags & AUDIO_OUTPUT_FLAG_DIRECT) != 0) &&
218 (desc->mDirectOpenCount == 0))) {
219 closeOutput(outputs[i]);
220 }
221 }
Sharad Sangleca67a022015-05-28 16:15:16 +0530222 // check again after closing A2DP output to reset mA2dpSuspended if needed
223 checkA2dpSuspend();
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700224 }
225
226 updateDevicesAndOutputs();
Sharad Sangleca67a022015-05-28 16:15:16 +0530227 if (mEngine->getPhoneState() == AUDIO_MODE_IN_CALL && hasPrimaryOutput()) {
228 audio_devices_t newDevice = getNewOutputDevice(mPrimaryOutput, false /*fromCache*/);
229 updateCallRouting(newDevice);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700230 }
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700231 for (size_t i = 0; i < mOutputs.size(); i++) {
Sharad Sangleca67a022015-05-28 16:15:16 +0530232 sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
233 if ((mEngine->getPhoneState() != AUDIO_MODE_IN_CALL) || (desc != mPrimaryOutput)) {
234 audio_devices_t newDevice = getNewOutputDevice(desc, true /*fromCache*/);
235 // do not force device change on duplicated output because if device is 0, it will
236 // also force a device 0 for the two outputs it is duplicated to which may override
237 // a valid device selection on those outputs.
238 bool force = !desc->isDuplicated()
239 && (!device_distinguishes_on_address(device)
240 // always force when disconnecting (a non-duplicated device)
241 || (state == AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE));
242 setOutputDevice(desc, newDevice, force, 0);
Satya Krishna Pindiproli5cf8c1a2014-05-08 12:22:16 +0530243 }
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700244 }
245
Sharad Sangleca67a022015-05-28 16:15:16 +0530246 mpClientInterface->onAudioPortListUpdate();
247 return NO_ERROR;
248 } // end if is output device
249
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700250 // handle input devices
251 if (audio_is_input_device(device)) {
Sharad Sangleca67a022015-05-28 16:15:16 +0530252 SortedVector <audio_io_handle_t> inputs;
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700253
Sharad Sangleca67a022015-05-28 16:15:16 +0530254 ssize_t index = mAvailableInputDevices.indexOf(devDesc);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700255 switch (state)
256 {
257 // handle input device connection
Sharad Sangleca67a022015-05-28 16:15:16 +0530258 case AUDIO_POLICY_DEVICE_STATE_AVAILABLE: {
259 if (index >= 0) {
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700260 ALOGW("setDeviceConnectionState() device already connected: %d", device);
261 return INVALID_OPERATION;
262 }
Sharad Sangleca67a022015-05-28 16:15:16 +0530263 sp<HwModule> module = mHwModules.getModuleForDevice(device);
264 if (module == NULL) {
265 ALOGW("setDeviceConnectionState(): could not find HW module for device %08x",
266 device);
267 return INVALID_OPERATION;
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700268 }
Sharad Sangleca67a022015-05-28 16:15:16 +0530269 if (checkInputsForDevice(devDesc, state, inputs, devDesc->mAddress) != NO_ERROR) {
270 return INVALID_OPERATION;
271 }
272
273 index = mAvailableInputDevices.add(devDesc);
274 if (index >= 0) {
275 mAvailableInputDevices[index]->attach(module);
276 } else {
277 return NO_MEMORY;
278 }
279
280 // Set connect to HALs
281 AudioParameter param = AudioParameter(devDesc->mAddress);
282 param.addInt(String8(AUDIO_PARAMETER_DEVICE_CONNECT), device);
283 mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString());
284
285 // Propagate device availability to Engine
286 mEngine->setDeviceConnectionState(devDesc, state);
287 } break;
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700288
289 // handle input device disconnection
Sharad Sangleca67a022015-05-28 16:15:16 +0530290 case AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE: {
291 if (index < 0) {
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700292 ALOGW("setDeviceConnectionState() device not connected: %d", device);
293 return INVALID_OPERATION;
294 }
Sharad Sangleca67a022015-05-28 16:15:16 +0530295
296 ALOGV("setDeviceConnectionState() disconnecting input device %x", device);
297
298 // Set Disconnect to HALs
299 AudioParameter param = AudioParameter(devDesc->mAddress);
300 param.addInt(String8(AUDIO_PARAMETER_DEVICE_DISCONNECT), device);
301 mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString());
302
303 checkInputsForDevice(devDesc, state, inputs, devDesc->mAddress);
304 mAvailableInputDevices.remove(devDesc);
305
306 // Propagate device availability to Engine
307 mEngine->setDeviceConnectionState(devDesc, state);
308 } break;
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700309
310 default:
311 ALOGE("setDeviceConnectionState() invalid state: %x", state);
312 return BAD_VALUE;
313 }
314
Sharad Sangleca67a022015-05-28 16:15:16 +0530315 closeAllInputs();
316
317 if (mEngine->getPhoneState() == AUDIO_MODE_IN_CALL && hasPrimaryOutput()) {
318 audio_devices_t newDevice = getNewOutputDevice(mPrimaryOutput, false /*fromCache*/);
319 updateCallRouting(newDevice);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700320 }
321
Sharad Sangleca67a022015-05-28 16:15:16 +0530322 mpClientInterface->onAudioPortListUpdate();
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700323 return NO_ERROR;
Sharad Sangleca67a022015-05-28 16:15:16 +0530324 } // end if is input device
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -0700325
326 ALOGW("setDeviceConnectionState() invalid device: %x", device);
327 return BAD_VALUE;
328}
ApurupaPattapu0c566872014-01-10 14:46:02 -0800329// This function checks for the parameters which can be offloaded.
330// This can be enhanced depending on the capability of the DSP and policy
331// of the system.
Sharad Sangleca67a022015-05-28 16:15:16 +0530332bool AudioPolicyManagerCustom::isOffloadSupported(const audio_offload_info_t& offloadInfo)
ApurupaPattapu0c566872014-01-10 14:46:02 -0800333{
Sharad Sangleca67a022015-05-28 16:15:16 +0530334 ALOGV("isOffloadSupported: SR=%u, CM=0x%x, Format=0x%x, StreamType=%d,"
335 " BitRate=%u, duration=%" PRId64 " us, has_video=%d",
ApurupaPattapu0c566872014-01-10 14:46:02 -0800336 offloadInfo.sample_rate, offloadInfo.channel_mask,
337 offloadInfo.format,
338 offloadInfo.stream_type, offloadInfo.bit_rate, offloadInfo.duration_us,
339 offloadInfo.has_video);
340
ApurupaPattapu0c566872014-01-10 14:46:02 -0800341 // Check if stream type is music, then only allow offload as of now.
342 if (offloadInfo.stream_type != AUDIO_STREAM_MUSIC)
343 {
344 ALOGV("isOffloadSupported: stream_type != MUSIC, returning false");
345 return false;
346 }
ApurupaPattapu0c566872014-01-10 14:46:02 -0800347
Preetam Singh Ranawatfdba8132015-07-21 19:30:09 +0530348 char propValue[PROPERTY_VALUE_MAX];
349 bool pcmOffload = false;
350#ifdef PCM_OFFLOAD_ENABLED
351 if ((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM_OFFLOAD) {
352 bool prop_enabled = false;
353 if ((AUDIO_FORMAT_PCM_16_BIT_OFFLOAD == offloadInfo.format) &&
354 property_get("audio.offload.pcm.16bit.enable", propValue, NULL)) {
355 prop_enabled = atoi(propValue) || !strncmp("true", propValue, 4);
356 }
357
358#ifdef PCM_OFFLOAD_ENABLED_24
359 if ((AUDIO_FORMAT_PCM_24_BIT_OFFLOAD == offloadInfo.format) &&
360 property_get("audio.offload.pcm.24bit.enable", propValue, NULL)) {
361 prop_enabled = atoi(propValue) || !strncmp("true", propValue, 4);
362 }
363#endif
364
365 if (prop_enabled) {
366 ALOGI("PCM offload property is enabled");
367 pcmOffload = true;
368 }
369
370 if (!pcmOffload) {
371 ALOGD("system property not enabled for PCM offload format[%x]",offloadInfo.format);
372 return false;
373 }
374 }
375#endif
376 if (!pcmOffload) {
377 // Check if offload has been disabled
378 if (property_get("audio.offload.disable", propValue, "0")) {
379 if (atoi(propValue) != 0) {
380 ALOGV("offload disabled by audio.offload.disable=%s", propValue );
381 return false;
382 }
383 }
384 //check if it's multi-channel AAC (includes sub formats) and FLAC format
385 if ((popcount(offloadInfo.channel_mask) > 2) &&
386 (((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_AAC) ||
387 ((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_VORBIS))) {
388 ALOGD("offload disabled for multi-channel AAC,FLAC and VORBIS format");
389 return false;
390 }
391#ifdef AUDIO_EXTN_FORMATS_ENABLED
392 //check if it's multi-channel FLAC/ALAC/WMA format with sample rate > 48k
393 if ((popcount(offloadInfo.channel_mask) > 2) &&
394 (((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_FLAC) ||
395 (((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_ALAC) && offloadInfo.sample_rate > 48000) ||
396 (((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_WMA) && offloadInfo.sample_rate > 48000) ||
397 (((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_WMA_PRO) && offloadInfo.sample_rate > 48000))) {
398 ALOGD("offload disabled for multi-channel FLAC/ALAC/WMA clips with sample rate > 48kHz");
399 return false;
400 }
401#endif
402 //TODO: enable audio offloading with video when ready
403 const bool allowOffloadWithVideo =
404 property_get_bool("audio.offload.video", false /* default_value */);
405 if (offloadInfo.has_video && !allowOffloadWithVideo) {
406 ALOGV("isOffloadSupported: has_video == true, returning false");
407 return false;
408 }
ApurupaPattapu0c566872014-01-10 14:46:02 -0800409 }
410
411 //If duration is less than minimum value defined in property, return false
412 if (property_get("audio.offload.min.duration.secs", propValue, NULL)) {
413 if (offloadInfo.duration_us < (atoi(propValue) * 1000000 )) {
414 ALOGV("Offload denied by duration < audio.offload.min.duration.secs(=%s)", propValue);
415 return false;
416 }
417 } else if (offloadInfo.duration_us < OFFLOAD_DEFAULT_MIN_DURATION_SECS * 1000000) {
418 ALOGV("Offload denied by duration < default min(=%u)", OFFLOAD_DEFAULT_MIN_DURATION_SECS);
Sharad Sangleca67a022015-05-28 16:15:16 +0530419 //duration checks only valid for MP3/AAC/ formats,
ApurupaPattapu0c566872014-01-10 14:46:02 -0800420 //do not check duration for other audio formats, e.g. dolby AAC/AC3 and amrwb+ formats
Sharad Sangleca67a022015-05-28 16:15:16 +0530421 if ((offloadInfo.format == AUDIO_FORMAT_MP3) ||
422 ((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_AAC) ||
423 ((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_FLAC) ||
424 ((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_VORBIS) ||
425 ((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_WMA) ||
426 ((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_WMA_PRO) ||
427 ((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_ALAC) ||
428 ((offloadInfo.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_APE))
ApurupaPattapu0c566872014-01-10 14:46:02 -0800429 return false;
Sharad Sangleca67a022015-05-28 16:15:16 +0530430
ApurupaPattapu0c566872014-01-10 14:46:02 -0800431 }
432
433 // Do not allow offloading if one non offloadable effect is enabled. This prevents from
434 // creating an offloaded track and tearing it down immediately after start when audioflinger
435 // detects there is an active non offloadable effect.
436 // FIXME: We should check the audio session here but we do not have it in this context.
437 // This may prevent offloading in rare situations where effects are left active by apps
438 // in the background.
Sharad Sangleca67a022015-05-28 16:15:16 +0530439 if (mEffects.isNonOffloadableEffectEnabled()) {
ApurupaPattapu0c566872014-01-10 14:46:02 -0800440 return false;
441 }
Sharad Sangleca67a022015-05-28 16:15:16 +0530442 // Check for soundcard status
443 String8 valueStr = mpClientInterface->getParameters((audio_io_handle_t)0,
444 String8("SND_CARD_STATUS"));
445 AudioParameter result = AudioParameter(valueStr);
446 int isonline = 0;
447 if ((result.getInt(String8("SND_CARD_STATUS"), isonline) == NO_ERROR)
448 && !isonline) {
449 ALOGD("copl: soundcard is offline rejecting offload request");
450 return false;
451 }
ApurupaPattapu0c566872014-01-10 14:46:02 -0800452 // See if there is a profile to support this.
453 // AUDIO_DEVICE_NONE
Sharad Sangleca67a022015-05-28 16:15:16 +0530454 sp<IOProfile> profile = getProfileForDirectOutput(AUDIO_DEVICE_NONE /*ignore device */,
ApurupaPattapu0c566872014-01-10 14:46:02 -0800455 offloadInfo.sample_rate,
456 offloadInfo.format,
457 offloadInfo.channel_mask,
458 AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD);
Sharad Sangleca67a022015-05-28 16:15:16 +0530459 ALOGV("isOffloadSupported() profile %sfound", profile != 0 ? "" : "NOT ");
460 return (profile != 0);
ApurupaPattapu0c566872014-01-10 14:46:02 -0800461}
Sharad Sangleca67a022015-05-28 16:15:16 +0530462audio_devices_t AudioPolicyManagerCustom::getNewOutputDevice(const sp<AudioOutputDescriptor>& outputDesc,
463 bool fromCache)
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -0700464{
Sharad Sangleca67a022015-05-28 16:15:16 +0530465 audio_devices_t device = AUDIO_DEVICE_NONE;
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -0700466
Sharad Sangleca67a022015-05-28 16:15:16 +0530467 ssize_t index = mAudioPatches.indexOfKey(outputDesc->mPatchHandle);
468 if (index >= 0) {
469 sp<AudioPatch> patchDesc = mAudioPatches.valueAt(index);
470 if (patchDesc->mUid != mUidCached) {
471 ALOGV("getNewOutputDevice() device %08x forced by patch %d",
472 outputDesc->device(), outputDesc->mPatchHandle);
473 return outputDesc->device();
474 }
475 }
476
477 // check the following by order of priority to request a routing change if necessary:
478 // 1: the strategy enforced audible is active and enforced on the output:
479 // use device for strategy enforced audible
480 // 2: we are in call or the strategy phone is active on the output:
481 // use device for strategy phone
482 // 3: the strategy for enforced audible is active but not enforced on the output:
483 // use the device for strategy enforced audible
484 // 4: the strategy sonification is active on the output:
485 // use device for strategy sonification
486 // 5: the strategy "respectful" sonification is active on the output:
487 // use device for strategy "respectful" sonification
488 // 6: the strategy accessibility is active on the output:
489 // use device for strategy accessibility
490 // 7: the strategy media is active on the output:
491 // use device for strategy media
492 // 8: the strategy DTMF is active on the output:
493 // use device for strategy DTMF
494 // 9: the strategy for beacon, a.k.a. "transmitted through speaker" is active on the output:
495 // use device for strategy t-t-s
496 if (isStrategyActive(outputDesc, STRATEGY_ENFORCED_AUDIBLE) &&
497 mEngine->getForceUse(AUDIO_POLICY_FORCE_FOR_SYSTEM) == AUDIO_POLICY_FORCE_SYSTEM_ENFORCED) {
498 device = getDeviceForStrategy(STRATEGY_ENFORCED_AUDIBLE, fromCache);
499 } else if (isInCall() ||
500 isStrategyActive(outputDesc, STRATEGY_PHONE)||
501 isStrategyActive(mPrimaryOutput, STRATEGY_PHONE)) {
502 device = getDeviceForStrategy(STRATEGY_PHONE, fromCache);
503 } else if (isStrategyActive(outputDesc, STRATEGY_ENFORCED_AUDIBLE)) {
504 device = getDeviceForStrategy(STRATEGY_ENFORCED_AUDIBLE, fromCache);
505 } else if (isStrategyActive(outputDesc, STRATEGY_SONIFICATION)||
506 (isStrategyActive(mPrimaryOutput,STRATEGY_SONIFICATION)
507 && (!isStrategyActive(mPrimaryOutput,STRATEGY_MEDIA)))) {
508 device = getDeviceForStrategy(STRATEGY_SONIFICATION, fromCache);
509 } else if (isStrategyActive(outputDesc, STRATEGY_SONIFICATION_RESPECTFUL)||
510 (isStrategyActive(mPrimaryOutput,STRATEGY_SONIFICATION_RESPECTFUL)
511 && (!isStrategyActive(mPrimaryOutput, STRATEGY_MEDIA)))) {
512 device = getDeviceForStrategy(STRATEGY_SONIFICATION_RESPECTFUL, fromCache);
513 } else if (isStrategyActive(outputDesc, STRATEGY_ACCESSIBILITY)) {
514 device = getDeviceForStrategy(STRATEGY_ACCESSIBILITY, fromCache);
515 } else if (isStrategyActive(outputDesc, STRATEGY_MEDIA)) {
516 device = getDeviceForStrategy(STRATEGY_MEDIA, fromCache);
517 } else if (isStrategyActive(outputDesc, STRATEGY_DTMF)) {
518 device = getDeviceForStrategy(STRATEGY_DTMF, fromCache);
519 } else if (isStrategyActive(outputDesc, STRATEGY_TRANSMITTED_THROUGH_SPEAKER)) {
520 device = getDeviceForStrategy(STRATEGY_TRANSMITTED_THROUGH_SPEAKER, fromCache);
521 } else if (isStrategyActive(outputDesc, STRATEGY_REROUTING)) {
522 device = getDeviceForStrategy(STRATEGY_REROUTING, fromCache);
523 }
524
525 ALOGV("getNewOutputDevice() selected device %x", device);
526 return device;
527}
528void AudioPolicyManagerCustom::setPhoneState(audio_mode_t state)
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -0700529{
Sharad Sangleca67a022015-05-28 16:15:16 +0530530 ALOGV("setPhoneState() state %d", state);
531 // store previous phone state for management of sonification strategy below
Ramjee Singhae5f8902015-08-19 20:47:12 +0530532 audio_devices_t newDevice = AUDIO_DEVICE_NONE;
Sharad Sangleca67a022015-05-28 16:15:16 +0530533 int oldState = mEngine->getPhoneState();
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -0700534
Sharad Sangleca67a022015-05-28 16:15:16 +0530535 if (mEngine->setPhoneState(state) != NO_ERROR) {
536 ALOGW("setPhoneState() invalid or same state %d", state);
537 return;
538 }
539 /// Opens: can these line be executed after the switch of volume curves???
540 // if leaving call state, handle special case of active streams
541 // pertaining to sonification strategy see handleIncallSonification()
Ramjee Singhf9345b32015-10-13 18:13:04 +0530542 if (isStateInCall(oldState)) {
Sharad Sangleca67a022015-05-28 16:15:16 +0530543 ALOGV("setPhoneState() in call state management: new state is %d", state);
544 for (size_t j = 0; j < mOutputs.size(); j++) {
545 audio_io_handle_t curOutput = mOutputs.keyAt(j);
546 for (int stream = 0; stream < AUDIO_STREAM_CNT; stream++) {
547 if (stream == AUDIO_STREAM_PATCH) {
548 continue;
549 }
550
551 handleIncallSonification((audio_stream_type_t)stream, false, true, curOutput);
552 }
553 }
554
555 // force reevaluating accessibility routing when call starts
556 mpClientInterface->invalidateStream(AUDIO_STREAM_ACCESSIBILITY);
557 }
558
559 /**
560 * Switching to or from incall state or switching between telephony and VoIP lead to force
561 * routing command.
562 */
563 bool force = ((is_state_in_call(oldState) != is_state_in_call(state))
564 || (is_state_in_call(state) && (state != oldState)));
565
566 // check for device and output changes triggered by new phone state
567 checkA2dpSuspend();
568 checkOutputForAllStrategies();
569 updateDevicesAndOutputs();
570
571 sp<SwAudioOutputDescriptor> hwOutputDesc = mPrimaryOutput;
572
573 int delayMs = 0;
574 if (isStateInCall(state)) {
575 nsecs_t sysTime = systemTime();
576 for (size_t i = 0; i < mOutputs.size(); i++) {
577 sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
578 // mute media and sonification strategies and delay device switch by the largest
579 // latency of any output where either strategy is active.
580 // This avoid sending the ring tone or music tail into the earpiece or headset.
581 if ((isStrategyActive(desc, STRATEGY_MEDIA,
582 SONIFICATION_HEADSET_MUSIC_DELAY,
583 sysTime) ||
584 isStrategyActive(desc, STRATEGY_SONIFICATION,
585 SONIFICATION_HEADSET_MUSIC_DELAY,
586 sysTime)) &&
587 (delayMs < (int)desc->latency()*2)) {
588 delayMs = desc->latency()*2;
589 }
590 setStrategyMute(STRATEGY_MEDIA, true, desc);
591 setStrategyMute(STRATEGY_MEDIA, false, desc, MUTE_TIME_MS,
592 getDeviceForStrategy(STRATEGY_MEDIA, true /*fromCache*/));
593 setStrategyMute(STRATEGY_SONIFICATION, true, desc);
594 setStrategyMute(STRATEGY_SONIFICATION, false, desc, MUTE_TIME_MS,
595 getDeviceForStrategy(STRATEGY_SONIFICATION, true /*fromCache*/));
596 }
597 ALOGV("Setting the delay from %dms to %dms", delayMs,
598 MIN(delayMs, MAX_VOICE_CALL_START_DELAY_MS));
599 delayMs = MIN(delayMs, MAX_VOICE_CALL_START_DELAY_MS);
600 }
601
602 if (hasPrimaryOutput()) {
603 // Note that despite the fact that getNewOutputDevice() is called on the primary output,
604 // the device returned is not necessarily reachable via this output
605 audio_devices_t rxDevice = getNewOutputDevice(mPrimaryOutput, false /*fromCache*/);
606 // force routing command to audio hardware when ending call
607 // even if no device change is needed
608 if (isStateInCall(oldState) && rxDevice == AUDIO_DEVICE_NONE) {
609 rxDevice = mPrimaryOutput->device();
610 }
611
612 if (state == AUDIO_MODE_IN_CALL) {
613 updateCallRouting(rxDevice, delayMs);
614 } else if (oldState == AUDIO_MODE_IN_CALL) {
615 if (mCallRxPatch != 0) {
616 mpClientInterface->releaseAudioPatch(mCallRxPatch->mAfPatchHandle, 0);
617 mCallRxPatch.clear();
618 }
619 if (mCallTxPatch != 0) {
620 mpClientInterface->releaseAudioPatch(mCallTxPatch->mAfPatchHandle, 0);
621 mCallTxPatch.clear();
622 }
623 setOutputDevice(mPrimaryOutput, rxDevice, force, 0);
624 } else {
625 setOutputDevice(mPrimaryOutput, rxDevice, force, 0);
626 }
627 }
Ramjee Singhae5f8902015-08-19 20:47:12 +0530628 //update device for all non-primary outputs
629 for (size_t i = 0; i < mOutputs.size(); i++) {
630 audio_io_handle_t output = mOutputs.keyAt(i);
631 if (output != mPrimaryOutput->mIoHandle) {
632 newDevice = getNewOutputDevice(mOutputs.valueFor(output), false /*fromCache*/);
633 setOutputDevice(mOutputs.valueFor(output), newDevice, (newDevice != AUDIO_DEVICE_NONE));
634 }
635 }
Sharad Sangleca67a022015-05-28 16:15:16 +0530636 // if entering in call state, handle special case of active streams
637 // pertaining to sonification strategy see handleIncallSonification()
638 if (isStateInCall(state)) {
639 ALOGV("setPhoneState() in call state management: new state is %d", state);
640 for (size_t j = 0; j < mOutputs.size(); j++) {
641 audio_io_handle_t curOutput = mOutputs.keyAt(j);
642 for (int stream = 0; stream < AUDIO_STREAM_CNT; stream++) {
643 if (stream == AUDIO_STREAM_PATCH) {
644 continue;
645 }
646 handleIncallSonification((audio_stream_type_t)stream, true, true, curOutput);
647 }
648 }
649 }
650
651 // Flag that ringtone volume must be limited to music volume until we exit MODE_RINGTONE
652 if (state == AUDIO_MODE_RINGTONE &&
653 isStreamActive(AUDIO_STREAM_MUSIC, SONIFICATION_HEADSET_MUSIC_DELAY)) {
654 mLimitRingtoneVolume = true;
655 } else {
656 mLimitRingtoneVolume = false;
657 }
658}
Dhananjay Kumar42441032015-09-16 19:44:33 +0530659
660void AudioPolicyManagerCustom::setForceUse(audio_policy_force_use_t usage,
661 audio_policy_forced_cfg_t config)
662{
663 ALOGV("setForceUse() usage %d, config %d, mPhoneState %d", usage, config, mEngine->getPhoneState());
664
665 if (mEngine->setForceUse(usage, config) != NO_ERROR) {
666 ALOGW("setForceUse() could not set force cfg %d for usage %d", config, usage);
667 return;
668 }
669 bool forceVolumeReeval = (usage == AUDIO_POLICY_FORCE_FOR_COMMUNICATION) ||
670 (usage == AUDIO_POLICY_FORCE_FOR_DOCK) ||
671 (usage == AUDIO_POLICY_FORCE_FOR_SYSTEM);
672
673 // check for device and output changes triggered by new force usage
674 checkA2dpSuspend();
675 checkOutputForAllStrategies();
676 updateDevicesAndOutputs();
677 if (mEngine->getPhoneState() == AUDIO_MODE_IN_CALL && hasPrimaryOutput()) {
678 audio_devices_t newDevice = getNewOutputDevice(mPrimaryOutput, true /*fromCache*/);
679 updateCallRouting(newDevice);
680 }
681 // Use reverse loop to make sure any low latency usecases (generally tones)
682 // are not routed before non LL usecases (generally music).
683 // We can safely assume that LL output would always have lower index,
684 // and use this work-around to avoid routing of output with music stream
685 // from the context of short lived LL output.
686 // Note: in case output's share backend(HAL sharing is implicit) all outputs
687 // gets routing update while processing first output itself.
688 for (size_t i = mOutputs.size(); i > 0; i--) {
689 sp<SwAudioOutputDescriptor> outputDesc = mOutputs.valueAt(i-1);
690 audio_devices_t newDevice = getNewOutputDevice(outputDesc, true /*fromCache*/);
691 if ((mEngine->getPhoneState() != AUDIO_MODE_IN_CALL) || outputDesc != mPrimaryOutput) {
692 setOutputDevice(outputDesc, newDevice, (newDevice != AUDIO_DEVICE_NONE));
693 }
694 if (forceVolumeReeval && (newDevice != AUDIO_DEVICE_NONE)) {
695 applyStreamVolumes(outputDesc, newDevice, 0, true);
696 }
697 }
698
699 audio_io_handle_t activeInput = mInputs.getActiveInput();
700 if (activeInput != 0) {
701 setInputDevice(activeInput, getNewInputDevice(activeInput));
702 }
703
704}
705
Ramjee Singh5b022de2015-09-15 18:25:20 +0530706status_t AudioPolicyManagerCustom::stopSource(sp<AudioOutputDescriptor> outputDesc1,
Sharad Sangleca67a022015-05-28 16:15:16 +0530707 audio_stream_type_t stream,
708 bool forceDeviceUpdate)
709{
710 // always handle stream stop, check which stream type is stopping
Steve Kondikc1ff6852015-11-01 03:58:16 -0800711 const sp<SwAudioOutputDescriptor> outputDesc = (SwAudioOutputDescriptor *) outputDesc1.get();
Sharad Sangleca67a022015-05-28 16:15:16 +0530712 handleEventForBeacon(stream == AUDIO_STREAM_TTS ? STOPPING_BEACON : STOPPING_OUTPUT);
713
714 // handle special case for sonification while in call
Ramjee Singhae5f8902015-08-19 20:47:12 +0530715 if (isInCall() && (outputDesc->mRefCount[stream] == 1)) {
Sharad Sangleca67a022015-05-28 16:15:16 +0530716 if (outputDesc->isDuplicated()) {
Ramjee Singhae5f8902015-08-19 20:47:12 +0530717 handleIncallSonification(stream, false, false, outputDesc->mOutput1->mIoHandle);
718 handleIncallSonification(stream, false, false, outputDesc->mOutput2->mIoHandle);
Sharad Sangleca67a022015-05-28 16:15:16 +0530719 }
720 handleIncallSonification(stream, false, false, outputDesc->mIoHandle);
721 }
722
723 if (outputDesc->mRefCount[stream] > 0) {
724 // decrement usage count of this stream on the output
725 outputDesc->changeRefCount(stream, -1);
726
727 // store time at which the stream was stopped - see isStreamActive()
728 if (outputDesc->mRefCount[stream] == 0 || forceDeviceUpdate) {
729 outputDesc->mStopTime[stream] = systemTime();
730 audio_devices_t newDevice = getNewOutputDevice(outputDesc, false /*fromCache*/);
731 // delay the device switch by twice the latency because stopOutput() is executed when
732 // the track stop() command is received and at that time the audio track buffer can
733 // still contain data that needs to be drained. The latency only covers the audio HAL
734 // and kernel buffers. Also the latency does not always include additional delay in the
735 // audio path (audio DSP, CODEC ...)
736 setOutputDevice(outputDesc, newDevice, false, outputDesc->latency()*2);
737
738 // force restoring the device selection on other active outputs if it differs from the
739 // one being selected for this output
740 for (size_t i = 0; i < mOutputs.size(); i++) {
741 audio_io_handle_t curOutput = mOutputs.keyAt(i);
742 sp<AudioOutputDescriptor> desc = mOutputs.valueAt(i);
743 if (desc != outputDesc &&
744 desc->isActive() &&
745 outputDesc->sharesHwModuleWith(desc) &&
746 (newDevice != desc->device())) {
Ramjee Singhae5f8902015-08-19 20:47:12 +0530747 audio_devices_t dev = getNewOutputDevice(mOutputs.valueFor(curOutput), false
748 /*fromCache*/);
749 setOutputDevice(desc,
750 dev,
Sharad Sangleca67a022015-05-28 16:15:16 +0530751 true,
752 outputDesc->latency()*2);
753 }
754 }
755 // update the outputs if stopping one with a stream that can affect notification routing
756 handleNotificationRoutingForStream(stream);
757 }
758 return NO_ERROR;
759 } else {
760 ALOGW("stopOutput() refcount is already 0");
761 return INVALID_OPERATION;
762 }
763}
Ramjee Singh5b022de2015-09-15 18:25:20 +0530764status_t AudioPolicyManagerCustom::startSource(sp<AudioOutputDescriptor> outputDesc1,
Sharad Sangleca67a022015-05-28 16:15:16 +0530765 audio_stream_type_t stream,
766 audio_devices_t device,
767 uint32_t *delayMs)
768{
769 // cannot start playback of STREAM_TTS if any other output is being used
770 uint32_t beaconMuteLatency = 0;
Steve Kondikc1ff6852015-11-01 03:58:16 -0800771 const sp<SwAudioOutputDescriptor> outputDesc = (SwAudioOutputDescriptor *) outputDesc1.get();
Sharad Sangleca67a022015-05-28 16:15:16 +0530772
773 *delayMs = 0;
774 if (stream == AUDIO_STREAM_TTS) {
775 ALOGV("\t found BEACON stream");
776 if (mOutputs.isAnyOutputActive(AUDIO_STREAM_TTS /*streamToIgnore*/)) {
777 return INVALID_OPERATION;
778 } else {
779 beaconMuteLatency = handleEventForBeacon(STARTING_BEACON);
780 }
781 } else {
782 // some playback other than beacon starts
783 beaconMuteLatency = handleEventForBeacon(STARTING_OUTPUT);
784 }
785
786 // increment usage count for this stream on the requested output:
787 // NOTE that the usage count is the same for duplicated output and hardware output which is
788 // necessary for a correct control of hardware output routing by startOutput() and stopOutput()
789 outputDesc->changeRefCount(stream, 1);
790
791 if (outputDesc->mRefCount[stream] == 1 || device != AUDIO_DEVICE_NONE) {
792 // starting an output being rerouted?
793 if (device == AUDIO_DEVICE_NONE) {
794 device = getNewOutputDevice(outputDesc, false /*fromCache*/);
795 }
796 routing_strategy strategy = getStrategy(stream);
797 bool shouldWait = (strategy == STRATEGY_SONIFICATION) ||
798 (strategy == STRATEGY_SONIFICATION_RESPECTFUL) ||
799 (beaconMuteLatency > 0);
800 uint32_t waitMs = beaconMuteLatency;
801 bool force = false;
802 for (size_t i = 0; i < mOutputs.size(); i++) {
803 sp<AudioOutputDescriptor> desc = mOutputs.valueAt(i);
804 if (desc != outputDesc) {
805 // force a device change if any other output is managed by the same hw
806 // module and has a current device selection that differs from selected device.
807 // In this case, the audio HAL must receive the new device selection so that it can
808 // change the device currently selected by the other active output.
809 if (outputDesc->sharesHwModuleWith(desc) &&
810 desc->device() != device) {
811 force = true;
812 }
813 // wait for audio on other active outputs to be presented when starting
814 // a notification so that audio focus effect can propagate, or that a mute/unmute
815 // event occurred for beacon
816 uint32_t latency = desc->latency();
817 if (shouldWait && desc->isActive(latency * 2) && (waitMs < latency)) {
818 waitMs = latency;
819 }
820 }
821 }
822 uint32_t muteWaitMs = setOutputDevice(outputDesc, device, force);
823
824 // handle special case for sonification while in call
825 if (isInCall()) {
826 handleIncallSonification(stream, true, false, outputDesc->mIoHandle);
827 }
828
829 // apply volume rules for current stream and device if necessary
830 checkAndSetVolume(stream,
831 mStreams.valueFor(stream).getVolumeIndex(device),
832 outputDesc,
833 device);
834
835 // update the outputs if starting an output with a stream that can affect notification
836 // routing
837 handleNotificationRoutingForStream(stream);
838
839 // force reevaluating accessibility routing when ringtone or alarm starts
840 if (strategy == STRATEGY_SONIFICATION) {
841 mpClientInterface->invalidateStream(AUDIO_STREAM_ACCESSIBILITY);
842 }
843 }
844 else {
845 // handle special case for sonification while in call
846 if (isInCall()) {
847 handleIncallSonification(stream, true, false, outputDesc->mIoHandle);
848 }
849 }
850 return NO_ERROR;
851}
852void AudioPolicyManagerCustom::handleIncallSonification(audio_stream_type_t stream,
853 bool starting, bool stateChange,
854 audio_io_handle_t output)
855{
856 if(!hasPrimaryOutput()) {
857 return;
858 }
859 // no action needed for AUDIO_STREAM_PATCH stream type, it's for internal flinger tracks
860 if (stream == AUDIO_STREAM_PATCH) {
861 return;
862 }
863 // if the stream pertains to sonification strategy and we are in call we must
864 // mute the stream if it is low visibility. If it is high visibility, we must play a tone
865 // in the device used for phone strategy and play the tone if the selected device does not
866 // interfere with the device used for phone strategy
867 // if stateChange is true, we are called from setPhoneState() and we must mute or unmute as
868 // many times as there are active tracks on the output
869 const routing_strategy stream_strategy = getStrategy(stream);
870 if ((stream_strategy == STRATEGY_SONIFICATION) ||
871 ((stream_strategy == STRATEGY_SONIFICATION_RESPECTFUL))) {
872 sp<SwAudioOutputDescriptor> outputDesc = mOutputs.valueFor(output);
873 ALOGV("handleIncallSonification() stream %d starting %d device %x stateChange %d",
874 stream, starting, outputDesc->mDevice, stateChange);
875 if (outputDesc->mRefCount[stream]) {
876 int muteCount = 1;
877 if (stateChange) {
878 muteCount = outputDesc->mRefCount[stream];
879 }
880 if (audio_is_low_visibility(stream)) {
881 ALOGV("handleIncallSonification() low visibility, muteCount %d", muteCount);
882 for (int i = 0; i < muteCount; i++) {
883 setStreamMute(stream, starting, outputDesc);
884 }
885 } else {
886 ALOGV("handleIncallSonification() high visibility");
887 if (outputDesc->device() &
888 getDeviceForStrategy(STRATEGY_PHONE, true /*fromCache*/)) {
889 ALOGV("handleIncallSonification() high visibility muted, muteCount %d", muteCount);
890 for (int i = 0; i < muteCount; i++) {
891 setStreamMute(stream, starting, outputDesc);
892 }
893 }
894 if (starting) {
895 mpClientInterface->startTone(AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION,
896 AUDIO_STREAM_VOICE_CALL);
897 } else {
898 mpClientInterface->stopTone();
899 }
900 }
901 }
902 }
903}
904void AudioPolicyManagerCustom::handleNotificationRoutingForStream(audio_stream_type_t stream) {
905 switch(stream) {
906 case AUDIO_STREAM_MUSIC:
907 checkOutputForStrategy(STRATEGY_SONIFICATION_RESPECTFUL);
908 updateDevicesAndOutputs();
909 break;
910 default:
911 break;
912 }
913}
914status_t AudioPolicyManagerCustom::checkAndSetVolume(audio_stream_type_t stream,
915 int index,
Steve Kondikc1ff6852015-11-01 03:58:16 -0800916 const sp<AudioOutputDescriptor>& outputDesc1,
Sharad Sangleca67a022015-05-28 16:15:16 +0530917 audio_devices_t device,
918 int delayMs, bool force)
919{
Steve Kondikc1ff6852015-11-01 03:58:16 -0800920 const sp<SwAudioOutputDescriptor> outputDesc = (SwAudioOutputDescriptor *) outputDesc1.get();
921
Sharad Sangleca67a022015-05-28 16:15:16 +0530922 // do not change actual stream volume if the stream is muted
923 if (outputDesc->mMuteCount[stream] != 0) {
924 ALOGVV("checkAndSetVolume() stream %d muted count %d",
925 stream, outputDesc->mMuteCount[stream]);
926 return NO_ERROR;
927 }
928 audio_policy_forced_cfg_t forceUseForComm =
929 mEngine->getForceUse(AUDIO_POLICY_FORCE_FOR_COMMUNICATION);
930 // do not change in call volume if bluetooth is connected and vice versa
931 if ((stream == AUDIO_STREAM_VOICE_CALL && forceUseForComm == AUDIO_POLICY_FORCE_BT_SCO) ||
932 (stream == AUDIO_STREAM_BLUETOOTH_SCO && forceUseForComm != AUDIO_POLICY_FORCE_BT_SCO)) {
933 ALOGV("checkAndSetVolume() cannot set stream %d volume with force use = %d for comm",
934 stream, forceUseForComm);
935 return INVALID_OPERATION;
936 }
937
938 if (device == AUDIO_DEVICE_NONE) {
939 device = outputDesc->device();
940 }
941
942 float volumeDb = computeVolume(stream, index, device);
943 if (outputDesc->isFixedVolume(device)) {
944 volumeDb = 0.0f;
945 }
946
947 outputDesc->setVolume(volumeDb, stream, device, delayMs, force);
948
949 if (stream == AUDIO_STREAM_VOICE_CALL ||
950 stream == AUDIO_STREAM_BLUETOOTH_SCO) {
951 float voiceVolume;
952 // Force voice volume to max for bluetooth SCO as volume is managed by the headset
953 if (stream == AUDIO_STREAM_VOICE_CALL) {
954 voiceVolume = (float)index/(float)mStreams.valueFor(stream).getVolumeIndexMax();
955 } else {
956 voiceVolume = 1.0;
957 }
958
959 if (voiceVolume != mLastVoiceVolume && ((outputDesc == mPrimaryOutput) ||
960 isDirectOutput(outputDesc->mIoHandle) || device & AUDIO_DEVICE_OUT_ALL_USB)) {
961 mpClientInterface->setVoiceVolume(voiceVolume, delayMs);
962 mLastVoiceVolume = voiceVolume;
963 }
964 }
965
966 return NO_ERROR;
967}
968bool AudioPolicyManagerCustom::isDirectOutput(audio_io_handle_t output) {
969 for (size_t i = 0; i < mOutputs.size(); i++) {
970 audio_io_handle_t curOutput = mOutputs.keyAt(i);
971 sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
972 if ((curOutput == output) && (desc->mFlags & AUDIO_OUTPUT_FLAG_DIRECT)) {
973 return true;
974 }
975 }
976 return false;
977}
978audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevice(
979 audio_devices_t device,
980 audio_session_t session __unused,
981 audio_stream_type_t stream,
982 uint32_t samplingRate,
983 audio_format_t format,
984 audio_channel_mask_t channelMask,
985 audio_output_flags_t flags,
986 const audio_offload_info_t *offloadInfo)
987{
988 audio_io_handle_t output = AUDIO_IO_HANDLE_NONE;
989 uint32_t latency = 0;
990 status_t status;
991
992#ifdef AUDIO_POLICY_TEST
993 if (mCurOutput != 0) {
994 ALOGV("getOutput() test output mCurOutput %d, samplingRate %d, format %d, channelMask %x, mDirectOutput %d",
995 mCurOutput, mTestSamplingRate, mTestFormat, mTestChannels, mDirectOutput);
996
997 if (mTestOutputs[mCurOutput] == 0) {
998 ALOGV("getOutput() opening test output");
999 sp<AudioOutputDescriptor> outputDesc = new SwAudioOutputDescriptor(NULL,
1000 mpClientInterface);
1001 outputDesc->mDevice = mTestDevice;
1002 outputDesc->mLatency = mTestLatencyMs;
1003 outputDesc->mFlags =
1004 (audio_output_flags_t)(mDirectOutput ? AUDIO_OUTPUT_FLAG_DIRECT : 0);
1005 outputDesc->mRefCount[stream] = 0;
1006 audio_config_t config = AUDIO_CONFIG_INITIALIZER;
1007 config.sample_rate = mTestSamplingRate;
1008 config.channel_mask = mTestChannels;
1009 config.format = mTestFormat;
1010 if (offloadInfo != NULL) {
1011 config.offload_info = *offloadInfo;
1012 }
1013 status = mpClientInterface->openOutput(0,
1014 &mTestOutputs[mCurOutput],
1015 &config,
1016 &outputDesc->mDevice,
1017 String8(""),
1018 &outputDesc->mLatency,
1019 outputDesc->mFlags);
1020 if (status == NO_ERROR) {
1021 outputDesc->mSamplingRate = config.sample_rate;
1022 outputDesc->mFormat = config.format;
1023 outputDesc->mChannelMask = config.channel_mask;
1024 AudioParameter outputCmd = AudioParameter();
1025 outputCmd.addInt(String8("set_id"),mCurOutput);
1026 mpClientInterface->setParameters(mTestOutputs[mCurOutput],outputCmd.toString());
1027 addOutput(mTestOutputs[mCurOutput], outputDesc);
1028 }
1029 }
1030 return mTestOutputs[mCurOutput];
1031 }
1032#endif //AUDIO_POLICY_TEST
1033 if (((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) != 0) &&
1034 (stream != AUDIO_STREAM_MUSIC)) {
1035 // compress should not be used for non-music streams
1036 ALOGE("Offloading only allowed with music stream");
1037 return 0;
Karthik Reddy Kattaeb605c92015-07-14 16:05:18 +05301038 }
1039
1040 if ((stream == AUDIO_STREAM_VOICE_CALL) &&
1041 (channelMask == 1) &&
1042 (samplingRate == 8000 || samplingRate == 16000)) {
1043 // Allow Voip direct output only if:
1044 // audio mode is MODE_IN_COMMUNCATION; AND
1045 // voip output is not opened already; AND
1046 // requested sample rate matches with that of voip input stream (if opened already)
1047 int value = 0;
1048 uint32_t mode = 0, voipOutCount = 1, voipSampleRate = 1;
1049 String8 valueStr = mpClientInterface->getParameters((audio_io_handle_t)0,
1050 String8("audio_mode"));
1051 AudioParameter result = AudioParameter(valueStr);
1052 if (result.getInt(String8("audio_mode"), value) == NO_ERROR) {
1053 mode = value;
1054 }
1055
1056 valueStr = mpClientInterface->getParameters((audio_io_handle_t)0,
1057 String8("voip_out_stream_count"));
1058 result = AudioParameter(valueStr);
1059 if (result.getInt(String8("voip_out_stream_count"), value) == NO_ERROR) {
1060 voipOutCount = value;
1061 }
1062
1063 valueStr = mpClientInterface->getParameters((audio_io_handle_t)0,
1064 String8("voip_sample_rate"));
1065 result = AudioParameter(valueStr);
1066 if (result.getInt(String8("voip_sample_rate"), value) == NO_ERROR) {
1067 voipSampleRate = value;
1068 }
1069
1070 if ((mode == AUDIO_MODE_IN_COMMUNICATION) && (voipOutCount == 0) &&
1071 ((voipSampleRate == 0) || (voipSampleRate == samplingRate))) {
1072 if (audio_is_linear_pcm(format)) {
1073 char propValue[PROPERTY_VALUE_MAX] = {0};
1074 property_get("use.voice.path.for.pcm.voip", propValue, "0");
1075 bool voipPcmSysPropEnabled = !strncmp("true", propValue, sizeof("true"));
1076 if (voipPcmSysPropEnabled && (format == AUDIO_FORMAT_PCM_16_BIT)) {
1077 flags = (audio_output_flags_t)((flags &~AUDIO_OUTPUT_FLAG_FAST) |
1078 AUDIO_OUTPUT_FLAG_VOIP_RX | AUDIO_OUTPUT_FLAG_DIRECT);
1079 ALOGD("Set VoIP and Direct output flags for PCM format");
1080 }
1081 }
1082 }
Sharad Sangleca67a022015-05-28 16:15:16 +05301083 }
Karthik Reddy Kattaeb605c92015-07-14 16:05:18 +05301084
Ramjee Singhae5f8902015-08-19 20:47:12 +05301085#ifdef AUDIO_EXTN_AFE_PROXY_ENABLED
Sharad Sangleca67a022015-05-28 16:15:16 +05301086 /*
1087 * WFD audio routes back to target speaker when starting a ringtone playback.
1088 * This is because primary output is reused for ringtone, so output device is
1089 * updated based on SONIFICATION strategy for both ringtone and music playback.
1090 * The same issue is not seen on remoted_submix HAL based WFD audio because
1091 * primary output is not reused and a new output is created for ringtone playback.
1092 * Issue is fixed by updating output flag to AUDIO_OUTPUT_FLAG_FAST when there is
1093 * a non-music stream playback on WFD, so primary output is not reused for ringtone.
1094 */
1095 audio_devices_t availableOutputDeviceTypes = mAvailableOutputDevices.types();
1096 if ((availableOutputDeviceTypes & AUDIO_DEVICE_OUT_PROXY)
1097 && (stream != AUDIO_STREAM_MUSIC)) {
1098 ALOGD("WFD audio: use OUTPUT_FLAG_FAST for non music stream. flags:%x", flags );
1099 //For voip paths
1100 if(flags & AUDIO_OUTPUT_FLAG_DIRECT)
1101 flags = AUDIO_OUTPUT_FLAG_DIRECT;
1102 else //route every thing else to ULL path
1103 flags = AUDIO_OUTPUT_FLAG_FAST;
1104 }
Ramjee Singhae5f8902015-08-19 20:47:12 +05301105#endif
Sharad Sangleca67a022015-05-28 16:15:16 +05301106 // open a direct output if required by specified parameters
1107 //force direct flag if offload flag is set: offloading implies a direct output stream
1108 // and all common behaviors are driven by checking only the direct flag
1109 // this should normally be set appropriately in the policy configuration file
1110 if ((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) != 0) {
1111 flags = (audio_output_flags_t)(flags | AUDIO_OUTPUT_FLAG_DIRECT);
1112 }
1113 if ((flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC) != 0) {
1114 flags = (audio_output_flags_t)(flags | AUDIO_OUTPUT_FLAG_DIRECT);
1115 }
1116 // only allow deep buffering for music stream type
1117 if (stream != AUDIO_STREAM_MUSIC) {
1118 flags = (audio_output_flags_t)(flags &~AUDIO_OUTPUT_FLAG_DEEP_BUFFER);
Sharad Sangle412d96c2015-08-03 17:55:48 +05301119 } else if (/* stream == AUDIO_STREAM_MUSIC && */
1120 flags == AUDIO_OUTPUT_FLAG_NONE &&
1121 property_get_bool("audio.deep_buffer.media", false /* default_value */)) {
1122 flags = (audio_output_flags_t)AUDIO_OUTPUT_FLAG_DEEP_BUFFER;
Sharad Sangleca67a022015-05-28 16:15:16 +05301123 }
Sharad Sangle412d96c2015-08-03 17:55:48 +05301124
Sharad Sangleca67a022015-05-28 16:15:16 +05301125 if (stream == AUDIO_STREAM_TTS) {
1126 flags = AUDIO_OUTPUT_FLAG_TTS;
1127 }
1128
1129 sp<IOProfile> profile;
1130
1131 // skip direct output selection if the request can obviously be attached to a mixed output
1132 // and not explicitly requested
1133 if (((flags & AUDIO_OUTPUT_FLAG_DIRECT) == 0) &&
1134 audio_is_linear_pcm(format) && samplingRate <= MAX_MIXER_SAMPLING_RATE &&
1135 audio_channel_count_from_out_mask(channelMask) <= 2) {
1136 goto non_direct_output;
1137 }
1138
1139 // Do not allow offloading if one non offloadable effect is enabled. This prevents from
1140 // creating an offloaded track and tearing it down immediately after start when audioflinger
1141 // detects there is an active non offloadable effect.
1142 // FIXME: We should check the audio session here but we do not have it in this context.
1143 // This may prevent offloading in rare situations where effects are left active by apps
1144 // in the background.
1145
1146 if (((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0) ||
1147 !mEffects.isNonOffloadableEffectEnabled()) {
1148 profile = getProfileForDirectOutput(device,
1149 samplingRate,
1150 format,
1151 channelMask,
1152 (audio_output_flags_t)flags);
1153 }
1154
1155 if (profile != 0) {
1156 sp<SwAudioOutputDescriptor> outputDesc = NULL;
1157
1158 for (size_t i = 0; i < mOutputs.size(); i++) {
1159 sp<SwAudioOutputDescriptor> desc = mOutputs.valueAt(i);
1160 if (!desc->isDuplicated() && (profile == desc->mProfile)) {
1161 outputDesc = desc;
1162 // reuse direct output if currently open and configured with same parameters
1163 if ((samplingRate == outputDesc->mSamplingRate) &&
1164 (format == outputDesc->mFormat) &&
1165 (channelMask == outputDesc->mChannelMask)) {
1166 outputDesc->mDirectOpenCount++;
1167 ALOGV("getOutput() reusing direct output %d", mOutputs.keyAt(i));
1168 return mOutputs.keyAt(i);
1169 }
1170 }
1171 }
1172 // close direct output if currently open and configured with different parameters
1173 if (outputDesc != NULL) {
1174 closeOutput(outputDesc->mIoHandle);
1175 }
1176
1177 // if the selected profile is offloaded and no offload info was specified,
1178 // create a default one
1179 audio_offload_info_t defaultOffloadInfo = AUDIO_INFO_INITIALIZER;
1180 if ((profile->mFlags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) && !offloadInfo) {
1181 flags = (audio_output_flags_t)(flags | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD);
1182 defaultOffloadInfo.sample_rate = samplingRate;
1183 defaultOffloadInfo.channel_mask = channelMask;
1184 defaultOffloadInfo.format = format;
1185 defaultOffloadInfo.stream_type = stream;
1186 defaultOffloadInfo.bit_rate = 0;
1187 defaultOffloadInfo.duration_us = -1;
1188 defaultOffloadInfo.has_video = true; // conservative
1189 defaultOffloadInfo.is_streaming = true; // likely
1190 offloadInfo = &defaultOffloadInfo;
1191 }
1192
1193 outputDesc = new SwAudioOutputDescriptor(profile, mpClientInterface);
1194 outputDesc->mDevice = device;
1195 outputDesc->mLatency = 0;
1196 outputDesc->mFlags = (audio_output_flags_t)(outputDesc->mFlags | flags);
1197 audio_config_t config = AUDIO_CONFIG_INITIALIZER;
1198 config.sample_rate = samplingRate;
1199 config.channel_mask = channelMask;
1200 config.format = format;
1201 if (offloadInfo != NULL) {
1202 config.offload_info = *offloadInfo;
1203 }
1204 status = mpClientInterface->openOutput(profile->getModuleHandle(),
1205 &output,
1206 &config,
1207 &outputDesc->mDevice,
1208 String8(""),
1209 &outputDesc->mLatency,
1210 outputDesc->mFlags);
1211
1212 // only accept an output with the requested parameters
1213 if (status != NO_ERROR ||
1214 (samplingRate != 0 && samplingRate != config.sample_rate) ||
1215 (format != AUDIO_FORMAT_DEFAULT && format != config.format) ||
1216 (channelMask != 0 && channelMask != config.channel_mask)) {
1217 ALOGV("getOutput() failed opening direct output: output %d samplingRate %d %d,"
1218 "format %d %d, channelMask %04x %04x", output, samplingRate,
1219 outputDesc->mSamplingRate, format, outputDesc->mFormat, channelMask,
1220 outputDesc->mChannelMask);
1221 if (output != AUDIO_IO_HANDLE_NONE) {
1222 mpClientInterface->closeOutput(output);
1223 }
1224 // fall back to mixer output if possible when the direct output could not be open
1225 if (audio_is_linear_pcm(format) && samplingRate <= MAX_MIXER_SAMPLING_RATE) {
1226 goto non_direct_output;
1227 }
1228 return AUDIO_IO_HANDLE_NONE;
1229 }
1230 outputDesc->mSamplingRate = config.sample_rate;
1231 outputDesc->mChannelMask = config.channel_mask;
1232 outputDesc->mFormat = config.format;
1233 outputDesc->mRefCount[stream] = 0;
1234 outputDesc->mStopTime[stream] = 0;
1235 outputDesc->mDirectOpenCount = 1;
1236
1237 audio_io_handle_t srcOutput = getOutputForEffect();
1238 addOutput(output, outputDesc);
1239 audio_io_handle_t dstOutput = getOutputForEffect();
1240 if (dstOutput == output) {
1241 mpClientInterface->moveEffects(AUDIO_SESSION_OUTPUT_MIX, srcOutput, dstOutput);
1242 }
1243 mPreviousOutputs = mOutputs;
1244 ALOGV("getOutput() returns new direct output %d", output);
1245 mpClientInterface->onAudioPortListUpdate();
1246 return output;
1247 }
1248
1249non_direct_output:
1250 // ignoring channel mask due to downmix capability in mixer
1251
1252 // open a non direct output
1253
1254 // for non direct outputs, only PCM is supported
1255 if (audio_is_linear_pcm(format)) {
1256 // get which output is suitable for the specified stream. The actual
1257 // routing change will happen when startOutput() will be called
1258 SortedVector<audio_io_handle_t> outputs = getOutputsForDevice(device, mOutputs);
1259
1260 // at this stage we should ignore the DIRECT flag as no direct output could be found earlier
1261 flags = (audio_output_flags_t)(flags & ~AUDIO_OUTPUT_FLAG_DIRECT);
1262 output = selectOutput(outputs, flags, format);
1263 }
1264 ALOGW_IF((output == 0), "getOutput() could not find output for stream %d, samplingRate %d,"
1265 "format %d, channels %x, flags %x", stream, samplingRate, format, channelMask, flags);
1266
1267 ALOGV(" getOutputForDevice() returns output %d", output);
1268
1269 return output;
1270}
Ramjee Singh58a28312015-08-14 14:40:44 +05301271
Mingming Yin38877802015-10-05 15:24:04 -07001272AudioPolicyManagerCustom::AudioPolicyManagerCustom(AudioPolicyClientInterface *clientInterface)
1273 : AudioPolicyManager(clientInterface),
1274 mHdmiAudioDisabled(false),
1275 mHdmiAudioEvent(false),
1276 mPrevPhoneState(0)
1277{
1278 char ssr_enabled[PROPERTY_VALUE_MAX] = {0};
1279 bool prop_ssr_enabled = false;
1280
1281 if (property_get("ro.qc.sdk.audio.ssr", ssr_enabled, NULL)) {
1282 prop_ssr_enabled = atoi(ssr_enabled) || !strncmp("true", ssr_enabled, 4);
1283 }
1284
1285 for (size_t i = 0; i < mHwModules.size(); i++) {
1286 ALOGV("Hw module %d", i);
1287 for (size_t j = 0; j < mHwModules[i]->mInputProfiles.size(); j++) {
1288 const sp<IOProfile> inProfile = mHwModules[i]->mInputProfiles[j];
Steve Kondik13582572015-12-05 17:19:19 -08001289 ALOGV("Input profile %d", j);
Mingming Yin38877802015-10-05 15:24:04 -07001290 for (size_t k = 0; k < inProfile->mChannelMasks.size(); k++) {
1291 audio_channel_mask_t channelMask =
1292 inProfile->mChannelMasks.itemAt(k);
1293 ALOGV("Channel Mask %x size %d", channelMask,
1294 inProfile->mChannelMasks.size());
1295 if (AUDIO_CHANNEL_IN_5POINT1 == channelMask) {
1296 if (!prop_ssr_enabled) {
1297 ALOGI("removing AUDIO_CHANNEL_IN_5POINT1 from"
1298 " input profile as SSR(surround sound record)"
1299 " is not supported on this chipset variant");
1300 inProfile->mChannelMasks.removeItemsAt(k, 1);
1301 ALOGV("Channel Mask size now %d",
1302 inProfile->mChannelMasks.size());
1303 }
1304 }
1305 }
1306 }
1307 }
1308
1309#ifdef RECORD_PLAY_CONCURRENCY
1310 mIsInputRequestOnProgress = false;
1311#endif
1312
1313
1314#ifdef VOICE_CONCURRENCY
1315 mFallBackflag = getFallBackPath();
1316#endif
1317}
1318
Sharad Sangleca67a022015-05-28 16:15:16 +05301319}