summaryrefslogtreecommitdiffstats
path: root/plugins/lib/bluealsa/hal-bluealsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/lib/bluealsa/hal-bluealsa.c')
-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;
}