Lines Matching refs:device

27 // A device mask for all audio input devices that are considered "virtual" when evaluating
45 status_t AudioPolicyManagerBase::setDeviceConnectionState(audio_devices_t device,
51 ALOGV("setDeviceConnectionState() device: %x, state %d, address %s", device, state, device_address);
53 // connect/disconnect only 1 device at a time
54 if (!audio_is_output_device(device) && !audio_is_input_device(device)) return BAD_VALUE;
62 if (audio_is_output_device(device)) {
64 if (!mHasA2dp && audio_is_a2dp_device(device)) {
65 ALOGE("setDeviceConnectionState() invalid A2DP device: %x", device);
68 if (!mHasUsb && audio_is_usb_device(device)) {
69 ALOGE("setDeviceConnectionState() invalid USB audio device: %x", device);
72 if (!mHasRemoteSubmix && audio_is_remote_submix_device((audio_devices_t)device)) {
73 ALOGE("setDeviceConnectionState() invalid remote submix audio device: %x", device);
82 // handle output device connection
84 if (mAvailableOutputDevices & device) {
85 ALOGW("setDeviceConnectionState() device already connected: %x", device);
88 ALOGV("setDeviceConnectionState() connecting device %x", device);
90 if (checkOutputsForDevice(device, state, outputs) != NO_ERROR) {
95 // register new device as available
96 mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices | device);
100 if (mHasA2dp && audio_is_a2dp_device(device)) {
101 // handle A2DP device connection
107 } else if (audio_is_bluetooth_sco_device(device)) {
108 // handle SCO device connection
110 } else if (mHasUsb && audio_is_usb_device(device)) {
111 // handle USB device connection
124 // handle output device disconnection
126 if (!(mAvailableOutputDevices & device)) {
127 ALOGW("setDeviceConnectionState() device not connected: %x", device);
131 ALOGV("setDeviceConnectionState() disconnecting device %x", device);
132 // remove device from available output devices
133 mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices & ~device);
135 checkOutputsForDevice(device, state, outputs);
136 if (mHasA2dp && audio_is_a2dp_device(device)) {
137 // handle A2DP device disconnection
140 } else if (audio_is_bluetooth_sco_device(device)) {
141 // handle SCO device disconnection
143 } else if (mHasUsb && audio_is_usb_device(device)) {
144 // handle USB device disconnection
161 // close unused outputs after device disconnection or direct outputs that have been
178 if (device == AUDIO_DEVICE_OUT_WIRED_HEADSET) {
179 device = AUDIO_DEVICE_IN_WIRED_HEADSET;
180 } else if (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO ||
181 device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET ||
182 device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) {
183 device = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET;
189 if (audio_is_input_device(device)) {
193 // handle input device connection
195 if (mAvailableInputDevices & device) {
196 ALOGW("setDeviceConnectionState() device already connected: %d", device);
199 mAvailableInputDevices = mAvailableInputDevices | (device & ~AUDIO_DEVICE_BIT_IN);
203 // handle input device disconnection
205 if (!(mAvailableInputDevices & device)) {
206 ALOGW("setDeviceConnectionState() device not connected: %d", device);
209 mAvailableInputDevices = (audio_devices_t) (mAvailableInputDevices & ~device);
222 ALOGV("setDeviceConnectionState() changing device from %x to %x for input %d",
234 ALOGW("setDeviceConnectionState() invalid device: %x", device);
238 AudioSystem::device_connection_state AudioPolicyManagerBase::getDeviceConnectionState(audio_devices_t device,
243 if (audio_is_output_device(device)) {
244 if (device & mAvailableOutputDevices) {
245 if (audio_is_a2dp_device(device) &&
249 if (audio_is_bluetooth_sco_device(device) &&
253 if (audio_is_usb_device(device) &&
255 ALOGE("getDeviceConnectionState() invalid device: %x", device);
258 if (audio_is_remote_submix_device((audio_devices_t)device) && !mHasRemoteSubmix) {
263 } else if (audio_is_input_device(device)) {
264 if (device & mAvailableInputDevices) {
304 // even if no device change is needed
309 // even if no device change is needed
314 // even if no device change is needed
318 // check for device and output changes triggered by new phone state
327 // even if no device change is needed
329 newDevice = hwOutputDesc->device();
337 // delay the device change command by twice the output latency to have some margin
368 // setting output device above
444 // check for device and output changes triggered by new force usage
462 ALOGV("setForceUse() changing device from %x to %x for input %d",
484 audio_devices_t device,
496 if (profile->isCompatibleProfile(device, samplingRate, format,
517 audio_devices_t device = getDeviceForStrategy(strategy, false /*fromCache*/);
554 IOProfile *profile = getProfileForDirectOutput(device,
561 ALOGV("getOutput() opening direct output device %x", device);
564 outputDesc->mDevice = device;
606 SortedVector<audio_io_handle_t> outputs = getOutputsForDevice(device, mOutputs);
621 // select one output among several that provide a path to a particular device or set of
692 // force a device change if any other output is managed by the same hw
693 // module and has a current device selection that differs from selected device.
694 // In this case, the audio HAL must receive the new device selection so that it can
695 // change the device currently selected by the other active output.
697 desc->device() != newDevice) {
714 // apply volume rules for current stream and device if necessary
756 // delay the device switch by twice the latency because stopOutput() is executed when
763 // force restoring the device selection on other active outputs if it differs from the
771 newDevice != desc->device()) {
827 audio_devices_t device = getDeviceForInputSource(inputSource);
832 if (device == AUDIO_DEVICE_NONE) {
833 ALOGW("getInput() could not find device for inputSource %d", inputSource);
852 IOProfile *profile = getInputProfile(device,
857 ALOGW("getInput() could not find profile for device %04x, samplingRate %d, format %d,"
859 device, samplingRate, format, channelMask);
871 inputDesc->mDevice = device;
983 audio_devices_t device)
989 if (!audio_is_output_device(device)) {
996 ALOGV("setStreamVolumeIndex() stream %d, device %04x, index %d",
997 stream, device, index);
999 // if device is AUDIO_DEVICE_OUT_DEFAULT set default value and
1000 // clear all device specific values
1001 if (device == AUDIO_DEVICE_OUT_DEFAULT) {
1004 mStreams[stream].mIndexCur.add(device, index);
1006 // compute and apply stream volume on all outputs according to connected device
1010 getDeviceForVolume(mOutputs.valueAt(i)->device());
1011 if (device == curDevice) {
1023 audio_devices_t device)
1028 if (!audio_is_output_device(device)) {
1031 // if device is AUDIO_DEVICE_OUT_DEFAULT, return volume for device corresponding to
1033 if (device == AUDIO_DEVICE_OUT_DEFAULT) {
1034 device = getDeviceForStrategy(getStrategy(stream), true /*fromCache*/);
1036 device = getDeviceForVolume(device);
1038 *index = mStreams[stream].getVolumeIndex(device);
1039 ALOGV("getStreamVolumeIndex() stream %d device %08x index %d", stream, device, *index);
1049 audio_devices_t device = getDeviceForStrategy(strategy, false /*fromCache*/);
1050 SortedVector<audio_io_handle_t> dstOutputs = getOutputsForDevice(device, mOutputs);
1202 snprintf(buffer, SIZE, " A2DP device address: %s\n", mA2dpDeviceAddress.string());
1204 snprintf(buffer, SIZE, " SCO device address: %s\n", mScoDeviceAddress.string());
1254 " Stream Can be muted Index Min Index Max Index Cur [device : index]...\n");
1571 status_t AudioPolicyManagerBase::checkOutputsForDevice(audio_devices_t device,
1578 // first list already open outputs that can be routed to this device
1581 if (!desc->isDuplicated() && (desc->mProfile->mSupportedDevices & device)) {
1586 // then look for output profiles that can be routed to this device
1595 if (mHwModules[i]->mOutputProfiles[j]->mSupportedDevices & device) {
1603 ALOGW("checkOutputsForDevice(): No output available for device %04x", device);
1624 ALOGV("opening output for device %08x", device);
1626 desc->mDevice = device;
1683 // set initial stream volume for device
1684 applyStreamVolumes(output, device, 0, true);
1701 applyStreamVolumes(duplicatedOutput, device, 0, true);
1712 ALOGW("checkOutputsForDevice() could not open output for device %x", device);
1723 ALOGW("checkOutputsForDevice(): No output available for device %04x", device);
1727 // check if one opened output is not needed any more after disconnecting one device
1744 if ((profile->mSupportedDevices & device) &&
1815 SortedVector<audio_io_handle_t> AudioPolicyManagerBase::getOutputsForDevice(audio_devices_t device,
1820 ALOGVV("getOutputsForDevice() device %04x", device);
1822 ALOGVV("output %d isDuplicated=%d device=%04x",
1824 if ((device & openOutputs.valueAt(i)->supportedDevices()) == device) {
1919 if (!outputDesc->isDuplicated() && outputDesc->device() & AUDIO_DEVICE_OUT_ALL_A2DP) {
1939 // ((SCO device is connected &&
1945 // ((SCO device is NOT connected ||
1974 audio_devices_t device = AUDIO_DEVICE_NONE;
1979 // use device for strategy enforced audible
1981 // use device for strategy phone
1983 // use device for strategy sonification
1985 // use device for strategy "respectful" sonification
1987 // use device for strategy media
1989 // use device for strategy DTMF
1991 device = getDeviceForStrategy(STRATEGY_ENFORCED_AUDIBLE, fromCache);
1994 device = getDeviceForStrategy(STRATEGY_PHONE, fromCache);
1996 device = getDeviceForStrategy(STRATEGY_SONIFICATION, fromCache);
1998 device = getDeviceForStrategy(STRATEGY_SONIFICATION_RESPECTFUL, fromCache);
2000 device = getDeviceForStrategy(STRATEGY_MEDIA, fromCache);
2002 device = getDeviceForStrategy(STRATEGY_DTMF, fromCache);
2005 ALOGV("getNewDevice() selected device %x", device);
2006 return device;
2068 uint32_t device = AUDIO_DEVICE_NONE;
2071 ALOGVV("getDeviceForStrategy() from cache strategy %d, device %x",
2080 device = getDeviceForStrategy(STRATEGY_SONIFICATION, false /*fromCache*/);
2082 // while media is playing (or has recently played), use the same device
2083 device = getDeviceForStrategy(STRATEGY_MEDIA, false /*fromCache*/);
2086 device = getDeviceForStrategy(STRATEGY_SONIFICATION, false /*fromCache*/);
2094 device = getDeviceForStrategy(STRATEGY_MEDIA, false /*fromCache*/);
2106 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
2107 if (device) break;
2109 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
2110 if (device) break;
2111 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_SCO;
2112 if (device) break;
2113 // if SCO device is requested but no SCO device is available, fall back to default case
2121 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP;
2122 if (device) break;
2123 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES;
2124 if (device) break;
2126 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE;
2127 if (device) break;
2128 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_WIRED_HEADSET;
2129 if (device) break;
2131 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_USB_ACCESSORY;
2132 if (device) break;
2133 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_USB_DEVICE;
2134 if (device) break;
2135 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET;
2136 if (device) break;
2137 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_AUX_DIGITAL;
2138 if (device) break;
2139 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET;
2140 if (device) break;
2142 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_EARPIECE;
2143 if (device) break;
2144 device = mDefaultOutputDevice;
2145 if (device == AUDIO_DEVICE_NONE) {
2146 ALOGE("getDeviceForStrategy() no device found for STRATEGY_PHONE");
2156 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER;
2157 if (device) break;
2160 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_USB_ACCESSORY;
2161 if (device) break;
2162 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_USB_DEVICE;
2163 if (device) break;
2164 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET;
2165 if (device) break;
2166 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_AUX_DIGITAL;
2167 if (device) break;
2168 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET;
2169 if (device) break;
2171 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_SPEAKER;
2172 if (device) break;
2173 device = mDefaultOutputDevice;
2174 if (device == AUDIO_DEVICE_NONE) {
2175 ALOGE("getDeviceForStrategy() no device found for STRATEGY_PHONE, FORCE_SPEAKER");
2183 // If incall, just select the STRATEGY_PHONE device: The rest of the behavior is handled by
2186 device = getDeviceForStrategy(STRATEGY_PHONE, false /*fromCache*/);
2199 device = mAvailableOutputDevices & AUDIO_DEVICE_OUT_SPEAKER;
2200 if (device == AUDIO_DEVICE_NONE) {
2201 ALOGE("getDeviceForStrategy() speaker device not found for STRATEGY_SONIFICATION");
2204 // The second device used for sonification is the same as the device used by media strategy
2251 // device is DEVICE_OUT_SPEAKER if we come from case STRATEGY_SONIFICATION or
2253 device |= device2;
2254 if (device) break;
2255 device = mDefaultOutputDevice;
2256 if (device == AUDIO_DEVICE_NONE) {
2257 ALOGE("getDeviceForStrategy() no device found for STRATEGY_MEDIA");
2266 ALOGVV("getDeviceForStrategy() strategy %d, device %x", strategy, device);
2267 return device;
2282 // mute/unmute strategies using an incompatible device combination
2290 audio_devices_t device = outputDesc->device();
2292 (AudioSystem::popCount(device) >= 2);
2293 // temporary mute output if device selection changes to avoid volume bursts due to
2294 // different per device volumes
2295 bool tempMute = (outputDesc->refCount() != 0) && (device != prevDevice);
2299 bool mute = shouldMute && (curDevice & device) && (curDevice != device);
2324 desc->latency() * 2, device);
2351 audio_devices_t device,
2355 ALOGV("setOutputDevice() output %d device %04x delayMs %d", output, device, delayMs);
2361 muteWaitMs = setOutputDevice(outputDesc->mOutput1->mId, device, force, delayMs);
2362 muteWaitMs += setOutputDevice(outputDesc->mOutput2->mId, device, force, delayMs);
2366 device = (audio_devices_t)(device & outputDesc->mProfile->mSupportedDevices);
2372 if (device != AUDIO_DEVICE_NONE) {
2373 outputDesc->mDevice = device;
2378 // - the requested device is AUDIO_DEVICE_NONE
2379 // - the requested device is the same as current device and force is not specified.
2381 if ((device == AUDIO_DEVICE_NONE || device == prevDevice) && !force) {
2382 ALOGV("setOutputDevice() setting same device %04x or null device for output %d", device, output);
2386 ALOGV("setOutputDevice() changing device");
2388 param.addInt(String8(AudioParameter::keyRouting), (int)device);
2391 // update stream volumes according to new device
2392 applyStreamVolumes(output, device, delayMs);
2397 AudioPolicyManagerBase::IOProfile *AudioPolicyManagerBase::getInputProfile(audio_devices_t device,
2413 if (profile->isCompatibleProfile(device, samplingRate, format,
2424 uint32_t device = AUDIO_DEVICE_NONE;
2433 device = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET;
2435 device = AUDIO_DEVICE_IN_WIRED_HEADSET;
2437 device = AUDIO_DEVICE_IN_BUILTIN_MIC;
2442 device = AUDIO_DEVICE_IN_BACK_MIC;
2444 device = AUDIO_DEVICE_IN_BUILTIN_MIC;
2451 device = AUDIO_DEVICE_IN_VOICE_CALL;
2456 device = AUDIO_DEVICE_IN_REMOTE_SUBMIX;
2463 ALOGV("getDeviceForInputSource()input source %d, device %08x", inputSource, device);
2464 return device;
2467 bool AudioPolicyManagerBase::isVirtualInputDevice(audio_devices_t device)
2469 if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
2470 device &= ~AUDIO_DEVICE_BIT_IN;
2471 if ((popcount(device) == 1) && ((device & ~APM_AUDIO_IN_DEVICE_VIRTUAL_ALL) == 0))
2490 audio_devices_t AudioPolicyManagerBase::getDeviceForVolume(audio_devices_t device)
2492 if (device == AUDIO_DEVICE_NONE) {
2495 device = AUDIO_DEVICE_OUT_SPEAKER;
2496 } else if (AudioSystem::popCount(device) > 1) {
2497 // Multiple device selection is either:
2498 // - speaker + one other device: give priority to speaker in this case.
2499 // - one A2DP device + another device: happens with duplicated output. In this case
2500 // retain the device on the A2DP output as the other must not correspond to an active
2502 if (device & AUDIO_DEVICE_OUT_SPEAKER) {
2503 device = AUDIO_DEVICE_OUT_SPEAKER;
2505 device = (audio_devices_t)(device & AUDIO_DEVICE_OUT_ALL_A2DP);
2509 ALOGW_IF(AudioSystem::popCount(device) != 1,
2510 "getDeviceForVolume() invalid device combination: %08x",
2511 device);
2513 return device;
2516 AudioPolicyManagerBase::device_category AudioPolicyManagerBase::getDeviceCategory(audio_devices_t device)
2518 switch(getDeviceForVolume(device)) {
2540 float AudioPolicyManagerBase::volIndexToAmpl(audio_devices_t device, const StreamDescriptor& streamDesc,
2543 device_category deviceCategory = getDeviceCategory(device);
2698 audio_devices_t device)
2704 if (device == AUDIO_DEVICE_NONE) {
2705 device = outputDesc->device();
2711 (device == AUDIO_DEVICE_OUT_AUX_DIGITAL ||
2712 device == AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET ||
2713 device == AUDIO_DEVICE_OUT_USB_ACCESSORY ||
2714 device == AUDIO_DEVICE_OUT_USB_DEVICE)) {
2718 volume = volIndexToAmpl(device, streamDesc, index);
2726 if ((device & (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
2762 audio_devices_t device,
2782 float volume = computeVolume(stream, index, output, device);
2818 audio_devices_t device,
2822 ALOGVV("applyStreamVolumes() for output %d and device %x", output, device);
2826 mStreams[stream].getVolumeIndex(device),
2828 device,
2838 audio_devices_t device)
2843 setStreamMute(stream, on, output, delayMs, device);
2852 audio_devices_t device)
2856 if (device == AUDIO_DEVICE_NONE) {
2857 device = outputDesc->device();
2860 ALOGVV("setStreamMute() stream %d, mute %d, output %d, mMuteCount %d device %04x",
2861 stream, on, output, outputDesc->mMuteCount[stream], device);
2868 checkAndSetVolume(stream, 0, output, device, delayMs);
2880 streamDesc.getVolumeIndex(device),
2882 device,
2892 // in the device used for phone strategy and play the tone if the selected device does not
2893 // interfere with the device used for phone strategy
2900 ALOGV("handleIncallSonification() stream %d starting %d device %x stateChange %d",
2914 if (outputDesc->device() &
2946 audio_devices_t device)
2989 audio_devices_t AudioPolicyManagerBase::AudioOutputDescriptor::device()
3080 snprintf(buffer, SIZE, " Devices %08x\n", device());
3131 int AudioPolicyManagerBase::StreamDescriptor::getVolumeIndex(audio_devices_t device)
3133 device = AudioPolicyManagerBase::getDeviceForVolume(device);
3135 if (mIndexCur.indexOfKey(device) < 0) {
3136 device = AUDIO_DEVICE_OUT_DEFAULT;
3138 return mIndexCur.valueFor(device);
3242 bool AudioPolicyManagerBase::IOProfile::isCompatibleProfile(audio_devices_t device,
3248 if ((mSupportedDevices & device) != device) {
3428 uint32_t device = 0;
3433 device |= stringToEnum(sDeviceNameToEnumTable,
3439 return device;
3701 "loadGlobalConfig() default device not specified");