Currently, the following device interfaces are supported in Android4.2 (defined in AudioFlinger. cpp ):
* audio_interfaces[] = AUDIO_HARDWARE_MODULE_ID_PRIMARY, AUDIO_HARDWARE_MODULE_ID_A2DP, AUDIO_HARDWARE_MODULE_ID_USB, };
Constants in the array are also defined in/hardware/libhardware/include/audio. h:
AUDIO_HARDWARE_MODULE_ID_PRIMARY "primary" AUDIO_HARDWARE_MODULE_ID_A2DP "a2dp" AUDIO_HARDWARE_MODULE_ID_USB "usb"
During initialization, AudioFlinger does not take the initiative to load the audio module. It provides a loadHwModule (const char * name) interface to call AudioPolicyService. name is one of the supported devices. The following primary device is used as an example:
int hw_get_module_by_class( *class_id, * hw_module_t ** hw_module_t *hmi = (i= ; i<HAL_VARIANT_KEYS_COUNT+ ; i++ (i < (property_get(variant_keys[i], prop, NULL) == (path), (access(path, R_OK) == ) (path), (access(path, R_OK) == ) (path), (access(path, R_OK) == ) = - (i < HAL_VARIANT_KEYS_COUNT+=
The inst parameter is "primary", and class_id is AUDIO_HARDWARE_MODULE_ID, which is defined in audio. h:
AUDIO_HARDWARE_MODULE_ID "audio"
This method traverses the variant_keys array:
*variant_keys[] =,
In system property, extract the key values and splice the passed primary in order to check whether the *. so file exists.
For example, for our company's platform, the first two properties in the array are null, and ro. board. if platform is "mrvl", the so file name is audio. primary. mrvl. so.
Search in two different directories:
HAL_LIBRARY_PATH1 "/system/lib/hw" HAL_LIBRARY_PATH2 "/vendor/lib/hw"
4. Call the load function to open this *. so.