aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-18 16:02:13 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:53:53 +0200
commitddf7309d11eb277dd81e519290211293df737bc9 (patch)
tree47fdea9cd5e7de1e8ec10924cc27508fcbe2043a
parent2a283187230646b2537c1fee1f6dbe1239174d7c (diff)
Delay event parsing to be the last
Delay event parsing to be the last. This is to avoid receiving events before everything is parsed. Do some minor layout changes. Change-Id: I0fd3f8d387c27471657c58ca8c4ea5828c002e23 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
index 0ea3e12..b7f2a78 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
@@ -45,13 +45,13 @@ AFB_ApiT AFB_default;
// Config Section definition
static CtlSectionT ctrlSections[] =
{
- {.key="resources", .loadCB= PluginConfig},
- {.key="onload", .loadCB= OnloadConfig},
- {.key="controls", .loadCB= ControlConfig},
- {.key="events", .loadCB= EventConfig},
- {.key="halmap", .loadCB= HalCtlsHalMapConfig},
- {.key="halmixer", .loadCB= HalCtlsHalMixerConfig},
- {.key=NULL}
+ { .key = "resources", .loadCB = PluginConfig },
+ { .key = "onload", .loadCB = OnloadConfig },
+ { .key = "controls", .loadCB = ControlConfig },
+ { .key = "halmixer", .loadCB = HalCtlsHalMixerConfig },
+ { .key = "halmap", .loadCB = HalCtlsHalMapConfig },
+ { .key = "events", .loadCB = EventConfig },
+ { .key = NULL }
};
/*******************************************************************************
@@ -62,7 +62,7 @@ static CtlSectionT ctrlSections[] =
static AFB_ApiVerbs CtlHalDynApiStaticVerbs[] =
{
/* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
- { .verb = "info", .callback = HalCtlsInfo, .info = "List available streams/playbacks/... for this api"},
+ { .verb = "info", .callback = HalCtlsInfo, .info = "List available streams/playbacks/captures... for this api" },
{ .verb = NULL } // Marker for end of the array
};
@@ -111,8 +111,9 @@ static int HalCtlsInitOneApi(AFB_ApiT apiHandle)
currentCtlHalData->sndCardId = HalCtlsGetCardIdByCardPath(apiHandle, currentCtlHalData->sndCardPath);
- if(currentCtlHalData->sndCardId < 0)
+ if(currentCtlHalData->sndCardId < 0) {
currentCtlHalData->status = HAL_STATUS_UNAVAILABLE;
+ }
else {
currentCtlHalData->status = HAL_STATUS_AVAILABLE;
if((err = HalCtlsAttachToMixer(apiHandle))) {
@@ -131,7 +132,7 @@ static int HalCtlsLoadOneApi(void *cbdata, AFB_ApiT apiHandle)
int err;
CtlConfigT *ctrlConfig;
- if(! cbdata || ! apiHandle )
+ if(! cbdata || ! apiHandle)
return -1;
ctrlConfig = (CtlConfigT*) cbdata;
@@ -146,7 +147,8 @@ static int HalCtlsLoadOneApi(void *cbdata, AFB_ApiT apiHandle)
}
// Load section for corresponding Api
- err = CtlLoadSections(apiHandle, ctrlConfig, ctrlSections);
+ if((err = CtlLoadSections(apiHandle, ctrlConfig, ctrlSections)))
+ return err;
// Declare an event manager for this Api
afb_dynapi_on_event(apiHandle, HalCtlsDispatchApiEvent);
@@ -154,7 +156,7 @@ static int HalCtlsLoadOneApi(void *cbdata, AFB_ApiT apiHandle)
// Init Api function (does not receive user closure ???)
afb_dynapi_on_init(apiHandle, HalCtlsInitOneApi);
- return err;
+ return 0;
}
int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGlobalData)
@@ -189,7 +191,10 @@ int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGl
currentCtlHalData->ctlHalSpecificData = calloc(1, sizeof(struct CtlHalSpecificData));
// Create one API (Pre-V3 return code ToBeChanged)
- return afb_dynapi_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, HalCtlsLoadOneApi, ctrlConfig);
+ if(afb_dynapi_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, HalCtlsLoadOneApi, ctrlConfig))
+ return -5;
+
+ return 0;
}
int HalCtlsCreateAllApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)