summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-21 17:07:36 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-28 15:38:58 +0100
commit756f8d02b445631df44243d528165fb1fe414487 (patch)
tree1ef835068d6cf24f33eeb0a0a136865a23a1884e /4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
parent524ad81cd52d52555d0e6cbaf865f6bb6cfecb25 (diff)
Move from controller functions to afb functions
Move from controller 'afb-definitions.h' functions to application framework 'afb/afb-binding.h' functions. Change-Id: I4cd62af881ef8ac949b082ede9dfcc4736d1e12c Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c42
1 files changed, 20 insertions, 22 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 0691cb5..4a1ca8f 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
@@ -23,7 +23,7 @@
#include <filescan-utils.h>
#include <wrap-json.h>
-#include <afb-definitions.h>
+#include <afb/afb-binding.h>
#include <ctl-config.h>
@@ -35,7 +35,7 @@
#include "4a-hal-controllers-mixer-link.h"
// Default api to print log when apihandle not available
-AFB_ApiT AFB_default;
+afb_api_t AFB_default;
/*******************************************************************************
* Json parsing functions using app controller *
@@ -58,7 +58,7 @@ static CtlSectionT ctrlSectionsDefault[] =
******************************************************************************/
// Every HAL export the same API & Interface Mapping from SndCard to AudioLogic is done through alsaHalSndCardT
-static AFB_ApiVerbs CtlHalApiStaticVerbs[] =
+static afb_verb_t CtlHalApiStaticVerbs[] =
{
/* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
{ .verb = "info", .callback = HalCtlsInfo, .info = "List available streams/playbacks/captures/controls for this api" },
@@ -71,7 +71,7 @@ static AFB_ApiVerbs CtlHalApiStaticVerbs[] =
* Dynamic API functions for app controller *
******************************************************************************/
-static int HalCtlsInitOneApi(AFB_ApiT apiHandle)
+static int HalCtlsInitOneApi(afb_api_t apiHandle)
{
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentCtlHalData;
@@ -83,8 +83,7 @@ static int HalCtlsInitOneApi(AFB_ApiT apiHandle)
AFB_default = apiHandle;
// Retrieve section config from api handle
- ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle);
- if(! ctrlConfig)
+ if(! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle)))
return -2;
currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig);
@@ -106,8 +105,7 @@ static int HalCtlsInitOneApi(AFB_ApiT apiHandle)
currentCtlHalData->sndCardId = HalCtlsGetCardIdByCardPath(apiHandle, currentCtlHalData->sndCardPath);
- currentCtlHalData->ctlHalSpecificData->streamUpdates = AFB_EventMake(apiHandle, HAL_STREAM_UPDATES_EVENT_NAME);
- if(! AFB_EventIsValid(currentCtlHalData->ctlHalSpecificData->streamUpdates))
+ if(! (currentCtlHalData->ctlHalSpecificData->streamUpdates = afb_api_make_event(apiHandle, HAL_STREAM_UPDATES_EVENT_NAME)))
return -4;
if(currentCtlHalData->sndCardId < 0)
@@ -120,7 +118,7 @@ static int HalCtlsInitOneApi(AFB_ApiT apiHandle)
return CtlConfigExec(apiHandle, ctrlConfig);
}
-static int HalCtlsLoadOneApi(void *cbdata, AFB_ApiT apiHandle)
+static int HalCtlsLoadOneApi(void *cbdata, afb_api_t apiHandle)
{
int err;
CtlConfigT *ctrlConfig;
@@ -132,11 +130,11 @@ static int HalCtlsLoadOneApi(void *cbdata, AFB_ApiT apiHandle)
ctrlConfig = (CtlConfigT*) cbdata;
// Save closure as api's data context
- AFB_ApiSetUserData(apiHandle, ctrlConfig);
+ afb_api_set_userdata(apiHandle, ctrlConfig);
// Add static controls verbs
if(HalUtlLoadVerbs(apiHandle, CtlHalApiStaticVerbs)) {
- AFB_ApiError(apiHandle, "Load Section : fail to register static V2 verbs");
+ AFB_API_ERROR(apiHandle, "Load Section : fail to register static V2 verbs");
return 1;
}
@@ -148,15 +146,15 @@ static int HalCtlsLoadOneApi(void *cbdata, AFB_ApiT apiHandle)
return err;
// Declare an event manager for this Api
- AFB_ApiOnEvent(apiHandle, HalCtlsDispatchApiEvent);
+ afb_api_on_event(apiHandle, HalCtlsDispatchApiEvent);
// Init Api function (does not receive user closure ???)
- AFB_ApiOnInit(apiHandle, HalCtlsInitOneApi);
+ afb_api_on_init(apiHandle, HalCtlsInitOneApi);
return 0;
}
-int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGlobalData)
+int HalCtlsCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *HalMgrGlobalData)
{
CtlConfigT *ctrlConfig;
struct SpecificHalData *currentCtlHalData;
@@ -167,12 +165,12 @@ int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGl
// Create one Api per file
ctrlConfig = CtlLoadMetaData(apiHandle, path);
if(! ctrlConfig) {
- AFB_ApiError(apiHandle, "No valid control config file in:\n-- %s", path);
+ AFB_API_ERROR(apiHandle, "No valid control config file in:\n-- %s", path);
return -2;
}
if(! ctrlConfig->api) {
- AFB_ApiError(apiHandle, "API Missing from metadata in:\n-- %s", path);
+ AFB_API_ERROR(apiHandle, "API Missing from metadata in:\n-- %s", path);
return -3;
}
@@ -189,14 +187,14 @@ int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGl
// Allocation of the structure that will be used to store specific hal controller data
currentCtlHalData->ctlHalSpecificData = calloc(1, sizeof(struct CtlHalSpecificData));
- // Create one API (Pre-V3 return code ToBeChanged)
- if(! AFB_NewApi(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, HalCtlsLoadOneApi, ctrlConfig))
+ // Create one API
+ if(! afb_api_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, HalCtlsLoadOneApi, ctrlConfig))
return -5;
return 0;
}
-int HalCtlsCreateAllApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
+int HalCtlsCreateAllApi(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData)
{
int index, status = 0;
char *dirList, *fileName, *fullPath;
@@ -212,7 +210,7 @@ int HalCtlsCreateAllApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
// Hugely hack to make all V2 AFB_DEBUG to work in fileutils
AFB_default = apiHandle;
- AFB_ApiNotice(apiHandle, "Begining to create all APIs");
+ AFB_API_NOTICE(apiHandle, "Begining to create all APIs");
dirList = getenv("CONTROL_CONFIG_PATH");
if(! dirList)
@@ -220,7 +218,7 @@ int HalCtlsCreateAllApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
configJ = CtlConfigScan(dirList, "hal");
if(! configJ) {
- AFB_ApiWarning(apiHandle, "No hal-(binder-middle-name)*.json config file(s) found in %s, 4a-hal-manager will only works with external hal", dirList);
+ AFB_API_WARNING(apiHandle, "No hal-(binder-middle-name)*.json config file(s) found in %s, 4a-hal-manager will only works with external hal", dirList);
return 0;
}
@@ -229,7 +227,7 @@ int HalCtlsCreateAllApi(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData)
entryJ = json_object_array_get_idx(configJ, index);
if(wrap_json_unpack(entryJ, "{s:s, s:s !}", "fullpath", &fullPath, "filename", &fileName)) {
- AFB_ApiError(apiHandle, "HOOPs invalid JSON entry = %s", json_object_get_string(entryJ));
+ AFB_API_ERROR(apiHandle, "HOOPs invalid JSON entry = %s", json_object_get_string(entryJ));
return -2;
}