diff options
author | 2019-02-18 15:56:02 +0100 | |
---|---|---|
committer | 2019-02-18 15:56:02 +0100 | |
commit | 487b3e3924060f3d8cdacd6d50e62f8d0e385bea (patch) | |
tree | 7ae7b420ecd0914fbe1b6305500474fac36e377f /plugins/lib/bluealsa/hal-bluealsa.c | |
parent | 6c55f920604baa08927740b1595c2d3d021c24e4 (diff) |
bluealsa plugin: do not do anything when the HAL is not ready
Change-Id: Ifad933c3c5f574aad437a59708c01c6d674dc914
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
Diffstat (limited to 'plugins/lib/bluealsa/hal-bluealsa.c')
-rw-r--r-- | plugins/lib/bluealsa/hal-bluealsa.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/plugins/lib/bluealsa/hal-bluealsa.c b/plugins/lib/bluealsa/hal-bluealsa.c index 05a1540..415b160 100644 --- a/plugins/lib/bluealsa/hal-bluealsa.c +++ b/plugins/lib/bluealsa/hal-bluealsa.c @@ -29,6 +29,7 @@ #include <urcu/list.h> #include "hal-bluealsa.h" +#include "4a-hal-utilities-data.h" #define HAL_BLUEALSA_PLUGIN_NAME "hal-bluealsa" @@ -67,17 +68,29 @@ CTLP_INIT(plugin, callbacks) { json_object *actionsToAdd = NULL; CtlConfigT *ctrlConfig; - - wrap_json_pack(&actionsToAdd, "{s:s s:s s:s}", - "uid", "init-bluealsa-plugin", - "info", "Init Bluez-Alsa hal plugin", - "action", "plugin://hal-bluealsa#init"); + struct SpecificHalData *currentHalData; if (!(ctrlConfig = (CtlConfigT *) afb_api_get_userdata(plugin->api))) { AFB_API_ERROR(plugin->api, "Can't get current hal controller config"); goto fail; } + if (!(currentHalData = (struct SpecificHalData *) ctrlConfig->external)) { + AFB_API_ERROR(plugin->api, "Can't get current hal controller data"); + goto fail; + } + + if (currentHalData->status != HAL_STATUS_AVAILABLE) { + AFB_API_WARNING(plugin->api, + "Controller initialization of %s plugin cannot be done because hal is not ready to be used", HAL_BLUEALSA_PLUGIN_NAME); + goto done; + } + + wrap_json_pack(&actionsToAdd, "{s:s s:s s:s}", + "uid", "init-bluealsa-plugin", + "info", "Init Bluez-Alsa hal plugin", + "action", "plugin://hal-bluealsa#init"); + int idx = 0; while (ctrlConfig->sections[idx].key && strcasecmp(ctrlConfig->sections[idx].key, "onload")) idx++; @@ -93,10 +106,11 @@ CTLP_INIT(plugin, callbacks) } AFB_API_NOTICE(plugin->api, "Plugin initialization of %s plugin correctly done", HAL_BLUEALSA_PLUGIN_NAME); - +done: return 0; fail: - json_object_put(actionsToAdd); + if (actionsToAdd) + json_object_put(actionsToAdd); return -1; } |