Lines Matching refs:device
27 // A device mask for all audio input devices that are considered "virtual" when evaluating
30 // A device mask for all audio output devices that are considered "remote" when evaluating
53 status_t AudioPolicyManagerBase::setDeviceConnectionState(audio_devices_t device,
62 ALOGV("setDeviceConnectionState() device: 0x%X, state %d, address %s", device, state, device_address);
64 // connect/disconnect only 1 device at a time
65 if (!audio_is_output_device(device) && !audio_is_input_device(device)) return BAD_VALUE;
73 if (audio_is_output_device(device)) {
76 if (!mHasA2dp && audio_is_a2dp_out_device(device)) {
77 ALOGE("setDeviceConnectionState() invalid A2DP device: %x", device);
80 if (!mHasUsb && audio_is_usb_out_device(device)) {
81 ALOGE("setDeviceConnectionState() invalid USB audio device: %x", device);
84 if (!mHasRemoteSubmix && audio_is_remote_submix_device((audio_devices_t)device)) {
85 ALOGE("setDeviceConnectionState() invalid remote submix audio device: %x", device);
95 // handle output device connection
97 if (mAvailableOutputDevices & device) {
98 ALOGW("setDeviceConnectionState() device already connected: %x", device);
101 ALOGV("setDeviceConnectionState() connecting device %x", device);
103 if (mHasA2dp && audio_is_a2dp_out_device(device)) {
104 // handle A2DP device connection
108 } else if (mHasUsb && audio_is_usb_out_device(device)) {
109 // handle USB device connection
113 if (checkOutputsForDevice(device, state, outputs, paramStr) != NO_ERROR) {
118 // register new device as available
119 mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices | device);
121 if (mHasA2dp && audio_is_a2dp_out_device(device)) {
122 // handle A2DP device connection
125 } else if (audio_is_bluetooth_sco_device(device)) {
126 // handle SCO device connection
128 } else if (mHasUsb && audio_is_usb_out_device(device)) {
129 // handle USB device connection
134 // handle output device disconnection
136 if (!(mAvailableOutputDevices & device)) {
137 ALOGW("setDeviceConnectionState() device not connected: %x", device);
141 ALOGV("setDeviceConnectionState() disconnecting device %x", device);
142 // remove device from available output devices
143 mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices & ~device);
144 checkOutputsForDevice(device, state, outputs, paramStr);
146 if (mHasA2dp && audio_is_a2dp_out_device(device)) {
147 // handle A2DP device disconnection
150 } else if (audio_is_bluetooth_sco_device(device)) {
151 // handle SCO device disconnection
153 } else if (mHasUsb && audio_is_usb_out_device(device)) {
154 // handle USB device disconnection
172 // close unused outputs after device disconnection or direct outputs that have been
184 // do not force device change on duplicated output because if device is 0, it will
185 // also force a device 0 for the two outputs it is duplicated to which may override
186 // a valid device selection on those outputs.
194 } // end if is output device
197 if (audio_is_input_device(device)) {
203 // handle input device connection
205 if (mAvailableInputDevices & device) {
206 ALOGW("setDeviceConnectionState() device already connected: %d", device);
210 if (mHasUsb && audio_is_usb_in_device(device)) {
211 // handle USB device connection
213 } else if (mHasA2dp && audio_is_a2dp_in_device(device)) {
214 // handle A2DP device connection
220 if (checkInputsForDevice(device, state, inputs, paramStr) != NO_ERROR) {
223 mAvailableInputDevices = mAvailableInputDevices | (device & ~AUDIO_DEVICE_BIT_IN);
227 // handle input device disconnection
229 if (!(mAvailableInputDevices & device)) {
230 ALOGW("setDeviceConnectionState() device not connected: %d", device);
233 checkInputsForDevice(device, state, inputs, paramStr);
234 mAvailableInputDevices = (audio_devices_t) (mAvailableInputDevices & ~device);
245 } // end if is input device
247 ALOGW("setDeviceConnectionState() invalid device: %x", device);
251 AudioSystem::device_connection_state AudioPolicyManagerBase::getDeviceConnectionState(audio_devices_t device,
260 if (audio_is_output_device(device)) {
261 if (device & mAvailableOutputDevices) {
262 if (audio_is_a2dp_out_device(device) &&
266 if (audio_is_bluetooth_sco_device(device) &&
270 if (audio_is_usb_out_device(device) &&
272 ALOGE("getDeviceConnectionState() invalid device: %x", device);
275 if (audio_is_remote_submix_device((audio_devices_t)device) && !mHasRemoteSubmix) {
280 } else if (audio_is_input_device(device)) {
281 if (device & mAvailableInputDevices) {
321 // even if no device change is needed
330 // even if no device change is needed
339 // even if no device change is needed
343 // check for device and output changes triggered by new phone state
352 // even if no device change is needed
354 newDevice = hwOutputDesc->device();
362 // mute media and sonification strategies and delay device switch by the largest
462 // check for device and output changes triggered by new force usage
480 ALOGV("setForceUse() changing device from %x to %x for input %d",
504 audio_devices_t device,
517 if (profile->isCompatibleProfile(device, samplingRate, format,
525 if (profile->isCompatibleProfile(device, samplingRate, format,
548 audio_devices_t device = getDeviceForStrategy(strategy, false /*fromCache*/);
549 ALOGV("getOutput() device %d, stream %d, samplingRate %d, format %x, channelMask %x, flags %x",
550 device, stream, samplingRate, format, channelMask, flags);
602 profile = getProfileForDirectOutput(device,
631 outputDesc->mDevice = device;
683 SortedVector<audio_io_handle_t> outputs = getOutputsForDevice(device, mOutputs);
698 // select one output among several that provide a path to a particular device or set of
769 // force a device change if any other output is managed by the same hw
770 // module and has a current device selection that differs from selected device.
771 // In this case, the audio HAL must receive the new device selection so that it can
772 // change the device currently selected by the other active output.
774 desc->device() != newDevice) {
792 // apply volume rules for current stream and device if necessary
834 // delay the device switch by twice the latency because stopOutput() is executed when
841 // force restoring the device selection on other active outputs if it differs from the
849 (newDevice != desc->device())) {
916 audio_devices_t device = getDeviceForInputSource(inputSource);
921 if (device == AUDIO_DEVICE_NONE) {
922 ALOGW("getInput() could not find device for inputSource %d", inputSource);
941 IOProfile *profile = getInputProfile(device,
946 ALOGW("getInput() could not find profile for device 0x%X, samplingRate %d, format %d, "
948 device, samplingRate, format, channelMask);
960 inputDesc->mDevice = device;
1111 audio_devices_t device)
1117 if (!audio_is_output_device(device)) {
1124 ALOGV("setStreamVolumeIndex() stream %d, device %04x, index %d",
1125 stream, device, index);
1127 // if device is AUDIO_DEVICE_OUT_DEFAULT set default value and
1128 // clear all device specific values
1129 if (device == AUDIO_DEVICE_OUT_DEFAULT) {
1132 mStreams[stream].mIndexCur.add(device, index);
1134 // compute and apply stream volume on all outputs according to connected device
1138 getDeviceForVolume(mOutputs.valueAt(i)->device());
1139 if ((device == AUDIO_DEVICE_OUT_DEFAULT) || (device == curDevice)) {
1151 audio_devices_t device)
1156 device)) {
1159 // if device is AUDIO_DEVICE_OUT_DEFAULT, return volume for device corresponding to
1161 if (device == AUDIO_DEVICE_OUT_DEFAULT) {
1162 device = getDeviceForStrategy(getStrategy(stream), true /*fromCache*/);
1164 device = getDeviceForVolume(device);
1166 *index = mStreams[stream].getVolumeIndex(device);
1167 ALOGV("getStreamVolumeIndex() stream %d device %08x index %d", stream, device, *index);
1217 audio_devices_t device = getDeviceForStrategy(strategy, false /*fromCache*/);
1218 SortedVector<audio_io_handle_t> dstOutputs = getOutputsForDevice(device, mOutputs);
1362 if (((outputDesc->device() & APM_AUDIO_OUT_DEVICE_REMOTE_ALL) != 0) &&
1396 snprintf(buffer, SIZE, " A2DP device address: %s\n", mA2dpDeviceAddress.string());
1398 snprintf(buffer, SIZE, " SCO device address: %s\n", mScoDeviceAddress.string());
1448 " Stream Can be muted Index Min Index Max Index Cur [device : index]...\n");
1530 IOProfile *profile = getProfileForDirectOutput(AUDIO_DEVICE_NONE /*ignore device */,
1842 status_t AudioPolicyManagerBase::checkOutputsForDevice(audio_devices_t device,
1850 // first list already open outputs that can be routed to this device
1853 if (!desc->isDuplicated() && (desc->mProfile->mSupportedDevices & device)) {
1858 // then look for output profiles that can be routed to this device
1867 if (mHwModules[i]->mOutputProfiles[j]->mSupportedDevices & device) {
1875 ALOGW("checkOutputsForDevice(): No output available for device %04x", device);
1896 ALOGV("opening output for device %08x with params %s", device, paramStr.string());
1898 desc->mDevice = device;
1914 // Here is where the out_set_parameters() for card & device gets called
1980 // set initial stream volume for device
1981 applyStreamVolumes(output, device, 0, true);
1998 applyStreamVolumes(duplicatedOutput, device, 0, true);
2010 ALOGW("checkOutputsForDevice() could not open output for device %x", device);
2021 ALOGW("checkOutputsForDevice(): No output available for device %04x", device);
2025 // check if one opened output is not needed any more after disconnecting one device
2034 // Clear any profiles associated with the disconnected device.
2043 if (profile->mSupportedDevices & device) {
2065 status_t AudioPolicyManagerBase::checkInputsForDevice(audio_devices_t device,
2072 // first list already open inputs that can be routed to this device
2075 if (desc->mProfile->mSupportedDevices & (device & ~AUDIO_DEVICE_BIT_IN)) {
2081 // then look for input profiles that can be routed to this device
2093 & (device & ~AUDIO_DEVICE_BIT_IN)) {
2102 ALOGW("checkInputsForDevice(): No input available for device 0x%X", device);
2123 ALOGV("opening input for device 0x%X with params %s", device, paramStr.string());
2125 desc->mDevice = device;
2184 ALOGW("checkInputsForDevice() could not open input for device 0x%X", device);
2195 ALOGW("checkInputsForDevice(): No input available for device 0x%X", device);
2200 // check if one opened input is not needed any more after disconnecting one device
2209 // Clear any profiles associated with the disconnected device.
2220 if (profile->mSupportedDevices & device) {
2292 SortedVector<audio_io_handle_t> AudioPolicyManagerBase::getOutputsForDevice(audio_devices_t device,
2297 ALOGVV("getOutputsForDevice() device %04x", device);
2299 ALOGVV("output %d isDuplicated=%d device=%04x",
2301 if ((device & openOutputs.valueAt(i)->supportedDevices()) == device) {
2388 if (!outputDesc->isDuplicated() && outputDesc->device() & AUDIO_DEVICE_OUT_ALL_A2DP) {
2408 // ((SCO device is connected &&
2414 // ((SCO device is NOT connected ||
2443 audio_devices_t device = AUDIO_DEVICE_NONE;
2448 // use device for strategy enforced audible
2450 // use device for strategy phone
2452 // use device for strategy sonification
2454 // use device for strategy "respectful" sonification
2456 // use device for strategy media
2458 // use device for strategy DTMF
2460 device = getDeviceForStrategy(STRATEGY_ENFORCED_AUDIBLE, fromCache);
2463 device = getDeviceForStrategy(STRATEGY_PHONE, fromCache);
2465 device = getDeviceForStrategy(STRATEGY_SONIFICATION, fromCache);
2467 device = getDeviceForStrategy(STRATEGY_SONIFICATION_RESPECTFUL, fromCache);
2469 device = getDeviceForStrategy(STRATEGY_MEDIA, fromCache);
2471 device = getDeviceForStrategy(STRATEGY_DTMF, fromCache);
2474 ALOGV("getNewDevice() selected device %x", device);
2475 return device;
2537 uint32_t device = AUDIO_DEVICE_NONE;
2540 ALOGVV("getDeviceForStrategy() from cache strategy %d, device %x",
2549 device = getDeviceForStrategy(STRATEGY_SONIFICATION, false /*fromCache*/);
2552 // while media is playing on a remote device, use the the sonification behavior.
2556 device = getDeviceForStrategy(STRATEGY_SONIFICATION, false /*fromCache*/);
2558 // while media is playing (or has recently played), use the same device
2559 device = getDeviceForStrategy(STRATEGY_MEDIA, false /*fromCache*/);
2562 device = getDeviceForStrategy(STRATEGY_SONIFICATION, false /*fromCache*/);
2570 device = getDeviceForStrategy(STRATEGY_MEDIA, false /*fromCache*/);
2582 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
2583 if (device) break;
2585 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
2586 if (device) break;
2587 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_SCO;
2588 if (device) break;
2589 // if SCO device is requested but no SCO device is available, fall back to default case
2597 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP;
2598 if (device) break;
2599 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES;
2600 if (device) break;
2602 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE;
2603 if (device) break;
2604 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_WIRED_HEADSET;
2605 if (device) break;
2607 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_USB_ACCESSORY;
2608 if (device) break;
2609 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_USB_DEVICE;
2610 if (device) break;
2611 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET;
2612 if (device) break;
2613 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_AUX_DIGITAL;
2614 if (device) break;
2615 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET;
2616 if (device) break;
2618 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_EARPIECE;
2619 if (device) break;
2620 device = mDefaultOutputDevice;
2621 if (device == AUDIO_DEVICE_NONE) {
2622 ALOGE("getDeviceForStrategy() no device found for STRATEGY_PHONE");
2632 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER;
2633 if (device) break;
2636 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_USB_ACCESSORY;
2637 if (device) break;
2638 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_USB_DEVICE;
2639 if (device) break;
2640 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET;
2641 if (device) break;
2642 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_AUX_DIGITAL;
2643 if (device) break;
2644 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET;
2645 if (device) break;
2647 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_SPEAKER;
2648 if (device) break;
2649 device = mDefaultOutputDevice;
2650 if (device == AUDIO_DEVICE_NONE) {
2651 ALOGE("getDeviceForStrategy() no device found for STRATEGY_PHONE, FORCE_SPEAKER");
2659 // If incall, just select the STRATEGY_PHONE device: The rest of the behavior is handled by
2662 device
2675 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_SPEAKER;
2676 if (device == AUDIO_DEVICE_NONE) {
2677 ALOGE("getDeviceForStrategy() speaker device not found for STRATEGY_SONIFICATION");
2680 // The second device used for sonification is the same as the device used by media strategy
2727 // device is DEVICE_OUT_SPEAKER if we come from case STRATEGY_SONIFICATION or
2729 device |= device2;
2730 if (device) break;
2731 device = mDefaultOutputDevice;
2732 if (device == AUDIO_DEVICE_NONE) {
2733 ALOGE("getDeviceForStrategy() no device found for STRATEGY_MEDIA");
2742 ALOGVV("getDeviceForStrategy() strategy %d, device %x", strategy, device);
2743 return device;
2758 // mute/unmute strategies using an incompatible device combination
2766 audio_devices_t device = outputDesc->device();
2767 bool shouldMute = outputDesc->isActive() && (AudioSystem::popCount(device) >= 2);
2768 // temporary mute output if device selection changes to avoid volume bursts due to
2769 // different per device volumes
2770 bool tempMute = outputDesc->isActive() && (device != prevDevice);
2774 bool mute = shouldMute && (curDevice & device) && (curDevice != device);
2787 // skip output if it does not share any device with current output
2801 desc->latency() * 2, device);
2828 audio_devices_t device,
2832 ALOGV("setOutputDevice() output %d device %04x delayMs %d", output, device, delayMs);
2838 muteWaitMs = setOutputDevice(outputDesc->mOutput1->mId, device, force, delayMs);
2839 muteWaitMs += setOutputDevice(outputDesc->mOutput2->mId, device, force, delayMs);
2842 // no need to proceed if new device is not AUDIO_DEVICE_NONE and not supported by current
2844 if ((device != AUDIO_DEVICE_NONE) &&
2845 ((device & outputDesc->mProfile->mSupportedDevices) == 0)) {
2850 device = (audio_devices_t)(device & outputDesc->mProfile->mSupportedDevices);
2856 if (device != AUDIO_DEVICE_NONE) {
2857 outputDesc->mDevice = device;
2861 ALOGV("Force routing to current device as previous device was null for this output");
2869 // Device is null and does not reflect the routing. Save the necessity to force
2870 // re-routing upon next attempt to select a non-null device for this output
2877 // - the requested device is AUDIO_DEVICE_NONE
2878 // - the requested device is the same as current device and force is not specified.
2880 if ((device == AUDIO_DEVICE_NONE || device == prevDevice) && !force) {
2881 ALOGV("setOutputDevice() setting same device %04x or null device for output %d", device, output);
2885 ALOGV("setOutputDevice() changing device");
2887 param.addInt(String8(AudioParameter::keyRouting), (int)device);
2890 // update stream volumes according to new device
2891 applyStreamVolumes(output, device, delayMs);
2896 AudioPolicyManagerBase::IOProfile *AudioPolicyManagerBase::getInputProfile(audio_devices_t device,
2912 if (profile->isCompatibleProfile(device, samplingRate, format,
2923 uint32_t device = AUDIO_DEVICE_NONE;
2928 device = AUDIO_DEVICE_IN_VOICE_CALL;
2936 device = AUDIO_DEVICE_IN_BLUETOOTH_A2DP;
2946 device = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET;
2948 device = AUDIO_DEVICE_IN_WIRED_HEADSET;
2950 device = AUDIO_DEVICE_IN_USB_DEVICE;
2952 device = AUDIO_DEVICE_IN_BUILTIN_MIC;
2957 device = AUDIO_DEVICE_IN_BACK_MIC;
2959 device = AUDIO_DEVICE_IN_BUILTIN_MIC;
2965 device = AUDIO_DEVICE_IN_VOICE_CALL;
2970 device = AUDIO_DEVICE_IN_REMOTE_SUBMIX;
2977 ALOGV("getDeviceForInputSource()input source %d, device %08x", inputSource, device);
2978 return device;
2981 bool AudioPolicyManagerBase::isVirtualInputDevice(audio_devices_t device)
2983 if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
2984 device &= ~AUDIO_DEVICE_BIT_IN;
2985 if ((popcount(device) == 1) && ((device & ~APM_AUDIO_IN_DEVICE_VIRTUAL_ALL) == 0))
3004 audio_devices_t AudioPolicyManagerBase::getDeviceForVolume(audio_devices_t device)
3006 if (device == AUDIO_DEVICE_NONE) {
3009 device = AUDIO_DEVICE_OUT_SPEAKER;
3010 } else if (AudioSystem::popCount(device) > 1) {
3011 // Multiple device selection is either:
3012 // - speaker + one other device: give priority to speaker in this case.
3013 // - one A2DP device + another device: happens with duplicated output. In this case
3014 // retain the device on the A2DP output as the other must not correspond to an active
3016 if (device & AUDIO_DEVICE_OUT_SPEAKER) {
3017 device = AUDIO_DEVICE_OUT_SPEAKER;
3019 device = (audio_devices_t)(device & AUDIO_DEVICE_OUT_ALL_A2DP);
3023 ALOGW_IF(AudioSystem::popCount(device) != 1,
3024 "getDeviceForVolume() invalid device combination: %08x",
3025 device);
3027 return device;
3030 AudioPolicyManagerBase::device_category AudioPolicyManagerBase::getDeviceCategory(audio_devices_t device)
3032 switch(getDeviceForVolume(device)) {
3054 float AudioPolicyManagerBase::volIndexToAmpl(audio_devices_t device
3057 device_category deviceCategory = getDeviceCategory(device);
3236 audio_devices_t device)
3242 if (device == AUDIO_DEVICE_NONE) {
3243 device = outputDesc->device();
3249 (device == AUDIO_DEVICE_OUT_AUX_DIGITAL ||
3250 device == AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET)) {
3254 volume = volIndexToAmpl(device, streamDesc, index);
3262 if ((device & (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
3298 audio_devices_t device,
3318 float volume = computeVolume(stream, index, output, device);
3354 audio_devices_t device,
3358 ALOGVV("applyStreamVolumes() for output %d and device %x", output, device);
3362 mStreams[stream].getVolumeIndex(device),
3364 device,
3374 audio_devices_t device)
3379 setStreamMute(stream, on, output, delayMs, device);
3388 audio_devices_t device)
3392 if (device == AUDIO_DEVICE_NONE) {
3393 device = outputDesc->device();
3396 ALOGVV("setStreamMute() stream %d, mute %d, output %d, mMuteCount %d device %04x",
3397 stream, on, output, outputDesc->mMuteCount[stream], device);
3404 checkAndSetVolume(stream, 0, output, device, delayMs);
3416 streamDesc.getVolumeIndex(device),
3418 device,
3428 // in the device used for phone strategy and play the tone if the selected device does not
3429 // interfere with the device used for phone strategy
3436 ALOGV("handleIncallSonification() stream %d starting %d device %x stateChange %d",
3450 if (outputDesc->device() &
3515 audio_devices_t AudioPolicyManagerBase::AudioOutputDescriptor::device() const
3628 snprintf(buffer, SIZE, " Devices %08x\n", device());
3684 int AudioPolicyManagerBase::StreamDescriptor::getVolumeIndex(audio_devices_t device)
3686 device = AudioPolicyManagerBase::getDeviceForVolume(device);
3688 if (mIndexCur.indexOfKey(device) < 0) {
3689 device = AUDIO_DEVICE_OUT_DEFAULT;
3691 return mIndexCur.valueFor(device);
3796 bool AudioPolicyManagerBase::IOProfile::isCompatibleProfile(audio_devices_t device,
3806 if ((mSupportedDevices & device) != device) {
4029 uint32_t device = 0;
4034 device |= stringToEnum(sDeviceNameToEnumTable,
4040 return device;
4302 "loadGlobalConfig() default device not specified");