shared libraries - Android: Is there just once instance of a HAL module? -


i confused lifetime , usage of hal modules. traditionally, hal module implemented set of hooks various functions , compiled shared library. suppose have 2 applications link libhardware , both call hw_get_module() somewhere in code.

struct my_audio_stream {     struct audio_stream base;      /* base hal */     int count; }  struct audio_module hal_module_info_sym = {     .base =          .common = {            .tag = hardware_module_tag,            .module_api_version = audio_module_api_version_0_1,            .hal_api_version = hardware_hal_api_version,            .id = audio_hardware_module_id,            .name = "usb audio hw hal",            .author = "the android open source project",            .methods = &hal_module_methods,         }, } 

if increment count variable in 1 application, visible other application? i.e, there 1 global instance of my_audio_stream module?

hw_get_module() calls dlopen()

dlopen() load library specific process called it. although .text (executable code) shared between processes shared object, storages required .so (e.g. global/static objects) allocated per process

so if 2 processes call hw_get_module() globals declared in .so not shared between these processes.

it follows count incremented in 1 process not seen other process.

having said that, android load 1 instance of hal module, , use forever internally. (there 1 instance of audio server)

if need access internals of hal app/process, should implement kind of ipc in hal.


Comments