Document directory
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,
Device_state_available,
Num_device_states
};
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 2.2.1.1 checkoutputsfordevice (device, state, outputs )! = No_error: Find all output that supports device. In this example, output is 2 and 3.
2.2.1.2 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.
Hardware/libhardware/modules/audio_remote_submix/audio_h1_cpp
Static int adev_set_parameters (struct audio_hw_device * Dev, const char * kvpairs)
{
Return-enosys;
}
R_submix has nothing to do.
2.2.1.3 audiopolicymanagerbase: checkoutputforallstrategies (); ----------> checkoutputforstrategy ();
Whether the output corresponding to the policy changes. This example does not change.
2.2.1.4 updatedevicesandoutputs (); a device is selected for each policy and saved to mdeviceforstrategy.
------> Mdeviceforstrategy [I] = getdeviceforstrategy (routing_strategy) I, false/* fromcache */);
2.2.1.5 getnewdevice (moutputs. keyat (I), true/* fromcache */) Select a policy based on the policy priority level.
-----> Audiopolicymanager: getdeviceforstrategy () according to the policy, select the device
2.2.1.5 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