blob: e86ae5f469c46662582b43f67d856cfa8367e8ec [file] [log] [blame]
François Gaffie2110e042015-03-24 08:41:51 +01001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "APM::AudioPolicyEngine"
18//#define LOG_NDEBUG 0
19
20//#define VERY_VERBOSE_LOGGING
21#ifdef VERY_VERBOSE_LOGGING
22#define ALOGVV ALOGV
23#else
24#define ALOGVV(a...) do { } while(0)
25#endif
26
27#include "Engine.h"
Chih-Hung Hsieh2b487032018-09-13 14:16:02 -070028#include <android-base/macros.h>
François Gaffie2110e042015-03-24 08:41:51 +010029#include <AudioPolicyManagerObserver.h>
30#include <AudioPort.h>
31#include <IOProfile.h>
32#include <policy.h>
33#include <utils/String8.h>
34#include <utils/Log.h>
35
36namespace android
37{
38namespace audio_policy
39{
40
41Engine::Engine()
42 : mManagerInterface(this),
43 mPhoneState(AUDIO_MODE_NORMAL),
44 mApmObserver(NULL)
45{
46 for (int i = 0; i < AUDIO_POLICY_FORCE_USE_CNT; i++) {
47 mForceUse[i] = AUDIO_POLICY_FORCE_NONE;
48 }
49}
50
51Engine::~Engine()
52{
53}
54
55void Engine::setObserver(AudioPolicyManagerObserver *observer)
56{
57 ALOG_ASSERT(observer != NULL, "Invalid Audio Policy Manager observer");
58 mApmObserver = observer;
59}
60
61status_t Engine::initCheck()
62{
63 return (mApmObserver != NULL) ? NO_ERROR : NO_INIT;
64}
65
François Gaffie2110e042015-03-24 08:41:51 +010066status_t Engine::setPhoneState(audio_mode_t state)
67{
68 ALOGV("setPhoneState() state %d", state);
69
70 if (state < 0 || state >= AUDIO_MODE_CNT) {
71 ALOGW("setPhoneState() invalid state %d", state);
72 return BAD_VALUE;
73 }
74
75 if (state == mPhoneState ) {
76 ALOGW("setPhoneState() setting same state %d", state);
77 return BAD_VALUE;
78 }
79
80 // store previous phone state for management of sonification strategy below
81 int oldState = mPhoneState;
82 mPhoneState = state;
François Gaffied1ab2bd2015-12-02 18:20:06 +010083
François Gaffie2110e042015-03-24 08:41:51 +010084 if (!is_state_in_call(oldState) && is_state_in_call(state)) {
85 ALOGV(" Entering call in setPhoneState()");
François Gaffied1ab2bd2015-12-02 18:20:06 +010086 mApmObserver->getVolumeCurves().switchVolumeCurve(AUDIO_STREAM_VOICE_CALL,
87 AUDIO_STREAM_DTMF);
François Gaffie2110e042015-03-24 08:41:51 +010088 } else if (is_state_in_call(oldState) && !is_state_in_call(state)) {
89 ALOGV(" Exiting call in setPhoneState()");
François Gaffied1ab2bd2015-12-02 18:20:06 +010090 mApmObserver->getVolumeCurves().restoreOriginVolumeCurve(AUDIO_STREAM_DTMF);
François Gaffie2110e042015-03-24 08:41:51 +010091 }
92 return NO_ERROR;
93}
94
95status_t Engine::setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config)
96{
97 switch(usage) {
98 case AUDIO_POLICY_FORCE_FOR_COMMUNICATION:
99 if (config != AUDIO_POLICY_FORCE_SPEAKER && config != AUDIO_POLICY_FORCE_BT_SCO &&
100 config != AUDIO_POLICY_FORCE_NONE) {
101 ALOGW("setForceUse() invalid config %d for FOR_COMMUNICATION", config);
102 return BAD_VALUE;
103 }
104 mForceUse[usage] = config;
105 break;
106 case AUDIO_POLICY_FORCE_FOR_MEDIA:
107 if (config != AUDIO_POLICY_FORCE_HEADPHONES && config != AUDIO_POLICY_FORCE_BT_A2DP &&
108 config != AUDIO_POLICY_FORCE_WIRED_ACCESSORY &&
109 config != AUDIO_POLICY_FORCE_ANALOG_DOCK &&
110 config != AUDIO_POLICY_FORCE_DIGITAL_DOCK && config != AUDIO_POLICY_FORCE_NONE &&
111 config != AUDIO_POLICY_FORCE_NO_BT_A2DP && config != AUDIO_POLICY_FORCE_SPEAKER ) {
112 ALOGW("setForceUse() invalid config %d for FOR_MEDIA", config);
113 return BAD_VALUE;
114 }
115 mForceUse[usage] = config;
116 break;
117 case AUDIO_POLICY_FORCE_FOR_RECORD:
118 if (config != AUDIO_POLICY_FORCE_BT_SCO && config != AUDIO_POLICY_FORCE_WIRED_ACCESSORY &&
119 config != AUDIO_POLICY_FORCE_NONE) {
120 ALOGW("setForceUse() invalid config %d for FOR_RECORD", config);
121 return BAD_VALUE;
122 }
123 mForceUse[usage] = config;
124 break;
125 case AUDIO_POLICY_FORCE_FOR_DOCK:
126 if (config != AUDIO_POLICY_FORCE_NONE && config != AUDIO_POLICY_FORCE_BT_CAR_DOCK &&
127 config != AUDIO_POLICY_FORCE_BT_DESK_DOCK &&
128 config != AUDIO_POLICY_FORCE_WIRED_ACCESSORY &&
129 config != AUDIO_POLICY_FORCE_ANALOG_DOCK &&
130 config != AUDIO_POLICY_FORCE_DIGITAL_DOCK) {
131 ALOGW("setForceUse() invalid config %d for FOR_DOCK", config);
132 }
133 mForceUse[usage] = config;
134 break;
135 case AUDIO_POLICY_FORCE_FOR_SYSTEM:
136 if (config != AUDIO_POLICY_FORCE_NONE &&
137 config != AUDIO_POLICY_FORCE_SYSTEM_ENFORCED) {
138 ALOGW("setForceUse() invalid config %d for FOR_SYSTEM", config);
139 }
140 mForceUse[usage] = config;
141 break;
142 case AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO:
143 if (config != AUDIO_POLICY_FORCE_NONE &&
144 config != AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED) {
Phil Burk09bc4612016-02-24 15:58:15 -0800145 ALOGW("setForceUse() invalid config %d for HDMI_SYSTEM_AUDIO", config);
146 }
147 mForceUse[usage] = config;
148 break;
149 case AUDIO_POLICY_FORCE_FOR_ENCODED_SURROUND:
150 if (config != AUDIO_POLICY_FORCE_NONE &&
151 config != AUDIO_POLICY_FORCE_ENCODED_SURROUND_NEVER &&
jiabin81772902018-04-02 17:52:27 -0700152 config != AUDIO_POLICY_FORCE_ENCODED_SURROUND_ALWAYS &&
153 config != AUDIO_POLICY_FORCE_ENCODED_SURROUND_MANUAL) {
Phil Burk09bc4612016-02-24 15:58:15 -0800154 ALOGW("setForceUse() invalid config %d for ENCODED_SURROUND", config);
155 return BAD_VALUE;
François Gaffie2110e042015-03-24 08:41:51 +0100156 }
157 mForceUse[usage] = config;
158 break;
Jack He96117ae2018-02-12 20:52:53 -0800159 case AUDIO_POLICY_FORCE_FOR_VIBRATE_RINGING:
160 if (config != AUDIO_POLICY_FORCE_BT_SCO && config != AUDIO_POLICY_FORCE_NONE) {
161 ALOGW("setForceUse() invalid config %d for FOR_VIBRATE_RINGING", config);
162 return BAD_VALUE;
163 }
164 mForceUse[usage] = config;
165 break;
François Gaffie2110e042015-03-24 08:41:51 +0100166 default:
167 ALOGW("setForceUse() invalid usage %d", usage);
Phil Burk09bc4612016-02-24 15:58:15 -0800168 break; // TODO return BAD_VALUE?
François Gaffie2110e042015-03-24 08:41:51 +0100169 }
170 return NO_ERROR;
171}
172
173routing_strategy Engine::getStrategyForStream(audio_stream_type_t stream)
174{
175 // stream to strategy mapping
176 switch (stream) {
177 case AUDIO_STREAM_VOICE_CALL:
178 case AUDIO_STREAM_BLUETOOTH_SCO:
179 return STRATEGY_PHONE;
180 case AUDIO_STREAM_RING:
181 case AUDIO_STREAM_ALARM:
182 return STRATEGY_SONIFICATION;
183 case AUDIO_STREAM_NOTIFICATION:
184 return STRATEGY_SONIFICATION_RESPECTFUL;
185 case AUDIO_STREAM_DTMF:
186 return STRATEGY_DTMF;
187 default:
188 ALOGE("unknown stream type %d", stream);
Chih-Hung Hsieh39399602018-10-16 14:42:13 -0700189 FALLTHROUGH_INTENDED;
François Gaffie2110e042015-03-24 08:41:51 +0100190 case AUDIO_STREAM_SYSTEM:
191 // NOTE: SYSTEM stream uses MEDIA strategy because muting music and switching outputs
192 // while key clicks are played produces a poor result
193 case AUDIO_STREAM_MUSIC:
194 return STRATEGY_MEDIA;
195 case AUDIO_STREAM_ENFORCED_AUDIBLE:
196 return STRATEGY_ENFORCED_AUDIBLE;
197 case AUDIO_STREAM_TTS:
198 return STRATEGY_TRANSMITTED_THROUGH_SPEAKER;
199 case AUDIO_STREAM_ACCESSIBILITY:
200 return STRATEGY_ACCESSIBILITY;
201 case AUDIO_STREAM_REROUTING:
202 return STRATEGY_REROUTING;
203 }
204}
205
206routing_strategy Engine::getStrategyForUsage(audio_usage_t usage)
207{
François Gaffie2110e042015-03-24 08:41:51 +0100208 // usage to strategy mapping
209 switch (usage) {
210 case AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY:
François Gaffie2110e042015-03-24 08:41:51 +0100211 return STRATEGY_ACCESSIBILITY;
212
213 case AUDIO_USAGE_MEDIA:
214 case AUDIO_USAGE_GAME:
Jean-Michel Trivi36867762016-12-29 12:03:28 -0800215 case AUDIO_USAGE_ASSISTANT:
François Gaffie2110e042015-03-24 08:41:51 +0100216 case AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
217 case AUDIO_USAGE_ASSISTANCE_SONIFICATION:
218 return STRATEGY_MEDIA;
219
220 case AUDIO_USAGE_VOICE_COMMUNICATION:
221 return STRATEGY_PHONE;
222
223 case AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING:
224 return STRATEGY_DTMF;
225
226 case AUDIO_USAGE_ALARM:
227 case AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE:
228 return STRATEGY_SONIFICATION;
229
230 case AUDIO_USAGE_NOTIFICATION:
231 case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
232 case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
233 case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
234 case AUDIO_USAGE_NOTIFICATION_EVENT:
235 return STRATEGY_SONIFICATION_RESPECTFUL;
236
237 case AUDIO_USAGE_UNKNOWN:
238 default:
239 return STRATEGY_MEDIA;
240 }
241}
242
243audio_devices_t Engine::getDeviceForStrategy(routing_strategy strategy) const
244{
Eric Laurent0f928fa2016-03-21 12:06:20 -0700245 DeviceVector availableOutputDevices = mApmObserver->getAvailableOutputDevices();
246 DeviceVector availableInputDevices = mApmObserver->getAvailableInputDevices();
François Gaffie2110e042015-03-24 08:41:51 +0100247
Eric Laurentc75307b2015-03-17 15:29:32 -0700248 const SwAudioOutputCollection &outputs = mApmObserver->getOutputs();
François Gaffie2110e042015-03-24 08:41:51 +0100249
Eric Laurent0f928fa2016-03-21 12:06:20 -0700250 return getDeviceForStrategyInt(strategy, availableOutputDevices,
Jean-Michel Trivi61309522018-01-23 09:58:17 -0800251 availableInputDevices, outputs, (uint32_t)AUDIO_DEVICE_NONE);
Eric Laurent28d09f02016-03-08 10:43:05 -0800252}
253
254
Eric Laurent28d09f02016-03-08 10:43:05 -0800255audio_devices_t Engine::getDeviceForStrategyInt(routing_strategy strategy,
Jean-Michel Trivi61309522018-01-23 09:58:17 -0800256 DeviceVector availableOutputDevices,
257 DeviceVector availableInputDevices,
258 const SwAudioOutputCollection &outputs,
259 uint32_t outputDeviceTypesToIgnore) const
Eric Laurent28d09f02016-03-08 10:43:05 -0800260{
François Gaffie2110e042015-03-24 08:41:51 +0100261 uint32_t device = AUDIO_DEVICE_NONE;
Jean-Michel Trivi61309522018-01-23 09:58:17 -0800262 uint32_t availableOutputDevicesType =
263 availableOutputDevices.types() & ~outputDeviceTypesToIgnore;
François Gaffie2110e042015-03-24 08:41:51 +0100264
265 switch (strategy) {
266
267 case STRATEGY_TRANSMITTED_THROUGH_SPEAKER:
268 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER;
François Gaffie2110e042015-03-24 08:41:51 +0100269 break;
270
271 case STRATEGY_SONIFICATION_RESPECTFUL:
Eric Laurent7731b5a2018-04-06 15:47:22 -0700272 if (isInCall() || outputs.isStreamActiveLocally(AUDIO_STREAM_VOICE_CALL)) {
Eric Laurent28d09f02016-03-08 10:43:05 -0800273 device = getDeviceForStrategyInt(
Jean-Michel Trivi61309522018-01-23 09:58:17 -0800274 STRATEGY_SONIFICATION, availableOutputDevices, availableInputDevices, outputs,
275 outputDeviceTypesToIgnore);
François Gaffie2110e042015-03-24 08:41:51 +0100276 } else {
Jean-Michel Trivi61309522018-01-23 09:58:17 -0800277 bool media_active_locally =
278 outputs.isStreamActiveLocally(
279 AUDIO_STREAM_MUSIC, SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY)
280 || outputs.isStreamActiveLocally(
281 AUDIO_STREAM_ACCESSIBILITY, SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY);
282 // routing is same as media without the "remote" device
283 device = getDeviceForStrategyInt(STRATEGY_MEDIA,
284 availableOutputDevices,
285 availableInputDevices, outputs,
286 AUDIO_DEVICE_OUT_REMOTE_SUBMIX | outputDeviceTypesToIgnore);
287 // if no media is playing on the device, check for mandatory use of "safe" speaker
288 // when media would have played on speaker, and the safe speaker path is available
289 if (!media_active_locally
290 && (device & AUDIO_DEVICE_OUT_SPEAKER)
291 && (availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER_SAFE)) {
Eric Laurent9a7d9222015-07-02 15:30:23 -0700292 device |= AUDIO_DEVICE_OUT_SPEAKER_SAFE;
293 device &= ~AUDIO_DEVICE_OUT_SPEAKER;
294 }
François Gaffie2110e042015-03-24 08:41:51 +0100295 }
296 break;
297
298 case STRATEGY_DTMF:
299 if (!isInCall()) {
300 // when off call, DTMF strategy follows the same rules as MEDIA strategy
Eric Laurent28d09f02016-03-08 10:43:05 -0800301 device = getDeviceForStrategyInt(
Jean-Michel Trivi61309522018-01-23 09:58:17 -0800302 STRATEGY_MEDIA, availableOutputDevices, availableInputDevices, outputs,
303 outputDeviceTypesToIgnore);
François Gaffie2110e042015-03-24 08:41:51 +0100304 break;
305 }
306 // when in call, DTMF and PHONE strategies follow the same rules
Chih-Hung Hsieh2b487032018-09-13 14:16:02 -0700307 FALLTHROUGH_INTENDED;
François Gaffie2110e042015-03-24 08:41:51 +0100308
309 case STRATEGY_PHONE:
310 // Force use of only devices on primary output if:
311 // - in call AND
312 // - cannot route from voice call RX OR
313 // - audio HAL version is < 3.0 and TX device is on the primary HW module
314 if (getPhoneState() == AUDIO_MODE_IN_CALL) {
315 audio_devices_t txDevice = getDeviceForInputSource(AUDIO_SOURCE_VOICE_COMMUNICATION);
316 sp<AudioOutputDescriptor> primaryOutput = outputs.getPrimaryOutput();
317 audio_devices_t availPrimaryInputDevices =
318 availableInputDevices.getDevicesFromHwModule(primaryOutput->getModuleHandle());
Eric Laurent58a73fc2018-02-21 18:46:13 -0800319
320 // TODO: getPrimaryOutput return only devices from first module in
321 // audio_policy_configuration.xml, hearing aid is not there, but it's
322 // a primary device
323 // FIXME: this is not the right way of solving this problem
François Gaffie2110e042015-03-24 08:41:51 +0100324 audio_devices_t availPrimaryOutputDevices =
Eric Laurent58a73fc2018-02-21 18:46:13 -0800325 (primaryOutput->supportedDevices() | AUDIO_DEVICE_OUT_HEARING_AID) &
326 availableOutputDevices.types();
François Gaffie2110e042015-03-24 08:41:51 +0100327
328 if (((availableInputDevices.types() &
329 AUDIO_DEVICE_IN_TELEPHONY_RX & ~AUDIO_DEVICE_BIT_IN) == 0) ||
330 (((txDevice & availPrimaryInputDevices & ~AUDIO_DEVICE_BIT_IN) != 0) &&
Mikhail Naganov9ee05402016-10-13 15:58:17 -0700331 (primaryOutput->getAudioPort()->getModuleVersionMajor() < 3))) {
François Gaffie2110e042015-03-24 08:41:51 +0100332 availableOutputDevicesType = availPrimaryOutputDevices;
333 }
334 }
Eric Laurent28d09f02016-03-08 10:43:05 -0800335 // for phone strategy, we first consider the forced use and then the available devices by
336 // order of priority
François Gaffie2110e042015-03-24 08:41:51 +0100337 switch (mForceUse[AUDIO_POLICY_FORCE_FOR_COMMUNICATION]) {
338 case AUDIO_POLICY_FORCE_BT_SCO:
339 if (!isInCall() || strategy != STRATEGY_DTMF) {
340 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
341 if (device) break;
342 }
343 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
344 if (device) break;
345 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_SCO;
346 if (device) break;
347 // if SCO device is requested but no SCO device is available, fall back to default case
Chih-Hung Hsieh2b487032018-09-13 14:16:02 -0700348 FALLTHROUGH_INTENDED;
François Gaffie2110e042015-03-24 08:41:51 +0100349
350 default: // FORCE_NONE
Eric Laurent58a73fc2018-02-21 18:46:13 -0800351 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_HEARING_AID;
352 if (device) break;
François Gaffie2110e042015-03-24 08:41:51 +0100353 // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to A2DP
354 if (!isInCall() &&
355 (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
Aniket Kumar Lataa8ee9962018-01-31 20:24:23 -0800356 outputs.isA2dpSupported()) {
François Gaffie2110e042015-03-24 08:41:51 +0100357 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP;
358 if (device) break;
359 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES;
360 if (device) break;
361 }
362 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_WIRED_HEADPHONE;
363 if (device) break;
364 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_WIRED_HEADSET;
365 if (device) break;
Eric Laurenta0b18ce2016-03-08 11:05:00 -0800366 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_LINE;
367 if (device) break;
Eric Laurent904d6322017-03-17 17:20:47 -0700368 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_USB_HEADSET;
369 if (device) break;
François Gaffie2110e042015-03-24 08:41:51 +0100370 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_USB_DEVICE;
371 if (device) break;
372 if (!isInCall()) {
373 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_USB_ACCESSORY;
374 if (device) break;
375 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET;
376 if (device) break;
377 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_AUX_DIGITAL;
378 if (device) break;
379 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET;
380 if (device) break;
381 }
382 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_EARPIECE;
François Gaffie2110e042015-03-24 08:41:51 +0100383 break;
384
385 case AUDIO_POLICY_FORCE_SPEAKER:
386 // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to
387 // A2DP speaker when forcing to speaker output
388 if (!isInCall() &&
389 (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
Aniket Kumar Lataa8ee9962018-01-31 20:24:23 -0800390 outputs.isA2dpSupported()) {
François Gaffie2110e042015-03-24 08:41:51 +0100391 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER;
392 if (device) break;
393 }
394 if (!isInCall()) {
395 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_USB_ACCESSORY;
396 if (device) break;
397 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_USB_DEVICE;
398 if (device) break;
399 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET;
400 if (device) break;
401 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_AUX_DIGITAL;
402 if (device) break;
403 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET;
404 if (device) break;
405 }
François Gaffie2110e042015-03-24 08:41:51 +0100406 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER;
François Gaffie2110e042015-03-24 08:41:51 +0100407 break;
408 }
409 break;
410
411 case STRATEGY_SONIFICATION:
412
413 // If incall, just select the STRATEGY_PHONE device: The rest of the behavior is handled by
414 // handleIncallSonification().
Eric Laurent7731b5a2018-04-06 15:47:22 -0700415 if (isInCall() || outputs.isStreamActiveLocally(AUDIO_STREAM_VOICE_CALL)) {
Eric Laurent28d09f02016-03-08 10:43:05 -0800416 device = getDeviceForStrategyInt(
Jean-Michel Trivi61309522018-01-23 09:58:17 -0800417 STRATEGY_PHONE, availableOutputDevices, availableInputDevices, outputs,
418 outputDeviceTypesToIgnore);
François Gaffie2110e042015-03-24 08:41:51 +0100419 break;
420 }
Chih-Hung Hsieh2b487032018-09-13 14:16:02 -0700421 FALLTHROUGH_INTENDED;
François Gaffie2110e042015-03-24 08:41:51 +0100422
423 case STRATEGY_ENFORCED_AUDIBLE:
424 // strategy STRATEGY_ENFORCED_AUDIBLE uses same routing policy as STRATEGY_SONIFICATION
425 // except:
426 // - when in call where it doesn't default to STRATEGY_PHONE behavior
427 // - in countries where not enforced in which case it follows STRATEGY_MEDIA
428
429 if ((strategy == STRATEGY_SONIFICATION) ||
430 (mForceUse[AUDIO_POLICY_FORCE_FOR_SYSTEM] == AUDIO_POLICY_FORCE_SYSTEM_ENFORCED)) {
431 device = availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER;
François Gaffie2110e042015-03-24 08:41:51 +0100432 }
Eric Laurenta8e0f022017-01-27 17:41:53 -0800433
434 // if SCO headset is connected and we are told to use it, play ringtone over
435 // speaker and BT SCO
Jack He96117ae2018-02-12 20:52:53 -0800436 if ((availableOutputDevicesType & AUDIO_DEVICE_OUT_ALL_SCO) != 0) {
Eric Laurenta8e0f022017-01-27 17:41:53 -0800437 uint32_t device2 = AUDIO_DEVICE_NONE;
438 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
439 if (device2 == AUDIO_DEVICE_NONE) {
440 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
441 }
442 if (device2 == AUDIO_DEVICE_NONE) {
443 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_SCO;
444 }
Jack He96117ae2018-02-12 20:52:53 -0800445 // Use ONLY Bluetooth SCO output when ringing in vibration mode
446 if (!((mForceUse[AUDIO_POLICY_FORCE_FOR_SYSTEM] == AUDIO_POLICY_FORCE_SYSTEM_ENFORCED)
447 && (strategy == STRATEGY_ENFORCED_AUDIBLE))) {
448 if (mForceUse[AUDIO_POLICY_FORCE_FOR_VIBRATE_RINGING]
449 == AUDIO_POLICY_FORCE_BT_SCO) {
450 if (device2 != AUDIO_DEVICE_NONE) {
451 device = device2;
452 break;
453 }
454 }
455 }
456 // Use both Bluetooth SCO and phone default output when ringing in normal mode
457 if (mForceUse[AUDIO_POLICY_FORCE_FOR_COMMUNICATION] == AUDIO_POLICY_FORCE_BT_SCO) {
juyuchen5fa0aed2018-05-16 10:58:37 +0800458 if ((strategy == STRATEGY_SONIFICATION) &&
459 (device & AUDIO_DEVICE_OUT_SPEAKER) &&
460 (availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER_SAFE)) {
461 device |= AUDIO_DEVICE_OUT_SPEAKER_SAFE;
462 device &= ~AUDIO_DEVICE_OUT_SPEAKER;
463 }
Jack He96117ae2018-02-12 20:52:53 -0800464 if (device2 != AUDIO_DEVICE_NONE) {
465 device |= device2;
466 break;
467 }
Eric Laurenta8e0f022017-01-27 17:41:53 -0800468 }
469 }
François Gaffie2110e042015-03-24 08:41:51 +0100470 // The second device used for sonification is the same as the device used by media strategy
Chih-Hung Hsieh2b487032018-09-13 14:16:02 -0700471 FALLTHROUGH_INTENDED;
François Gaffie2110e042015-03-24 08:41:51 +0100472
François Gaffie2110e042015-03-24 08:41:51 +0100473 case STRATEGY_ACCESSIBILITY:
474 if (strategy == STRATEGY_ACCESSIBILITY) {
475 // do not route accessibility prompts to a digital output currently configured with a
476 // compressed format as they would likely not be mixed and dropped.
477 for (size_t i = 0; i < outputs.size(); i++) {
478 sp<AudioOutputDescriptor> desc = outputs.valueAt(i);
479 audio_devices_t devices = desc->device() &
480 (AUDIO_DEVICE_OUT_HDMI | AUDIO_DEVICE_OUT_SPDIF | AUDIO_DEVICE_OUT_HDMI_ARC);
481 if (desc->isActive() && !audio_is_linear_pcm(desc->mFormat) &&
482 devices != AUDIO_DEVICE_NONE) {
483 availableOutputDevicesType = availableOutputDevices.types() & ~devices;
484 }
485 }
Eric Laurent28d09f02016-03-08 10:43:05 -0800486 availableOutputDevices =
487 availableOutputDevices.getDevicesFromType(availableOutputDevicesType);
488 if (outputs.isStreamActive(AUDIO_STREAM_RING) ||
489 outputs.isStreamActive(AUDIO_STREAM_ALARM)) {
490 return getDeviceForStrategyInt(
Jean-Michel Trivi61309522018-01-23 09:58:17 -0800491 STRATEGY_SONIFICATION, availableOutputDevices, availableInputDevices, outputs,
492 outputDeviceTypesToIgnore);
Eric Laurent28d09f02016-03-08 10:43:05 -0800493 }
494 if (isInCall()) {
495 return getDeviceForStrategyInt(
Jean-Michel Trivi61309522018-01-23 09:58:17 -0800496 STRATEGY_PHONE, availableOutputDevices, availableInputDevices, outputs,
497 outputDeviceTypesToIgnore);
Eric Laurent28d09f02016-03-08 10:43:05 -0800498 }
François Gaffie2110e042015-03-24 08:41:51 +0100499 }
Eric Laurent28d09f02016-03-08 10:43:05 -0800500 // For other cases, STRATEGY_ACCESSIBILITY behaves like STRATEGY_MEDIA
Chih-Hung Hsieh2b487032018-09-13 14:16:02 -0700501 FALLTHROUGH_INTENDED;
François Gaffie2110e042015-03-24 08:41:51 +0100502
Eric Laurent28d09f02016-03-08 10:43:05 -0800503 // FIXME: STRATEGY_REROUTING follow STRATEGY_MEDIA for now
François Gaffie2110e042015-03-24 08:41:51 +0100504 case STRATEGY_REROUTING:
505 case STRATEGY_MEDIA: {
506 uint32_t device2 = AUDIO_DEVICE_NONE;
507 if (strategy != STRATEGY_SONIFICATION) {
508 // no sonification on remote submix (e.g. WFD)
Eric Laurent28d09f02016-03-08 10:43:05 -0800509 if (availableOutputDevices.getDevice(AUDIO_DEVICE_OUT_REMOTE_SUBMIX,
510 String8("0")) != 0) {
François Gaffie2110e042015-03-24 08:41:51 +0100511 device2 = availableOutputDevices.types() & AUDIO_DEVICE_OUT_REMOTE_SUBMIX;
512 }
513 }
Eric Laurenta20d4fa2015-06-04 18:39:28 -0700514 if (isInCall() && (strategy == STRATEGY_MEDIA)) {
Eric Laurent28d09f02016-03-08 10:43:05 -0800515 device = getDeviceForStrategyInt(
Jean-Michel Trivi61309522018-01-23 09:58:17 -0800516 STRATEGY_PHONE, availableOutputDevices, availableInputDevices, outputs,
517 outputDeviceTypesToIgnore);
Eric Laurenta20d4fa2015-06-04 18:39:28 -0700518 break;
519 }
Eric Laurent58a73fc2018-02-21 18:46:13 -0800520 if (device2 == AUDIO_DEVICE_NONE) {
521 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_HEARING_AID;
522 }
François Gaffie2110e042015-03-24 08:41:51 +0100523 if ((device2 == AUDIO_DEVICE_NONE) &&
524 (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] != AUDIO_POLICY_FORCE_NO_BT_A2DP) &&
Aniket Kumar Lataa8ee9962018-01-31 20:24:23 -0800525 outputs.isA2dpSupported()) {
François Gaffie2110e042015-03-24 08:41:51 +0100526 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP;
527 if (device2 == AUDIO_DEVICE_NONE) {
528 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES;
529 }
530 if (device2 == AUDIO_DEVICE_NONE) {
531 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER;
532 }
533 }
534 if ((device2 == AUDIO_DEVICE_NONE) &&
535 (mForceUse[AUDIO_POLICY_FORCE_FOR_MEDIA] == AUDIO_POLICY_FORCE_SPEAKER)) {
536 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER;
537 }
538 if (device2 == AUDIO_DEVICE_NONE) {
539 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_WIRED_HEADPHONE;
540 }
Jean-Michel Trivi5c233f82015-04-03 09:21:24 -0700541 if (device2 == AUDIO_DEVICE_NONE) {
François Gaffie2110e042015-03-24 08:41:51 +0100542 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_LINE;
543 }
544 if (device2 == AUDIO_DEVICE_NONE) {
545 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_WIRED_HEADSET;
546 }
547 if (device2 == AUDIO_DEVICE_NONE) {
Eric Laurent904d6322017-03-17 17:20:47 -0700548 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_USB_HEADSET;
549 }
550 if (device2 == AUDIO_DEVICE_NONE) {
François Gaffie2110e042015-03-24 08:41:51 +0100551 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_USB_ACCESSORY;
552 }
553 if (device2 == AUDIO_DEVICE_NONE) {
554 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_USB_DEVICE;
555 }
556 if (device2 == AUDIO_DEVICE_NONE) {
557 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET;
558 }
559 if ((device2 == AUDIO_DEVICE_NONE) && (strategy != STRATEGY_SONIFICATION)) {
560 // no sonification on aux digital (e.g. HDMI)
561 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_AUX_DIGITAL;
562 }
563 if ((device2 == AUDIO_DEVICE_NONE) &&
564 (mForceUse[AUDIO_POLICY_FORCE_FOR_DOCK] == AUDIO_POLICY_FORCE_ANALOG_DOCK)) {
565 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET;
566 }
567 if (device2 == AUDIO_DEVICE_NONE) {
568 device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER;
569 }
570 int device3 = AUDIO_DEVICE_NONE;
571 if (strategy == STRATEGY_MEDIA) {
572 // ARC, SPDIF and AUX_LINE can co-exist with others.
573 device3 = availableOutputDevicesType & AUDIO_DEVICE_OUT_HDMI_ARC;
574 device3 |= (availableOutputDevicesType & AUDIO_DEVICE_OUT_SPDIF);
575 device3 |= (availableOutputDevicesType & AUDIO_DEVICE_OUT_AUX_LINE);
576 }
577
578 device2 |= device3;
579 // device is DEVICE_OUT_SPEAKER if we come from case STRATEGY_SONIFICATION or
580 // STRATEGY_ENFORCED_AUDIBLE, AUDIO_DEVICE_NONE otherwise
581 device |= device2;
582
583 // If hdmi system audio mode is on, remove speaker out of output list.
584 if ((strategy == STRATEGY_MEDIA) &&
585 (mForceUse[AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO] ==
586 AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED)) {
587 device &= ~AUDIO_DEVICE_OUT_SPEAKER;
588 }
Jean-Michel Trivi654afa02017-05-11 14:12:33 -0700589
590 // for STRATEGY_SONIFICATION:
591 // if SPEAKER was selected, and SPEAKER_SAFE is available, use SPEAKER_SAFE instead
592 if ((strategy == STRATEGY_SONIFICATION) &&
593 (device & AUDIO_DEVICE_OUT_SPEAKER) &&
594 (availableOutputDevicesType & AUDIO_DEVICE_OUT_SPEAKER_SAFE)) {
595 device |= AUDIO_DEVICE_OUT_SPEAKER_SAFE;
596 device &= ~AUDIO_DEVICE_OUT_SPEAKER;
597 }
François Gaffie2110e042015-03-24 08:41:51 +0100598 } break;
599
600 default:
601 ALOGW("getDeviceForStrategy() unknown strategy: %d", strategy);
602 break;
603 }
604
Eric Laurent5a2b6292016-04-14 18:05:57 -0700605 if (device == AUDIO_DEVICE_NONE) {
606 ALOGV("getDeviceForStrategy() no device found for strategy %d", strategy);
607 device = mApmObserver->getDefaultOutputDevice()->type();
608 ALOGE_IF(device == AUDIO_DEVICE_NONE,
609 "getDeviceForStrategy() no default device defined");
610 }
François Gaffie2110e042015-03-24 08:41:51 +0100611 ALOGVV("getDeviceForStrategy() strategy %d, device %x", strategy, device);
612 return device;
613}
614
615
616audio_devices_t Engine::getDeviceForInputSource(audio_source_t inputSource) const
617{
618 const DeviceVector &availableOutputDevices = mApmObserver->getAvailableOutputDevices();
619 const DeviceVector &availableInputDevices = mApmObserver->getAvailableInputDevices();
Eric Laurentc75307b2015-03-17 15:29:32 -0700620 const SwAudioOutputCollection &outputs = mApmObserver->getOutputs();
François Gaffie2110e042015-03-24 08:41:51 +0100621 audio_devices_t availableDeviceTypes = availableInputDevices.types() & ~AUDIO_DEVICE_BIT_IN;
622
623 uint32_t device = AUDIO_DEVICE_NONE;
624
Eric Laurentdc95a252018-04-12 12:46:56 -0700625 // when a call is active, force device selection to match source VOICE_COMMUNICATION
626 // for most other input sources to avoid rerouting call TX audio
627 if (isInCall()) {
628 switch (inputSource) {
629 case AUDIO_SOURCE_DEFAULT:
630 case AUDIO_SOURCE_MIC:
631 case AUDIO_SOURCE_VOICE_RECOGNITION:
632 case AUDIO_SOURCE_UNPROCESSED:
633 case AUDIO_SOURCE_HOTWORD:
634 case AUDIO_SOURCE_CAMCORDER:
635 inputSource = AUDIO_SOURCE_VOICE_COMMUNICATION;
636 break;
637 default:
638 break;
639 }
640 }
641
François Gaffie2110e042015-03-24 08:41:51 +0100642 switch (inputSource) {
643 case AUDIO_SOURCE_VOICE_UPLINK:
644 if (availableDeviceTypes & AUDIO_DEVICE_IN_VOICE_CALL) {
645 device = AUDIO_DEVICE_IN_VOICE_CALL;
646 break;
647 }
648 break;
649
650 case AUDIO_SOURCE_DEFAULT:
651 case AUDIO_SOURCE_MIC:
652 if (availableDeviceTypes & AUDIO_DEVICE_IN_BLUETOOTH_A2DP) {
653 device = AUDIO_DEVICE_IN_BLUETOOTH_A2DP;
654 } else if ((mForceUse[AUDIO_POLICY_FORCE_FOR_RECORD] == AUDIO_POLICY_FORCE_BT_SCO) &&
655 (availableDeviceTypes & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET)) {
656 device = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET;
657 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_WIRED_HEADSET) {
658 device = AUDIO_DEVICE_IN_WIRED_HEADSET;
Eric Laurent904d6322017-03-17 17:20:47 -0700659 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_USB_HEADSET) {
660 device = AUDIO_DEVICE_IN_USB_HEADSET;
François Gaffie2110e042015-03-24 08:41:51 +0100661 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_USB_DEVICE) {
662 device = AUDIO_DEVICE_IN_USB_DEVICE;
663 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_BUILTIN_MIC) {
664 device = AUDIO_DEVICE_IN_BUILTIN_MIC;
665 }
666 break;
667
668 case AUDIO_SOURCE_VOICE_COMMUNICATION:
669 // Allow only use of devices on primary input if in call and HAL does not support routing
670 // to voice call path.
671 if ((getPhoneState() == AUDIO_MODE_IN_CALL) &&
672 (availableOutputDevices.types() & AUDIO_DEVICE_OUT_TELEPHONY_TX) == 0) {
673 sp<AudioOutputDescriptor> primaryOutput = outputs.getPrimaryOutput();
674 availableDeviceTypes =
675 availableInputDevices.getDevicesFromHwModule(primaryOutput->getModuleHandle())
676 & ~AUDIO_DEVICE_BIT_IN;
677 }
678
679 switch (mForceUse[AUDIO_POLICY_FORCE_FOR_COMMUNICATION]) {
680 case AUDIO_POLICY_FORCE_BT_SCO:
681 // if SCO device is requested but no SCO device is available, fall back to default case
682 if (availableDeviceTypes & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) {
683 device = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET;
684 break;
685 }
Chih-Hung Hsieh2b487032018-09-13 14:16:02 -0700686 FALLTHROUGH_INTENDED;
François Gaffie2110e042015-03-24 08:41:51 +0100687
688 default: // FORCE_NONE
689 if (availableDeviceTypes & AUDIO_DEVICE_IN_WIRED_HEADSET) {
690 device = AUDIO_DEVICE_IN_WIRED_HEADSET;
Eric Laurent904d6322017-03-17 17:20:47 -0700691 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_USB_HEADSET) {
692 device = AUDIO_DEVICE_IN_USB_HEADSET;
François Gaffie2110e042015-03-24 08:41:51 +0100693 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_USB_DEVICE) {
694 device = AUDIO_DEVICE_IN_USB_DEVICE;
695 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_BUILTIN_MIC) {
696 device = AUDIO_DEVICE_IN_BUILTIN_MIC;
697 }
698 break;
699
700 case AUDIO_POLICY_FORCE_SPEAKER:
701 if (availableDeviceTypes & AUDIO_DEVICE_IN_BACK_MIC) {
702 device = AUDIO_DEVICE_IN_BACK_MIC;
703 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_BUILTIN_MIC) {
704 device = AUDIO_DEVICE_IN_BUILTIN_MIC;
705 }
706 break;
707 }
708 break;
709
710 case AUDIO_SOURCE_VOICE_RECOGNITION:
rago8a397d52015-12-02 11:27:57 -0800711 case AUDIO_SOURCE_UNPROCESSED:
François Gaffie2110e042015-03-24 08:41:51 +0100712 case AUDIO_SOURCE_HOTWORD:
713 if (mForceUse[AUDIO_POLICY_FORCE_FOR_RECORD] == AUDIO_POLICY_FORCE_BT_SCO &&
714 availableDeviceTypes & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) {
715 device = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET;
716 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_WIRED_HEADSET) {
717 device = AUDIO_DEVICE_IN_WIRED_HEADSET;
Eric Laurent904d6322017-03-17 17:20:47 -0700718 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_USB_HEADSET) {
719 device = AUDIO_DEVICE_IN_USB_HEADSET;
François Gaffie2110e042015-03-24 08:41:51 +0100720 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_USB_DEVICE) {
721 device = AUDIO_DEVICE_IN_USB_DEVICE;
722 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_BUILTIN_MIC) {
723 device = AUDIO_DEVICE_IN_BUILTIN_MIC;
724 }
725 break;
726 case AUDIO_SOURCE_CAMCORDER:
727 if (availableDeviceTypes & AUDIO_DEVICE_IN_BACK_MIC) {
728 device = AUDIO_DEVICE_IN_BACK_MIC;
729 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_BUILTIN_MIC) {
730 device = AUDIO_DEVICE_IN_BUILTIN_MIC;
Takeshi Oishi86ad3d12018-07-20 16:13:06 +0900731 } else if (availableDeviceTypes & AUDIO_DEVICE_IN_USB_DEVICE) {
732 // This is specifically for a device without built-in mic
733 device = AUDIO_DEVICE_IN_USB_DEVICE;
François Gaffie2110e042015-03-24 08:41:51 +0100734 }
735 break;
736 case AUDIO_SOURCE_VOICE_DOWNLINK:
737 case AUDIO_SOURCE_VOICE_CALL:
738 if (availableDeviceTypes & AUDIO_DEVICE_IN_VOICE_CALL) {
739 device = AUDIO_DEVICE_IN_VOICE_CALL;
740 }
741 break;
742 case AUDIO_SOURCE_REMOTE_SUBMIX:
743 if (availableDeviceTypes & AUDIO_DEVICE_IN_REMOTE_SUBMIX) {
744 device = AUDIO_DEVICE_IN_REMOTE_SUBMIX;
745 }
746 break;
747 case AUDIO_SOURCE_FM_TUNER:
748 if (availableDeviceTypes & AUDIO_DEVICE_IN_FM_TUNER) {
749 device = AUDIO_DEVICE_IN_FM_TUNER;
750 }
751 break;
752 default:
753 ALOGW("getDeviceForInputSource() invalid input source %d", inputSource);
754 break;
755 }
Eric Laurent5a2b6292016-04-14 18:05:57 -0700756 if (device == AUDIO_DEVICE_NONE) {
757 ALOGV("getDeviceForInputSource() no device found for source %d", inputSource);
758 if (availableDeviceTypes & AUDIO_DEVICE_IN_STUB) {
759 device = AUDIO_DEVICE_IN_STUB;
760 }
761 ALOGE_IF(device == AUDIO_DEVICE_NONE,
762 "getDeviceForInputSource() no default device defined");
763 }
François Gaffie2110e042015-03-24 08:41:51 +0100764 ALOGV("getDeviceForInputSource()input source %d, device %08x", inputSource, device);
765 return device;
766}
767
768template <>
769AudioPolicyManagerInterface *Engine::queryInterface()
770{
771 return &mManagerInterface;
772}
773
774} // namespace audio_policy
775} // namespace android
776
777