hal: gef: update gef extn to deinit gef library on hal deinit

Update gef extension to call deinit of gef library if the call is
available, so that gef is aware of audio hal state and gef init/deinit
is not tightly coupled with hal init/deinit.

Change-Id: I72ced9d6b9535563ee0b8e6d81efd634fcdc3ee3
This commit is contained in:
Dhananjay Kumar 2017-07-10 13:49:13 +05:30 committed by Shiv Maliyappanahalli
parent ac66803f66
commit a427f14cf2
1 changed files with 16 additions and 0 deletions

View File

@ -62,6 +62,7 @@
#endif #endif
typedef void* (*gef_init_t)(void*); typedef void* (*gef_init_t)(void*);
typedef void (*gef_deinit_t)(void*);
typedef void (*gef_device_config_cb_t)(void*, audio_devices_t, typedef void (*gef_device_config_cb_t)(void*, audio_devices_t,
audio_channel_mask_t, int, int); audio_channel_mask_t, int, int);
@ -69,6 +70,7 @@ typedef struct {
void* handle; void* handle;
void* gef_ptr; void* gef_ptr;
gef_init_t init; gef_init_t init;
gef_deinit_t deinit;
gef_device_config_cb_t device_config_cb; gef_device_config_cb_t device_config_cb;
} gef_data; } gef_data;
@ -137,6 +139,18 @@ void audio_extn_gef_init(struct audio_device *adev)
goto ERROR_RETURN; goto ERROR_RETURN;
} }
//call dlerror to clear the error
dlerror();
gef_hal_handle.deinit =
(gef_deinit_t)dlsym(gef_hal_handle.handle, "gef_deinit");
error = dlerror();
if(error != NULL) {
ALOGE("%s: dlsym of %s failed with error %s",
__func__, "gef_deinit", error);
goto ERROR_RETURN;
}
//call dlerror to clear the error //call dlerror to clear the error
error = dlerror(); error = dlerror();
gef_hal_handle.device_config_cb = gef_hal_handle.device_config_cb =
@ -289,6 +303,8 @@ void audio_extn_gef_deinit()
ALOGV("%s: Enter", __func__); ALOGV("%s: Enter", __func__);
if (gef_hal_handle.handle) { if (gef_hal_handle.handle) {
if (gef_hal_handle.handle && gef_hal_handle.deinit)
gef_hal_handle.deinit(gef_hal_handle.gef_ptr);
dlclose(gef_hal_handle.handle); dlclose(gef_hal_handle.handle);
} }