Detailed process of setdeviceconnectionstate

Source: Internet
Author: User
Document directory
  • 2.2.1 output device

Audiopolicymanageralsa. cpp

Status_t audiopolicymanager: setdeviceconnectionstate (audio_devices_t device,
Audiosystem: device_connection_state state,
Const char * device_address)

1. parameter description

Audio_devices_t: Device number to be connected. Common Errors include audio_device_out_speaker = 0x2 audio_device_out_wired_headphone = 0x8.

Audiosystem: device_connection_state:

Enum device_connection_state {
Device_state_unavailable = 0;

Device_state_available = 1

Const char * device_address: used for USB Bluetooth

2. Process: 2.1 only one device can be connected at a time 2.2 is divided into input and output devices 2.2.1 output devices checkoutputsfordevice (device, state, outputs )! = No_error: Find all output that supports device. In this example, output is 2 and 3. mpclientinterface-> setparameters (0, string8 (wiredaccessory_type_headphone); ---> audioflinger: setparameters

---> Dev-> SET_PARAMETERS (Dev, keyvaluepairs. String ());

The request will be called twice, but audiohardwarealsa: setparameters is not called for the second time.

---> Alsa_sound/audio_hw_hal.cpp ": static int adev_set_parameters

----> Audiohardwarealsa: setparameters: Set mdevsettingsflag | = wired_accessory_headphone;

The mdevsettingsflag flag determines this flag in alsadevice. cpp.

There are two devices in total:

2433 I (269: 269) loadhwmodule () loaded primary audio interface from qcom audio HW Hal (audio) handle 1

3015 I (269: 269) loadhwmodule () loaded r_submix audio interface from WiFi display audio Hal (audio) handle 4

The two devices have different SET_PARAMETERS implementations. The main reason is that you still do not understand the intention of the code, so it is easy to get away with it.


Static int adev_set_parameters (struct audio_hw_device * Dev, const char * kvpairs)
R_submix has nothing to do. audiopolicymanagerbase: checkoutputforallstrategies (); ----------> checkoutputforstrategy ();

Whether the output corresponding to the policy changes. This example does not change. updatedevicesandoutputs (); a device is selected for each policy and saved to mdeviceforstrategy.

------> Mdeviceforstrategy [I] = getdeviceforstrategy (routing_strategy) I, false/* fromcache */); getnewdevice (moutputs. keyat (I), true/* fromcache */) Select a policy based on the policy priority level.

-----> Audiopolicymanager: getdeviceforstrategy () according to the policy, select the device setoutputdevice is called twice. First: parameter output = 2 device = 8 second: parameter output = 3 device = 0

------> Alsa_sound/alsadevice. cpp void alsadevice: switchdevice

2.2.2 Input Device

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.