diff options
Diffstat (limited to 'plugins/lib')
-rw-r--r-- | plugins/lib/bluetooth/hal-bt.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/plugins/lib/bluetooth/hal-bt.c b/plugins/lib/bluetooth/hal-bt.c index 1fb4180..a4791e1 100644 --- a/plugins/lib/bluetooth/hal-bt.c +++ b/plugins/lib/bluetooth/hal-bt.c @@ -38,12 +38,6 @@ CTLP_CAPI_REGISTER(HAL_BT_PLUGIN_NAME) // Call at initialisation time CTLP_ONLOAD(plugin, callbacks) { - AFB_ApiInfo(plugin->api, "%s Plugin Registering: uid='%s' 'info='%s'", HAL_BT_PLUGIN_NAME, plugin->uid, plugin->info); - - memset(&localHalBtPluginData, '\0', sizeof(localHalBtPluginData)); - - localHalBtPluginData.currentHalApiHandle = plugin->api; - AFB_ApiNotice(plugin->api, "%s Plugin Registered correctly: uid='%s' 'info='%s'", HAL_BT_PLUGIN_NAME, plugin->uid, plugin->info); return 0; @@ -59,6 +53,8 @@ CTLP_INIT(plugin, callbacks) CtlConfigT *ctrlConfig; + struct SpecificHalData *currentHalData; + json_object *actionsToAdd, *returnedJ, *halMixerJ, *halOrigCaptureJ, *halNewCaptureJ, *halOrigStreamJ, *halNewStreamJ, *btCaptureJ, *btCaptureParamsJ, *btStreamJ; AFB_ApiInfo(plugin->api, "Plugin initialization of %s plugin", HAL_BT_PLUGIN_NAME); @@ -73,13 +69,13 @@ CTLP_INIT(plugin, callbacks) return -1; } - if(! (localHalBtPluginData.currentHalData = (struct SpecificHalData *) ctrlConfig->external)) { + if(! (currentHalData = (struct SpecificHalData *) ctrlConfig->external)) { AFB_ApiError(plugin->api, "Can't get current hal controller data"); return -2; } - if((! localHalBtPluginData.currentHalData->ctlHalSpecificData) || - (! (halMixerJ = localHalBtPluginData.currentHalData->ctlHalSpecificData->halMixerJ))) { + if((! currentHalData->ctlHalSpecificData) || + (! (halMixerJ = currentHalData->ctlHalSpecificData->halMixerJ))) { AFB_ApiError(plugin->api, "Can't get current hal mixer json section"); return -3; } @@ -113,6 +109,17 @@ CTLP_INIT(plugin, callbacks) "uid", "Bluetooth-Manager/device_updated", "action", "plugin://hal-bt#events"); + if(currentHalData->status != HAL_STATUS_AVAILABLE) { + AFB_ApiWarning(plugin->api, "Controller initialization of %s plugin cannot be done because hal is not ready to be used", HAL_BT_PLUGIN_NAME); + return 0; + } + + memset(&localHalBtPluginData, '\0', sizeof(localHalBtPluginData)); + + localHalBtPluginData.currentHalApiHandle = plugin->api; + + localHalBtPluginData.currentHalData = currentHalData; + idx = 0; while(ctrlConfig->sections[idx].key && strcasecmp(ctrlConfig->sections[idx].key, "events")) idx++; |