summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bultel <thierry.bultel@iot.bzh>2019-02-18 15:56:02 +0100
committerThierry Bultel <thierry.bultel@iot.bzh>2019-05-13 14:16:48 +0200
commit43efc33ea2c06664f96b56a32735a42900ba238b (patch)
tree47658330508f66ab39a435af14c988dc1fdf52d1
parentdb4eeea4a25740595e4760c2e55f37c625344046 (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>
-rw-r--r--plugins/lib/bluealsa/hal-bluealsa.c28
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;
}