h->intf.add_message_cb = dlsym(h->dl_handle, "audio_add_message_cb");
h->intf.remove_message_cb = dlsym(h->dl_handle, "audio_remove_message_cb");
if (h->intf.init) {
- if (h->intf.init(&h->ah_handle) != AUDIO_RET_OK)
+ if (h->intf.init(&h->ah_handle) != AUDIO_RET_OK) {
pa_log_error("hal_interface init failed");
+ dlclose(h->dl_handle);
+ pa_xfree(h);
+ return NULL;
+ }
}
} else {
pa_log_error("hal_interface deinit failed");
}
}
- if (h->dl_handle) {
+ if (h->dl_handle)
dlclose(h->dl_handle);
- }
if (h->core)
pa_shared_remove(h->core, SHARED_HAL_INTF);
pa_assert(u);
+ if (!u->device_manager) {
+ pa_log_error("device_manager is null");
+ return -1;
+ }
+
bt_device = _get_sco_connected_device(u->device_manager);
if (bt_device == NULL) {
pa_log_debug("No SCO connected bt device");
u->core = m->core;
u->module = m;
- u->hal_interface = pa_hal_interface_get(u->core);
+ if (!(u->hal_interface = pa_hal_interface_get(u->core))) {
+ pa_log("Failed to get hal interface");
+ pa_modargs_free(ma);
+ goto fail;
+ }
if ((u->communicator.comm = pa_communicator_get(u->core))) {
u->communicator.comm_hook_select_proper_sink_or_source_slot = pa_hook_connect(
if (!(u = m->userdata))
return;
- pa_module_unload(u->core, u->module_null_sink, true);
- u->module_null_sink = NULL;
- pa_module_unload(u->core, u->module_null_source, true);
- u->module_null_source = NULL;
+ bt_sco_close(u, false);
+
+ if (u->module_null_sink)
+ pa_module_unload(u->core, u->module_null_sink, true);
+
+ if (u->module_null_source)
+ pa_module_unload(u->core, u->module_null_source, true);
if (u->device_manager)
pa_device_manager_unref(u->device_manager);
if (u->hal_interface)
pa_hal_interface_unref(u->hal_interface);
- bt_sco_close(u, false);
-
pa_xfree(u);
pa_log_info("Tizen Audio Policy module is unloaded\n");
m = pa_xnew0(pa_stream_manager, 1);
m->core = c;
- m->hal = pa_hal_interface_get(c);
+ if (!(m->hal = pa_hal_interface_get(c)))
+ goto fail;
+
if (pa_hal_interface_add_message_callback(m->hal, message_cb, m))
pa_log_warn("skip adding message callback");
m->dm = pa_device_manager_get(c);