Home | History | Annotate | Download | only in managerdefault

Lines Matching refs:device

56 status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
61 return setDeviceConnectionStateInt(device, state, device_address, device_name);
64 status_t AudioPolicyManager::setDeviceConnectionStateInt(audio_devices_t device,
69 ALOGV("setDeviceConnectionStateInt() device: 0x%X, state %d, address %s name %s",
70 - device, state, device_address, device_name);
72 // connect/disconnect only 1 device at a time
73 if (!audio_is_output_device(device) && !audio_is_input_device(device)) return BAD_VALUE;
76 mHwModules.getDeviceDescriptor(device, device_address, device_name);
79 if (audio_is_output_device(device)) {
89 // handle output device connection
92 ALOGW("setDeviceConnectionState() device already connected: %x", device);
95 ALOGV("setDeviceConnectionState() connecting device %x", device);
97 // register new device as available
100 sp<HwModule> module = mHwModules.getModuleForDevice(device);
102 ALOGD("setDeviceConnectionState() could not find HW module for device %08x",
103 device);
116 // Propagate device availability to Engine
127 param.addInt(String8(AUDIO_PARAMETER_DEVICE_CONNECT), device);
131 // handle output device disconnection
134 ALOGW("setDeviceConnectionState() device not connected: %x", device);
138 ALOGV("setDeviceConnectionState() disconnecting output device %x", device);
142 param.addInt(String8(AUDIO_PARAMETER_DEVICE_DISCONNECT), device);
145 // remove device from available output devices
150 // Propagate device availability to Engine
167 // close unused outputs after device disconnection or direct outputs that have been
188 // do not force device change on duplicated output because if device is 0, it will
189 // also force a device 0 for the two outputs it is duplicated to which may override
190 // a valid device selection on those outputs.
192 && (!device_distinguishes_on_address(device)
193 // always force when disconnecting (a non-duplicated device)
205 } // end if is output device
208 if (audio_is_input_device(device)) {
214 // handle input device connection
217 ALOGW("setDeviceConnectionState() device already connected: %d", device);
220 sp<HwModule> module = mHwModules.getModuleForDevice(device);
222 ALOGW("setDeviceConnectionState(): could not find HW module for device %08x",
223 device);
239 param.addInt(String8(AUDIO_PARAMETER_DEVICE_CONNECT), device);
242 // Propagate device availability to Engine
246 // handle input device disconnection
249 ALOGW("setDeviceConnectionState() device not connected: %d", device);
253 ALOGV("setDeviceConnectionState() disconnecting input device %x", device);
257 param.addInt(String8(AUDIO_PARAMETER_DEVICE_DISCONNECT), device);
263 // Propagate device availability to Engine
285 } // end if is input device
287 ALOGW("setDeviceConnectionState() invalid device: %x", device);
291 audio_policy_dev_state_t AudioPolicyManager::getDeviceConnectionState(audio_devices_t device,
295 mHwModules.getDeviceDescriptor(device, device_address, "",
299 ALOGW("getDeviceConnectionState() undeclared device, type %08x, address: %s",
300 device, device_address);
306 if (audio_is_output_device(device)) {
308 } else if (audio_is_input_device(device)) {
311 ALOGW("getDeviceConnectionState() invalid device type %08x", device);
315 return (deviceVector->getDevice(device, String8(device_address)) != 0) ?
330 ALOGV("updateCallRouting device rxDevice %08x txDevice %08x", rxDevice, txDevice);
343 // If the RX device is on the primary HW module, then use legacy routing method for voice calls
348 // If the TX device is also on the primary HW module, setOutputDevice() will take care
361 "updateCallRouting() selected device not in output device list");
365 "updateCallRouting() no telephony RX device");
371 // request to reuse existing output stream if one is already opened to reach the RX device
380 "updateCallRouting() RX device output is duplicated");
404 "updateCallRouting() selected device not in input device list");
409 "updateCallRouting() no telephony TX device");
419 // path output device
423 "updateCallRouting() RX device output is duplicated");
429 // terminate active capture if on the same HW module as the call TX source device
431 // call TX device but this information is not in the audio patch and logic here must be
487 // check for device and output changes triggered by new phone state
497 // mute media and sonification strategies and delay device switch by the largest
520 // the device returned is not necessarily reachable via this output
523 // even if no device change is needed
525 rxDevice = mPrimaryOutput->device();
582 // check for device and output changes triggered by new force usage
606 // Force new input selection if the new device can not be reached via current input
623 audio_devices_t device,
644 if (!curProfile->isCompatibleProfile(device, String8(""),
651 // reject profiles not corresponding to a device currently available
676 audio_devices_t device = getDeviceForStrategy(strategy, false /*fromCache*/);
677 ALOGV("getOutput() device %d, stream %d, samplingRate %d, format %x, channelMask %x, flags %x",
678 device, stream, samplingRate, format, channelMask, flags);
680 return getOutputForDevice(device, AUDIO_SESSION_ALLOCATE,
747 audio_devices_t device = getDeviceForStrategy(strategy, false /*fromCache*/);
753 ALOGV("getOutputForAttr() device 0x%x, samplingRate %d, format %x, channelMask %x, flags %x",
754 device, samplingRate, format, channelMask, flags);
756 *output = getOutputForDevice(device, session, *stream,
768 audio_devices_t device,
865 profile = getProfileForDirectOutput(device,
911 outputDesc->mDevice = device;
982 SortedVector<audio_io_handle_t> outputs = getOutputsForDevice(device, mOutputs);
1000 // select one output among several that provide a path to a particular device or set of
1137 audio_devices_t device,
1165 if (outputDesc->mRefCount[stream] == 1 || device != AUDIO_DEVICE_NONE) {
1167 if (device == AUDIO_DEVICE_NONE) {
1168 device = getNewOutputDevice(outputDesc, false /*fromCache*/);
1178 // force a device change if any other output is managed by the same hw
1179 // module and has a current device selection that differs from selected device.
1180 // In this case, the audio HAL must receive the new device selection so that it can
1181 // change the device currently selected by the other active output.
1183 desc->device() != device) {
1195 uint32_t muteWaitMs = setOutputDevice(outputDesc, device, force, 0, NULL, address);
1202 // apply volume rules for current stream and device if necessary
1204 mVolumeCurves->getVolumeIndex(stream, device),
1206 device);
1281 // delay the device switch by twice the latency because stopOutput() is executed when
1288 // force restoring the device selection on other active outputs if it differs from the
1296 (newDevice != desc->device())) {
1379 audio_devices_t device;
1408 device = AUDIO_DEVICE_IN_REMOTE_SUBMIX;
1411 device = getDeviceAndMixForInputSource(inputSource, &policyMix);
1412 if (device == AUDIO_DEVICE_NONE) {
1413 ALOGW("getInputForAttr() could not find device for source %d", inputSource);
1428 } else if (audio_is_remote_submix_device(device)) {
1431 } else if (device == AUDIO_DEVICE_IN_TELEPHONY_RX) {
1439 *input = getInputForDevice(device, address, session, uid, inputSource,
1451 audio_io_handle_t AudioPolicyManager::getInputForDevice(audio_devices_t device,
1486 profile = getInputProfile(device, address,
1494 ALOGW("getInputForDevice() could not find profile for device 0x%X,"
1496 device, samplingRate, format, channelMask, flags);
1556 &device,
1579 inputDesc->mDevice = device;
1609 // for a non-virtual input device, check if there is another (non-virtual) active input
1635 // the call TX source device is on the same HW module.
1637 // call TX device but this information is not in the audio patch
1639 inputDesc->getModuleHandle() == mCallTxPatch->mPatch.sources[0].ext.device.hw_module) {
1662 // For remote submix (a virtual device), we open only one input per capture request.
1829 audio_devices_t device)
1836 if (!audio_is_output_device(device)) {
1843 ALOGV("setStreamVolumeIndex() stream %d, device %08x, index %d",
1844 stream, device, index);
1851 mVolumeCurves->addCurrentVolumeIndex((audio_stream_type_t)curStream, device, index);
1856 // - The device (or devices) selected by the strategy corresponding to this stream includes
1857 // the requested device
1858 // - For non default requested device, currently selected device on the output is either the
1859 // requested device or one of the devices selected by the strategy
1860 // - For default requested device (AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME), apply volume only if
1861 // no specific device volume value exists for currently selected device.
1865 audio_devices_t curDevice = Volume::getDeviceForVolume(desc->device());
1876 if ((curStreamDevice & device) == 0) {
1880 if (device != AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME) {
1881 curStreamDevice |= device;
1901 audio_devices_t device)
1906 if (!audio_is_output_device(device)) {
1909 // if device is AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME, return volume for device corresponding to
1911 if (device == AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME) {
1912 device = getDeviceForStrategy(getStrategy(stream), true /*fromCache*/);
1914 device = Volume::getDeviceForVolume(device);
1916 *index = mVolumeCurves->getVolumeIndex(stream, device);
1917 ALOGV("getStreamVolumeIndex() stream %d device %08x index %d", stream, device, *index);
1967 audio_devices_t device = getDeviceForStrategy(strategy, false /*fromCache*/);
1968 SortedVector<audio_io_handle_t> dstOutputs = getOutputsForDevice(device, mOutputs);
2026 // The corresponding input remote submix device is also connected.
2028 // When a remote submix device is connected, the address is checked to select the
2035 // - 2.2 if none found, default to device selection by policy rules
2036 // At this time, the corresponding output remote submix device is also connected
2043 // - 3 if none found, default to device and output selection by policy rules.
2107 audio_devices_t device = mixes[i].mDeviceType;
2109 i, mixes.size(), device, address.string());
2117 && (patch->mPatch.sinks[0].ext.device.type == device)
2118 && (strncmp(patch->mPatch.sinks[0].ext.device.address, address.string(),
2130 ALOGE(" Error registering mix %zu for device 0x%X addr %s",
2131 i, device, address.string());
2135 ALOGE(" Output not found for mix %zu for device 0x%X addr %s",
2136 i, device, address.string());
2317 sp<IOProfile> profile = getProfileForDirectOutput(AUDIO_DEVICE_NONE /*ignore device */,
2474 ALOGV("createAudioPatch() source mix but sink is not a device");
2480 ALOGV("createAudioPatch() out device not found for id %d", patch->sinks[i].id);
2493 ALOGV("createAudioPatch() profile not supported for device %08x",
2504 ALOGV("createAudioPatch() setting device %08x on output %d",
2521 // input device to input mix connection
2522 // only one sink supported when connecting an input device to a mix
2556 ALOGV("createAudioPatch() setting device %08x on output %d",
2572 // device to device connection
2591 ALOGV("createAudioPatch() source device but one sink is not a device");
2607 // support only one sink device for now to simplify output selection logic
2613 // if the sink device is reachable via an opened output stream, request to go via
2653 ALOGW("createAudioPatch() patch panel could not connect device patch, error %d",
2820 audio_devices_t device = getDeviceForStrategy(strategy, false /*fromCache*/);
2821 SortedVector<audio_io_handle_t> outputs = getOutputsForDevice(device, mOutputs);
2830 // If the default device for this strategy is on another output mix,
2832 // Otherwise select new device on the output mix.
2900 audio_devices_t *device)
2904 *device = getDeviceAndMixForInputSource(AUDIO_SOURCE_HOTWORD);
2928 mAvailableInputDevices.getDevice(source->ext.device.type,
2929 String8(source->ext.device.address));
2931 ALOGV("%s source->ext.device.type %08x not found", __FUNCTION__, source->ext.device.type);
2972 // create patch between src device and output device
2979 ALOGV("%s no output for device %08x", __FUNCTION__, sinkDevice);
2984 ALOGV("%s output for device %08x is duplicated", __FUNCTION__, sinkDevice);
2990 // - the sink is defined by whatever output device is currently selected for the output
3003 ALOGW("%s patch panel could not connect device patch, error %d",
3098 // release patch between src device and output device
3209 ALOGW("Output profile contains no device on module %s", mHwModules[i]->getName());
3223 // chose first device present in profile's SupportedDevices also part of
3252 ALOGW("Cannot open output stream for device %08x on hw module %s",
3262 // give a valid ID to an attached device once confirmed it is reachable
3287 ALOGW("Input profile contains no device on module %s", mHwModules[i]->getName());
3290 // chose first device present in profile's SupportedDevices also part of
3307 ALOGV(" for input device 0x%x using address %s", profileType, address.string());
3308 ALOGE_IF(inputDevices.size() == 0, "Input device list is empty!");
3327 // give a valid ID to an attached device once confirmed it is reachable
3338 ALOGW("Cannot open input stream for device %08x on hw module %s",
3347 ALOGW("Output device %08x unreachable", mAvailableOutputDevices[i]->type());
3351 // The device is now validated and can be appended to the available devices of the engine
3358 ALOGW("Input device %08x unreachable", mAvailableInputDevices[i]->type());
3362 // The device is now validated and can be appended to the available devices of the engine
3367 // make sure default device is reachable
3369 ALOGE("Default device %08x is unreachable", mDefaultOutputDevice->type());
3605 const audio_devices_t device /*in*/,
3609 desc->mProfile->getSupportedDeviceByAddress(device, address);
3622 audio_devices_t device = devDesc->type();
3625 if (audio_device_is_digital(device)) {
3631 // first list already open outputs that can be routed to this device
3634 if (!desc->isDuplicated() && (desc->supportedDevices() & device)) {
3635 if (!device_distinguishes_on_address(device)) {
3639 ALOGV(" checking address match due to device 0x%x", device);
3640 findIoHandlesByAddress(desc, device, address, outputs);
3644 // then look for output profiles that can be routed to this device
3654 if (profile->supportDevice(device)) {
3655 if (!device_distinguishes_on_address(device) ||
3667 ALOGW("checkOutputsForDevice(): No output available for device %04x", device);
3682 // by the profile in our device descriptor
3683 if (audio_device_is_digital(device)) {
3693 ALOGV("opening output for device %08x with params %s profile %p",
3694 device, address.string(), profile.get());
3696 desc->mDevice = device;
3717 // Here is where the out_set_parameters() for card & device gets called
3719 char *param = audio_device_address_to_parameter(device, address);
3723 updateAudioProfiles(device, output, profile->getAudioProfiles());
3753 if (device_distinguishes_on_address(device) && address != "0") {
3768 // set initial stream volume for device
3769 applyStreamVolumes(desc, device, 0, true);
3788 applyStreamVolumes(dupOutputDesc, device, 0, true);
3803 ALOGW("checkOutputsForDevice() could not open output for device %x", device);
3809 if (audio_device_is_digital(device)) {
3813 if (device_distinguishes_on_address(device)) {
3815 device, address.string());
3816 setOutputDevice(desc, device, true/*force*/, 0/*delay*/,
3824 ALOGW("checkOutputsForDevice(): No output available for device %04x", device);
3828 // check if one opened output is not needed any more after disconnecting one device
3832 // exact match on device
3833 if (device_distinguishes_on_address(device) &&
3834 (desc->supportedDevices() == device)) {
3835 findIoHandlesByAddress(desc, device, address, outputs);
3843 // Clear any profiles associated with the disconnected device.
3852 if (profile->supportDevice(device)) {
3868 audio_devices_t device = devDesc->type();
3871 if (audio_device_is_digital(device)) {
3877 // first list already open inputs that can be routed to this device
3880 if (desc->mProfile->supportDevice(device)) {
3886 // then look for input profiles that can be routed to this device
3899 if (profile->supportDevice(device)) {
3900 if (!device_distinguishes_on_address(device) ||
3911 ALOGW("checkInputsForDevice(): No input available for device 0x%X", device);
3925 if (audio_device_is_digital(device)) {
3935 ALOGV("opening input for device 0x%X with params %s", device, address.string());
3937 desc->mDevice = device;
3957 char *param = audio_device_address_to_parameter(device, address);
3961 updateAudioProfiles(device, input, profile->getAudioProfiles());
3974 ALOGW("checkInputsForDevice() could not open input for device 0x%X", device);
3979 if (audio_device_is_digital(device)) {
3987 ALOGW("checkInputsForDevice(): No input available for device 0x%X", device);
3992 // check if one opened input is not needed any more after disconnecting one device
4001 // Clear any profiles associated with the disconnected device.
4010 if (profile->supportDevice(device)) {
4106 audio_devices_t device,
4111 ALOGVV("getOutputsForDevice() device %04x", device);
4113 ALOGVV("output %d isDuplicated=%d device=%04x",
4116 if ((device & openOutputs.valueAt(i)->supportedDevices()) == device) {
4237 // ((SCO device is connected &&
4243 // ((SCO device is NOT connected ||
4273 audio_devices_t device = AUDIO_DEVICE_NONE;
4279 ALOGV("getNewOutputDevice() device %08x forced by patch %d",
4280 outputDesc->device(), outputDesc->getPatchHandle());
4281 return outputDesc->device();
4287 // use device for strategy enforced audible
4289 // use device for strategy phone
4291 // use the device for strategy enforced audible
4293 // use device for strategy sonification
4295 // use device for strategy accessibility
4297 // use device for strategy "respectful" sonification
4299 // use device for strategy media
4301 // use device for strategy DTMF
4303 // use device for strategy t-t-s
4306 device = getDeviceForStrategy(STRATEGY_ENFORCED_AUDIBLE, fromCache);
4309 device = getDeviceForStrategy(STRATEGY_PHONE, fromCache);
4311 device = getDeviceForStrategy(STRATEGY_ENFORCED_AUDIBLE, fromCache);
4313 device = getDeviceForStrategy(STRATEGY_SONIFICATION, fromCache);
4315 device = getDeviceForStrategy(STRATEGY_ACCESSIBILITY, fromCache);
4317 device = getDeviceForStrategy(STRATEGY_SONIFICATION_RESPECTFUL, fromCache);
4319 device = getDeviceForStrategy(STRATEGY_MEDIA, fromCache);
4321 device = getDeviceForStrategy(STRATEGY_DTMF, fromCache);
4323 device = getDeviceForStrategy(STRATEGY_TRANSMITTED_THROUGH_SPEAKER, fromCache);
4325 device = getDeviceForStrategy(STRATEGY_REROUTING, fromCache);
4328 ALOGV("getNewOutputDevice() selected device %x", device);
4329 return device;
4340 ALOGV("getNewInputDevice() device %08x forced by patch %d",
4346 audio_devices_t device = getDeviceAndMixForInputSource(inputDesc->inputSource());
4348 return device;
4381 curDevices |= outputDesc->device();
4493 // the device = the device from the descriptor in the RouteMap, and exit.
4503 ALOGVV("getDeviceForStrategy() from cache strategy %d, device %x",
4522 // mute/unmute strategies using an incompatible device combination
4530 audio_devices_t device = outputDesc->device();
4531 bool shouldMute = outputDesc->isActive() && (popcount(device) >= 2);
4536 bool mute = shouldMute && (curDevice & device) && (curDevice != device);
4549 // skip output if it does not share any device with current output
4573 // temporary mute output if device selection changes to avoid volume bursts due to
4574 // different per device volumes
4575 if (outputDesc->isActive() && (device != prevDevice)) {
4584 muteWaitMs *2, device);
4599 audio_devices_t device,
4605 ALOGV("setOutputDevice() device %04x delayMs %d", device, delayMs);
4610 muteWaitMs = setOutputDevice(outputDesc->subOutput1(), device, force, delayMs);
4611 muteWaitMs += setOutputDevice(outputDesc->subOutput2(), device, force, delayMs);
4614 // no need to proceed if new device is not AUDIO_DEVICE_NONE and not supported by current
4616 if ((device != AUDIO_DEVICE_NONE) &&
4617 ((device & outputDesc->supportedDevices()) == 0)) {
4622 device = (audio_devices_t)(device & outputDesc->supportedDevices());
4628 if (device != AUDIO_DEVICE_NONE) {
4629 outputDesc->mDevice = device;
4634 // the requested device is AUDIO_DEVICE_NONE
4635 // OR the requested device is the same as current device
4639 if ((device == AUDIO_DEVICE_NONE || device == prevDevice) &&
4642 ALOGV("setOutputDevice() setting same device 0x%04x or null device", device);
4646 ALOGV("setOutputDevice() changing device");
4649 if (device == AUDIO_DEVICE_NONE) {
4654 deviceList = mAvailableOutputDevices.getDevicesFromType(device);
4656 deviceList = mAvailableOutputDevices.getDevicesFromTypeAddr(device, String8(address));
4709 ALOGV("%s: inform input %d of device:%d", __func__,
4710 inputDescriptor->mIoHandle, device);
4711 inputCmd.addInt(String8(AudioParameter::keyRouting),device);
4719 // update stream volumes according to new device
4720 applyStreamVolumes(outputDesc, device, delayMs);
4749 audio_devices_t device,
4756 if ((device != AUDIO_DEVICE_NONE) && ((device != inputDesc->mDevice) || force)) {
4757 inputDesc->mDevice = device;
4759 DeviceVector deviceList = mAvailableInputDevices.getDevicesFromType(device);
4770 //only one input device for now
4834 sp<IOProfile> AudioPolicyManager::getInputProfile(audio_devices_t device,
4856 if (profile->isCompatibleProfile(device, address, samplingRate,
4899 audio_devices_t device)
4901 float volumeDB = mVolumeCurves->volIndexToDb(stream, Volume::getDeviceCategory(device), index);
4910 if ((device & (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
4937 if (device & (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
4943 ALOGV("computeVolume increasing volume for stream=%d device=0x%X from %f to %f",
4944 stream, device,
4949 } else if ((Volume::getDeviceForVolume(device) != AUDIO_DEVICE_OUT_SPEAKER) ||
4961 audio_devices_t device,
4981 if (device == AUDIO_DEVICE_NONE) {
4982 device = outputDesc->device();
4985 float volumeDb = computeVolume(stream, index, device);
4986 if (outputDesc->isFixedVolume(device)) {
4990 outputDesc->setVolume(volumeDb, stream, device, delayMs, force);
5012 audio_devices_t device,
5016 ALOGVV("applyStreamVolumes() for device %08x", device);
5020 mVolumeCurves->getVolumeIndex((audio_stream_type_t)stream, device),
5022 device,
5032 audio_devices_t device)
5038 setStreamMute((audio_stream_type_t)stream, on, outputDesc, delayMs, device);
5047 audio_devices_t device)
5049 if (device == AUDIO_DEVICE_NONE) {
5050 device = outputDesc->device();
5053 ALOGVV("setStreamMute() stream %d, mute %d, mMuteCount %d device %04x",
5054 stream, on, outputDesc->mMuteCount[stream], device);
5061 checkAndSetVolume(stream, 0, outputDesc, device, delayMs);
5073 mVolumeCurves->getVolumeIndex(stream, device),
5075 device,
5090 // in the device used for phone strategy and play the tone if the selected device does not
5091 // interfere with the device used for phone strategy
5098 ALOGV("handleIncallSonification() stream %d starting %d device %x stateChange %d",
5112 if (outputDesc->device() &
5257 source->ext.device.type == deviceDesc->type()) {
5264 sink->ext.device.type == deviceDesc->type()) {
5396 void AudioPolicyManager::updateAudioProfiles(audio_devices_t device,
5415 if (device == AUDIO_DEVICE_OUT_HDMI) {
5449 if (device == AUDIO_DEVICE_OUT_HDMI) {