summaryrefslogtreecommitdiffstats
path: root/4a-hal
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-07 11:30:12 +0100
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-01-28 15:38:28 +0100
commit4f44ee8f17789ac27cd1e29a451ac450c7dbeb06 (patch)
treee27e4c05a417ef2d8a9ca12451af0f8e298cc1cb /4a-hal
parenta93c3566d181e82a39b32acffdb13a411ca4f5f5 (diff)
Turn '4a-hal-utilities' into an internal library
That way, includes will be cleaner and '4a-hal-utilities' functions will be usable in plugin. Change-Id: I8a2146bd4e5dd5ef449b9ba7f2b1eed4d59045d3 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c34
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h45
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c2
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h2
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c6
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c8
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h2
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c2
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.c2
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-events.c3
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager.c5
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c147
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h45
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-data.c244
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-data.h108
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c50
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h28
-rw-r--r--4a-hal/CMakeLists.txt4
18 files changed, 28 insertions, 709 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
index 4ae5a13..f1f99a6 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c
@@ -24,10 +24,13 @@
#include <alsa/asoundlib.h>
+#include <afb-definitions.h>
+
#include <ctl-config.h>
-#include "../4a-hal-utilities/4a-hal-utilities-data.h"
-#include "../4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h"
+#include "4a-hal-utilities-alsa-data.h"
+#include "4a-hal-utilities-data.h"
+#include "4a-hal-utilities-appfw-responses-handler.h"
#include "4a-hal-controllers-alsacore-link.h"
#include "4a-hal-controllers-value-handler.h"
@@ -64,33 +67,6 @@ snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label)
}
/*******************************************************************************
- * Free contents of 'CtlHalAlsaMapT' data structure *
- ******************************************************************************/
-
-uint8_t HalCtlsFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap)
-{
- int idx;
-
- if(! alsaCtlsMap)
- return -1;
-
- if(alsaCtlsMap->ctlsCount > 0 && ! alsaCtlsMap->ctls)
- return -2;
-
- for(idx = 0; idx < alsaCtlsMap->ctlsCount; idx++) {
- free(alsaCtlsMap->ctls[idx].action);
- free(alsaCtlsMap->ctls[idx].ctl.alsaCtlProperties.enums);
- free(alsaCtlsMap->ctls[idx].ctl.alsaCtlProperties.dbscale);
- }
-
- free(alsaCtlsMap->ctls);
-
- free(alsaCtlsMap);
-
- return 0;
-}
-
-/*******************************************************************************
* HAL controllers alsacore calls funtions *
******************************************************************************/
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h
index 5d687aa..351ad59 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h
@@ -26,6 +26,8 @@
#include <ctl-config.h>
+#include "4a-hal-utilities-alsa-data.h"
+
#define ALSACORE_API "alsacore"
#define ALSACORE_SUBSCRIBE_VERB "subscribe"
#define ALSACORE_GETINFO_VERB "infoget"
@@ -33,52 +35,9 @@
#define ALSACORE_CTLSET_VERB "ctlset"
#define ALSACORE_ADDCTL_VERB "addcustomctl"
-struct CtlHalAlsaDBScale {
- int min;
- int max;
- int step;
- int mute;
-};
-
-struct CtlHalAlsaCtlProperties {
- snd_ctl_elem_type_t type;
- int count;
- int minval;
- int maxval;
- int step;
- // TBD JAI : use them
- const char **enums;
- struct CtlHalAlsaDBScale *dbscale;
-};
-
-struct CtlHalAlsaCtl {
- char *name;
- int numid;
- int value;
- struct CtlHalAlsaCtlProperties alsaCtlProperties;
- struct CtlHalAlsaCtlProperties *alsaCtlCreation;
-};
-
-struct CtlHalAlsaMap {
- const char *uid;
- char *info;
- AFB_EventT alsaControlEvent;
- struct CtlHalAlsaCtl ctl;
- json_object *actionJ;
- CtlActionT *action;
-};
-
-struct CtlHalAlsaMapT {
- struct CtlHalAlsaMap *ctls;
- unsigned int ctlsCount;
-};
-
// Alsa control types map from string function
snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label);
-// Free contents of 'CtlHalAlsaMapT' data structure
-uint8_t HalCtlsFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap);
-
// HAL controllers alsacore calls funtions
int HalCtlsGetCardIdByCardPath(AFB_ApiT apiHandle, char *devPath);
int HalCtlsSubscribeToAlsaCardEvent(AFB_ApiT apiHandle, char *cardId);
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 4cac346..72515e7 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
@@ -27,7 +27,7 @@
#include <ctl-config.h>
-#include "../4a-hal-utilities/4a-hal-utilities-verbs-loader.h"
+#include "4a-hal-utilities-verbs-loader.h"
#include "4a-hal-controllers-api-loader.h"
#include "4a-hal-controllers-alsacore-link.h"
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h
index 70e61cd..f1d3bfd 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h
@@ -22,7 +22,7 @@
#include <afb-definitions.h>
-#include "../4a-hal-utilities/4a-hal-utilities-data.h"
+#include "4a-hal-utilities-data.h"
// Verbs that can be use to create api
int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGlobalData);
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
index a8d0ee4..ba2454a 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
@@ -22,8 +22,10 @@
#include <wrap-json.h>
-#include "../4a-hal-utilities/4a-hal-utilities-data.h"
-#include "../4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h"
+#include <afb-definitions.h>
+
+#include "4a-hal-utilities-data.h"
+#include "4a-hal-utilities-appfw-responses-handler.h"
#include "4a-hal-controllers-cb.h"
#include "4a-hal-controllers-alsacore-link.h"
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
index 807dbb8..fd42899 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c
@@ -22,9 +22,11 @@
#include <wrap-json.h>
-#include "../4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h"
-#include "../4a-hal-utilities/4a-hal-utilities-data.h"
-#include "../4a-hal-utilities/4a-hal-utilities-verbs-loader.h"
+#include <afb-definitions.h>
+
+#include "4a-hal-utilities-appfw-responses-handler.h"
+#include "4a-hal-utilities-data.h"
+#include "4a-hal-utilities-verbs-loader.h"
#include "../4a-hal-manager/4a-hal-manager.h"
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h
index 165b70d..9189664 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h
@@ -24,7 +24,7 @@
#include "afb-helpers-utils.h"
-#include "../4a-hal-utilities/4a-hal-utilities-data.h"
+#include "4a-hal-utilities-data.h"
#define MIXER_ATTACH_VERB "attach"
#define MIXER_INFO_VERB "info"
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c
index 7a3dedd..4273def 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c
@@ -25,6 +25,8 @@
#include <wrap-json.h>
+#include <afb-definitions.h>
+
#include "4a-hal-controllers-value-handler.h"
#include "4a-hal-controllers-alsacore-link.h"
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
index ae86474..ba01394 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
@@ -22,7 +22,7 @@
#include <wrap-json.h>
-#include "../4a-hal-utilities/4a-hal-utilities-data.h"
+#include "4a-hal-utilities-data.h"
#include "4a-hal-manager-cb.h"
#include "4a-hal-manager-events.h"
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-events.c b/4a-hal/4a-hal-manager/4a-hal-manager-events.c
index 96299a0..2b58501 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-events.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-events.c
@@ -22,7 +22,8 @@
#include <wrap-json.h>
-#include "../4a-hal-utilities/4a-hal-utilities-data.h"
+#include "4a-hal-utilities-data.h"
+
#include "4a-hal-manager-events.h"
// TBD JAI: implement events handlers functions \ No newline at end of file
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager.c b/4a-hal/4a-hal-manager/4a-hal-manager.c
index 43fbd49..c510d17 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager.c
@@ -22,8 +22,9 @@
#include <afb-definitions.h>
-#include "../4a-hal-utilities/4a-hal-utilities-data.h"
-#include "../4a-hal-utilities/4a-hal-utilities-verbs-loader.h"
+#include "4a-hal-utilities-data.h"
+#include "4a-hal-utilities-verbs-loader.h"
+
#include "../4a-hal-controllers/4a-hal-controllers-api-loader.h"
#include "4a-hal-manager.h"
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c b/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c
deleted file mode 100644
index 40581ef..0000000
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2018 "IoT.bzh"
- * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <string.h>
-
-#include "4a-hal-utilities-appfw-responses-handler.h"
-
-/*******************************************************************************
- * Handle application framework response function *
- ******************************************************************************/
-
-enum CallError HalUtlHandleAppFwCallError(AFB_ApiT apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo)
-{
- json_object *returnedRequestJ, *returnedStatusJ, *returnedInfoJ;
-
- if(! apiHandle || ! apiCalled || ! verbCalled || ! callReturnJ)
- return CALL_ERROR_INVALID_ARGS;
-
- if(! json_object_object_get_ex(callReturnJ, "request", &returnedRequestJ)) {
- AFB_ApiWarning(apiHandle, "Couldn't get response request object");
- return CALL_ERROR_REQUEST_UNAVAILABLE;
- }
-
- if(! json_object_is_type(returnedRequestJ, json_type_object)) {
- AFB_ApiWarning(apiHandle, "Response request object is not valid");
- return CALL_ERROR_REQUEST_NOT_VALID;
- }
-
- if(! json_object_object_get_ex(returnedRequestJ, "status", &returnedStatusJ)) {
- AFB_ApiWarning(apiHandle, "Couldn't get response status object");
- return CALL_ERROR_REQUEST_STATUS_UNAVAILABLE;
- }
-
- if(! json_object_is_type(returnedStatusJ, json_type_string)) {
- AFB_ApiWarning(apiHandle, "Response status object is not valid");
- return CALL_ERROR_REQUEST_STATUS_NOT_VALID;
- }
-
- *returnedStatus = (char *) json_object_get_string(returnedStatusJ);
-
- if(! strcmp(*returnedStatus, "unknown-api")) {
- AFB_ApiWarning(apiHandle, "Api %s not found", apiCalled);
- return CALL_ERROR_API_UNAVAILABLE;
- }
-
- if(! strcmp(*returnedStatus, "unknown-verb")) {
- AFB_ApiWarning(apiHandle, "Verb %s of api %s not found", verbCalled, apiCalled);
- return CALL_ERROR_VERB_UNAVAILABLE;
- }
-
- if(! json_object_object_get_ex(returnedRequestJ, "info", &returnedInfoJ)) {
- AFB_ApiWarning(apiHandle, "Couldn't get response info object");
- return CALL_ERROR_REQUEST_INFO_UNAVAILABLE;
- }
-
- if(! json_object_is_type(returnedInfoJ, json_type_string)) {
- AFB_ApiWarning(apiHandle, "Response info object is not valid");
- return CALL_ERROR_REQUEST_INFO_NOT_VALID;
- }
-
- *returnedInfo = (char *) json_object_get_string(returnedInfoJ);
-
- AFB_ApiWarning(apiHandle,
- "Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
- apiCalled,
- verbCalled,
- *returnedStatus,
- *returnedInfo);
-
- return CALL_ERROR_RETURNED;
-}
-
-void HalUtlHandleAppFwCallErrorInRequest(AFB_ReqT request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend)
-{
- char *returnedStatus = NULL, *returnedInfo = NULL;
-
- AFB_ApiT apiHandle;
-
- if(! request || ! apiCalled || ! verbCalled || ! callReturnJ) {
- AFB_ReqFailF(request, "invalid_args", "Invalid arguments");
- return;
- }
-
- apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
- if(! apiHandle) {
- AFB_ReqFailF(request, "api_handle", "Can't get hal manager api handle");
- return;
- }
-
- switch(HalUtlHandleAppFwCallError(apiHandle, apiCalled, verbCalled, callReturnJ, &returnedStatus, &returnedInfo)) {
- case CALL_ERROR_REQUEST_UNAVAILABLE:
- case CALL_ERROR_REQUEST_NOT_VALID:
- case CALL_ERROR_REQUEST_STATUS_UNAVAILABLE:
- case CALL_ERROR_REQUEST_STATUS_NOT_VALID:
- case CALL_ERROR_REQUEST_INFO_UNAVAILABLE:
- case CALL_ERROR_REQUEST_INFO_NOT_VALID:
- AFB_ReqFail(request, errorStatusToSend, "Error with response object");
- return;
-
- case CALL_ERROR_API_UNAVAILABLE:
- AFB_ReqFailF(request, errorStatusToSend, "Api %s not found", apiCalled);
- return;
-
- case CALL_ERROR_VERB_UNAVAILABLE:
- AFB_ReqFailF(request, errorStatusToSend, "Verb %s of api %s not found", verbCalled, apiCalled);
- return;
-
- case CALL_ERROR_RETURNED:
- AFB_ReqFailF(request,
- errorStatusToSend,
- "Api %s and verb %s found, but this error was raised : '%s' with this info : '%s'",
- apiCalled,
- verbCalled,
- returnedStatus ? returnedStatus : "not returned",
- returnedInfo ? returnedInfo : "not returned");
- return;
-
- case CALL_ERROR_INVALID_ARGS:
- AFB_ReqFailF(request,
- errorStatusToSend,
- "Api %s and verb %s found, but the arguments are invalid",
- apiCalled,
- verbCalled);
- return;
-
- default:
- AFB_ReqFailF(request, errorStatusToSend, "Unknown error happened during call to verb %s of api %s", verbCalled, apiCalled);
- return;
- }
-} \ No newline at end of file
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h b/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h
deleted file mode 100644
index 923ca6b..0000000
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2018 "IoT.bzh"
- * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _HAL_UTILITIES_APPFW_RESP_HANDLER_INCLUDE_
-#define _HAL_UTILITIES_APPFW_RESP_HANDLER_INCLUDE_
-
-#include <stdio.h>
-
-#include <wrap-json.h>
-
-#include <afb-definitions.h>
-
-// Enum for the type of error detected
-enum CallError {
- CALL_ERROR_INVALID_ARGS=-1,
- CALL_ERROR_REQUEST_UNAVAILABLE=-2,
- CALL_ERROR_REQUEST_NOT_VALID=-3,
- CALL_ERROR_REQUEST_STATUS_UNAVAILABLE=-4,
- CALL_ERROR_REQUEST_STATUS_NOT_VALID=-5,
- CALL_ERROR_API_UNAVAILABLE=-6,
- CALL_ERROR_VERB_UNAVAILABLE=-7,
- CALL_ERROR_REQUEST_INFO_UNAVAILABLE=-8,
- CALL_ERROR_REQUEST_INFO_NOT_VALID=-9,
- CALL_ERROR_RETURNED=-10,
-};
-
-// Handle application framework response function
-extern enum CallError HalUtlHandleAppFwCallError(AFB_ApiT apiHandle, char *apiCalled, char *verbCalled, json_object *callReturnJ, char **returnedStatus, char **returnedInfo);
-void HalUtlHandleAppFwCallErrorInRequest(AFB_ReqT request, char *apiCalled, char *verbCalled, json_object *callReturnJ, char *errorStatusToSend);
-
-#endif /* _HAL_UTILITIES_APPFW_RESP_HANDLER_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c
deleted file mode 100644
index f3ee028..0000000
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2018 "IoT.bzh"
- * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <string.h>
-
-#include <wrap-json.h>
-
-#include "4a-hal-utilities-data.h"
-
-#include "../4a-hal-controllers/4a-hal-controllers-alsacore-link.h"
-
-/*******************************************************************************
- * Specfic Hal controller streams data handling functions *
- ******************************************************************************/
-
-uint8_t HalUtlRemoveAllCtlHalStreamsData(struct CtlHalMixerDataT *ctlHalStreamsData)
-{
- unsigned int cpt;
-
- if(! ctlHalStreamsData)
- return -1;
-
- if(! ctlHalStreamsData->count)
- return -2;
-
- for(cpt = 0; cpt < ctlHalStreamsData->count; cpt++) {
- free(ctlHalStreamsData->data[cpt].verb);
- free(ctlHalStreamsData->data[cpt].verbToCall);
- free(ctlHalStreamsData->data[cpt].streamCardId);
- }
-
- free(ctlHalStreamsData->data);
-
- return 0;
-}
-
-/*******************************************************************************
- * Specfic Hal data handling functions *
- ******************************************************************************/
-
-struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstHalData)
-{
- struct SpecificHalData *currentApi;
-
- if(! firstHalData)
- return NULL;
-
- currentApi = *firstHalData;
-
- if(! currentApi) {
- currentApi = (struct SpecificHalData *) calloc(1, sizeof(struct SpecificHalData));
- if(! currentApi)
- return NULL;
-
- *firstHalData = currentApi;
- }
- else {
- while(currentApi->next)
- currentApi = currentApi->next;
-
- currentApi->next = calloc(1, sizeof(struct SpecificHalData));
- if(! currentApi)
- return NULL;
-
- currentApi = currentApi->next;
- }
-
- memset(currentApi, 0, sizeof(struct SpecificHalData));
-
- return currentApi;
-}
-
-int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, struct SpecificHalData *apiToRemove)
-{
- struct SpecificHalData *currentApi, *matchingApi;
-
- if(! firstHalData || ! apiToRemove)
- return -1;
-
- currentApi = *firstHalData;
-
- if(currentApi == apiToRemove) {
- *firstHalData = currentApi->next;
- matchingApi = currentApi;
- }
- else {
- while(currentApi && currentApi->next != apiToRemove)
- currentApi = currentApi->next;
-
- if(currentApi) {
- matchingApi = currentApi->next;
- currentApi->next = currentApi->next->next;
- }
- else {
- return -2;
- }
- }
-
- if(! matchingApi->internal) {
- free(matchingApi->apiName);
- free(matchingApi->sndCardPath);
- free(matchingApi->info);
- free(matchingApi->author);
- free(matchingApi->version);
- free(matchingApi->date);
- }
- else {
- HalUtlRemoveAllCtlHalStreamsData(&matchingApi->ctlHalSpecificData->ctlHalStreamsData);
-
- HalCtlsFreeAlsaCtlsMap(matchingApi->ctlHalSpecificData->ctlHalAlsaMapT);
-
- free(matchingApi->ctlHalSpecificData);
- }
-
- free(matchingApi);
-
- return 0;
-}
-
-int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **firstHalData)
-{
- int8_t ret;
- int64_t CtlHalApiRemoved = 0;
-
- while(*firstHalData) {
- ret = HalUtlRemoveSelectedHalFromList(firstHalData, *firstHalData);
- if(ret)
- return (int64_t) ret;
-
- CtlHalApiRemoved++;
- }
-
- return CtlHalApiRemoved;
-}
-
-int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **firstHalData)
-{
- int64_t numberOfCtlHal = 0;
- struct SpecificHalData *currentApi;
-
- if(! firstHalData)
- return -1;
-
- currentApi = *firstHalData;
-
- while(currentApi) {
- currentApi = currentApi->next;
- numberOfCtlHal++;
- }
-
- return numberOfCtlHal;
-}
-
-struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **firstHalData, char *apiName)
-{
- struct SpecificHalData *currentApi;
-
- if(! firstHalData || ! apiName)
- return NULL;
-
- currentApi = *firstHalData;
-
- while(currentApi) {
- if(! strcmp(apiName, currentApi->apiName))
- return currentApi;
-
- currentApi = currentApi->next;
- }
-
- return NULL;
-}
-
-
-struct SpecificHalData *HalUtlSearchReadyHalDataByCarId(struct SpecificHalData **firstHalData, int cardId)
-{
- struct SpecificHalData *currentApi;
-
- if(! firstHalData)
- return NULL;
-
- currentApi = *firstHalData;
- while(currentApi) {
- if(currentApi->status == HAL_STATUS_READY && currentApi->sndCardId == cardId)
- return currentApi;
-
- currentApi = currentApi->next;
- }
-
- return NULL;
-}
-
-/*******************************************************************************
- * Hal Manager data handling functions *
- ******************************************************************************/
-
-uint8_t HalUtlInitializeHalMgrData(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info)
-{
- if(! apiHandle || ! HalMgrGlobalData || ! apiName || ! info)
- return -1;
-
- // Allocate and fill apiName and info strings
- HalMgrGlobalData->apiName = strdup(apiName);
- if(! HalMgrGlobalData->apiName)
- return -2;
-
- HalMgrGlobalData->info = strdup(info);
- if(! HalMgrGlobalData->apiName)
- return -3;
-
- HalMgrGlobalData->apiHandle = apiHandle;
-
- return 0;
-}
-
-void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData)
-{
- if(! HalMgrGlobalData)
- return;
-
- if(HalMgrGlobalData->first)
- HalUtlRemoveAllHalFromList(&HalMgrGlobalData->first);
-
- free(HalMgrGlobalData->apiName);
- free(HalMgrGlobalData->info);
-
- free(HalMgrGlobalData);
-} \ No newline at end of file
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h
deleted file mode 100644
index 01b3db7..0000000
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2018 "IoT.bzh"
- * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _HAL_UTILITIES_DATA_INCLUDE_
-#define _HAL_UTILITIES_DATA_INCLUDE_
-
-#include <stdio.h>
-
-#include <wrap-json.h>
-
-#include <afb-definitions.h>
-
-#include <ctl-config.h>
-
-#include "../4a-hal-controllers/4a-hal-controllers-alsacore-link.h"
-
-// Enum for sharing hal (controller or external) status
-enum HalStatus {
- HAL_STATUS_UNAVAILABLE=0,
- HAL_STATUS_AVAILABLE=1,
- HAL_STATUS_READY=2
-};
-
-// Structure to store stream data
-struct CtlHalMixerData {
- char *verb;
- char *verbToCall;
- char *streamCardId;
- AFB_EventT event;
-};
-
-// Structure to store stream data table
-struct CtlHalMixerDataT {
- struct CtlHalMixerData *data;
- unsigned int count;
-};
-
-// Structure to store specific controller hal data
-struct CtlHalSpecificData {
- char *mixerApiName;
- char *prefix;
- json_object *halMixerJ;
-
- struct CtlHalMixerDataT ctlHalStreamsData;
- struct CtlHalMixerDataT ctlHalPlaybacksData;
- struct CtlHalMixerDataT ctlHalCapturesData;
- struct CtlHalAlsaMapT *ctlHalAlsaMapT;
-
- AFB_ApiT apiHandle;
- CtlConfigT *ctrlConfig;
-};
-
-// Structure to store specific hal (controller or external) data
-struct SpecificHalData {
- char *apiName;
- enum HalStatus status;
- char *sndCardPath;
- int sndCardId;
- char *info;
- unsigned int internal;
-
- char *author;
- char *version;
- char *date;
- // Can be beefed up if needed
-
- struct CtlHalSpecificData *ctlHalSpecificData; // Can be NULL if external api
-
- struct SpecificHalData *next;
-};
-
-// Structure to store hal manager data
-struct HalMgrData {
- char *apiName;
- char *info;
-
- AFB_ApiT apiHandle;
-
- struct SpecificHalData *first;
-};
-
-// Exported verbs for 'struct SpecificHalData' handling
-struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstHalData);
-int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, struct SpecificHalData *ApiToRemove);
-int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **firstHalData);
-int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **firstHalData);
-struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **firstHalData, char *apiName);
-struct SpecificHalData *HalUtlSearchReadyHalDataByCarId(struct SpecificHalData **firstHalData, int cardId);
-
-// Exported verbs for 'struct HalMgrData' handling
-uint8_t HalUtlInitializeHalMgrData(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info);
-void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData);
-
-#endif /* _HAL_UTILITIES_DATA_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c b/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c
deleted file mode 100644
index f557f4c..0000000
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2018 "IoT.bzh"
- * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <string.h>
-
-#include <afb-definitions.h>
-
-#include "4a-hal-utilities-verbs-loader.h"
-
-/*******************************************************************************
- * Dynamic API common functions *
- ******************************************************************************/
-
-int HalUtlLoadVerbs(AFB_ApiT apiHandle, AFB_ApiVerbs *verbs)
-{
- int idx, errCount = 0;
-
- if(! apiHandle || ! verbs)
- return -1;
-
- for (idx = 0; verbs[idx].verb; idx++) {
- errCount+= AFB_ApiAddVerb(apiHandle,
- verbs[idx].verb,
- NULL,
- verbs[idx].callback,
- (void *) &verbs[idx],
- verbs[idx].auth,
- 0,
- 0);
- }
-
- return errCount;
-} \ No newline at end of file
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h b/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h
deleted file mode 100644
index 2bfa1cd..0000000
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 "IoT.bzh"
- * Author Jonathan Aillet <jonathan.aillet@iot.bzh>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _HAL_UTILITIES_VERBS_LOADER_INCLUDE_
-#define _HAL_UTILITIES_VERBS_LOADER_INCLUDE_
-
-#include <stdio.h>
-
-#include <afb-definitions.h>
-
-// Verb that allows to add verb to a dynamic api
-int HalUtlLoadVerbs(AFB_ApiT apiHandle, AFB_ApiVerbs *verbs);
-
-#endif /* _HAL_UTILITIES_VERBS_LOADER_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal/CMakeLists.txt b/4a-hal/CMakeLists.txt
index 2968f23..5392075 100644
--- a/4a-hal/CMakeLists.txt
+++ b/4a-hal/CMakeLists.txt
@@ -23,9 +23,6 @@ PROJECT_TARGET_ADD(4a-hal)
# Define project Targets
add_library(${TARGET_NAME} MODULE
- ${TARGET_NAME}-utilities/${TARGET_NAME}-utilities-appfw-responses-handler.c
- ${TARGET_NAME}-utilities/${TARGET_NAME}-utilities-data.c
- ${TARGET_NAME}-utilities/${TARGET_NAME}-utilities-verbs-loader.c
${TARGET_NAME}-manager/${TARGET_NAME}-manager.c
${TARGET_NAME}-manager/${TARGET_NAME}-manager-cb.c
${TARGET_NAME}-manager/${TARGET_NAME}-manager-events.c
@@ -48,6 +45,7 @@ PROJECT_TARGET_ADD(4a-hal)
TARGET_LINK_LIBRARIES(${TARGET_NAME}
afb-helpers
ctl-utilities
+ 4a-hal-utilities
${link_libraries}
)