summaryrefslogtreecommitdiffstats
path: root/4a-hal-utilities
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-04-18 12:40:25 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-05-24 12:05:52 +0200
commit68138a3ec7a78ad7304d291ff92d8e5292847c4e (patch)
tree9157134d50a749c838afdf93a49c4ce17a018347 /4a-hal-utilities
parent196e723e79a1f5eae41cf4a8b1450df0679a4af8 (diff)
Clarify internals hal functions and files names
The purpose of this commit is to have of a more standard way to name files and functions used to generate/handle hal api (generated from hal json configuration file). It occurred to me that 'hal-controller' was not a good name because it is harder for people who don't know about the app-controller to understanded what is the purpose of these files/functions. It was renamed to 'internal-hal' because it's about hal that are all handle/load by hal-manager in opposition of external-hal that are independant binding/binder that can register themselves to hal-manager. BUG-AGL: SPEC-2329 Change-Id: I11b7efe64ec474b004a2a15ed8969b9db95d428f Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal-utilities')
-rw-r--r--4a-hal-utilities/4a-hal-utilities-alsa-data.c4
-rw-r--r--4a-hal-utilities/4a-hal-utilities-alsa-data.h22
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.c183
-rw-r--r--4a-hal-utilities/4a-hal-utilities-data.h64
-rw-r--r--4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c79
-rw-r--r--4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h8
6 files changed, 186 insertions, 174 deletions
diff --git a/4a-hal-utilities/4a-hal-utilities-alsa-data.c b/4a-hal-utilities/4a-hal-utilities-alsa-data.c
index 79cc8eb..6409253 100644
--- a/4a-hal-utilities/4a-hal-utilities-alsa-data.c
+++ b/4a-hal-utilities/4a-hal-utilities-alsa-data.c
@@ -24,10 +24,10 @@
#include "4a-hal-utilities-alsa-data.h"
/*******************************************************************************
- * Free contents of 'CtlHalAlsaMapT' data structure *
+ * Free contents of 'InternalHalAlsaMapT' data structure *
******************************************************************************/
-uint8_t HalUtlFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap)
+uint8_t HalUtlFreeAlsaCtlsMap(struct InternalHalAlsaMapT *alsaCtlsMap)
{
int idx;
diff --git a/4a-hal-utilities/4a-hal-utilities-alsa-data.h b/4a-hal-utilities/4a-hal-utilities-alsa-data.h
index ef0aba1..fe70210 100644
--- a/4a-hal-utilities/4a-hal-utilities-alsa-data.h
+++ b/4a-hal-utilities/4a-hal-utilities-alsa-data.h
@@ -28,14 +28,14 @@
#include <ctl-config.h>
-struct CtlHalAlsaDBScale {
+struct InternalHalAlsaDBScale {
int min;
int max;
int step;
int mute;
};
-struct CtlHalAlsaCtlProperties {
+struct InternalHalAlsaCtlProperties {
snd_ctl_elem_type_t type;
int count;
int minval;
@@ -43,32 +43,32 @@ struct CtlHalAlsaCtlProperties {
int step;
// TBD JAI : use them
const char **enums;
- struct CtlHalAlsaDBScale *dbscale;
+ struct InternalHalAlsaDBScale *dbscale;
};
-struct CtlHalAlsaCtl {
+struct InternalHalAlsaCtl {
char *name;
int numid;
int value;
- struct CtlHalAlsaCtlProperties alsaCtlProperties;
- struct CtlHalAlsaCtlProperties *alsaCtlCreation;
+ struct InternalHalAlsaCtlProperties alsaCtlProperties;
+ struct InternalHalAlsaCtlProperties *alsaCtlCreation;
};
-struct CtlHalAlsaMap {
+struct InternalHalAlsaMap {
const char *uid;
char *info;
afb_event_t alsaControlEvent;
- struct CtlHalAlsaCtl ctl;
+ struct InternalHalAlsaCtl ctl;
json_object *actionJ;
CtlActionT *action;
};
-struct CtlHalAlsaMapT {
- struct CtlHalAlsaMap *ctls;
+struct InternalHalAlsaMapT {
+ struct InternalHalAlsaMap *ctls;
unsigned int ctlsCount;
};
// Free contents of 'CtlHalAlsaMapT' data structure
-uint8_t HalUtlFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap);
+uint8_t HalUtlFreeAlsaCtlsMap(struct InternalHalAlsaMapT *alsaCtlsMap);
#endif /* _HAL_UTILITIES_ALSA_DATA_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal-utilities/4a-hal-utilities-data.c
index 0790ed3..314190f 100644
--- a/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/4a-hal-utilities/4a-hal-utilities-data.c
@@ -28,19 +28,19 @@
#include "4a-hal-utilities-alsa-data.h"
/*******************************************************************************
- * Specfic Hal controller streams data handling functions *
+ * Internal Hal - Streams data handling functions *
******************************************************************************/
-struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData **mixerDataList)
+struct InternalHalMixerData *HalUtlAddMixerDataToMixerDataList(struct InternalHalMixerData **mixerDataList)
{
- struct CtlHalMixerData *currentMixerData;
+ struct InternalHalMixerData *currentMixerData;
if(! mixerDataList)
return NULL;
currentMixerData = *mixerDataList;
if(! currentMixerData) {
- currentMixerData = (struct CtlHalMixerData *) calloc(1, sizeof(struct CtlHalMixerData));
+ currentMixerData = (struct InternalHalMixerData *) calloc(1, sizeof(struct InternalHalMixerData));
if(! currentMixerData)
return NULL;
@@ -50,7 +50,7 @@ struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData
while(currentMixerData->next)
currentMixerData = currentMixerData->next;
- currentMixerData->next = calloc(1, sizeof(struct CtlHalMixerData));
+ currentMixerData->next = calloc(1, sizeof(struct InternalHalMixerData));
if(! currentMixerData->next)
return NULL;
@@ -60,9 +60,9 @@ struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData
return currentMixerData;
}
-int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **mixerDataList, struct CtlHalMixerData *mixerDataToRemove)
+int8_t HalUtlRemoveSelectedMixerData(struct InternalHalMixerData **mixerDataList, struct InternalHalMixerData *mixerDataToRemove)
{
- struct CtlHalMixerData *currentMixerData, *matchingMixerData;
+ struct InternalHalMixerData *currentMixerData, *matchingMixerData;
if(! mixerDataList || ! *mixerDataList || ! mixerDataToRemove)
return -1;
@@ -94,7 +94,7 @@ int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **mixerDataList, str
return 0;
}
-int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **mixerDataList)
+int64_t HalUtlRemoveAllMixerData(struct InternalHalMixerData **mixerDataList)
{
int8_t ret;
int64_t mixerDataRemoved = 0;
@@ -113,16 +113,15 @@ int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **mixerDataList)
return mixerDataRemoved;
}
-int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **mixerDataList)
+int64_t HalUtlGetNumberOfMixerDataInList(struct InternalHalMixerData **mixerDataList)
{
int64_t numberOfMixerData = 0;
- struct CtlHalMixerData *currentMixerData;
+ struct InternalHalMixerData *currentMixerData;
if(! mixerDataList)
return -1;
currentMixerData = *mixerDataList;
-
while(currentMixerData) {
currentMixerData = currentMixerData->next;
numberOfMixerData++;
@@ -131,9 +130,9 @@ int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **mixerDataList)
return numberOfMixerData;
}
-struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData **mixerDataList, char *verb, char *verbToCall, char *streamCardId)
+struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHalMixerData **mixerDataList, char *verb, char *verbToCall, char *streamCardId)
{
- struct CtlHalMixerData *currentMixerData;
+ struct InternalHalMixerData *currentMixerData;
if(! mixerDataList || ! verb)
return NULL;
@@ -153,89 +152,89 @@ struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData
}
/*******************************************************************************
- * Specfic Hal data handling functions *
+ * Hal data handling functions *
******************************************************************************/
-struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **halDataList)
+struct HalData *HalUtlAddHalToHalList(struct HalData **halDataList)
{
- struct SpecificHalData *currentApi;
+ struct HalData *currentHalData;
if(! halDataList)
return NULL;
- currentApi = *halDataList;
- if(! currentApi) {
- currentApi = (struct SpecificHalData *) calloc(1, sizeof(struct SpecificHalData));
- if(! currentApi)
+ currentHalData = *halDataList;
+ if(! currentHalData) {
+ currentHalData = (struct HalData *) calloc(1, sizeof(struct HalData));
+ if(! currentHalData)
return NULL;
- *halDataList = currentApi;
+ *halDataList = currentHalData;
}
else {
- while(currentApi->next)
- currentApi = currentApi->next;
+ while(currentHalData->next)
+ currentHalData = currentHalData->next;
- currentApi->next = calloc(1, sizeof(struct SpecificHalData));
- if(! currentApi->next)
+ currentHalData->next = calloc(1, sizeof(struct HalData));
+ if(! currentHalData->next)
return NULL;
- currentApi = currentApi->next;
+ currentHalData = currentHalData->next;
}
- return currentApi;
+ return currentHalData;
}
-int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **halDataList, struct SpecificHalData *apiToRemove)
+int8_t HalUtlRemoveSelectedHalFromList(struct HalData **halDataList, struct HalData *halToRemove)
{
- struct SpecificHalData *currentApi, *matchingApi;
+ struct HalData *currentHalData, *matchingHal;
- if(! halDataList || ! *halDataList || ! apiToRemove)
+ if(! halDataList || ! *halDataList || ! halToRemove)
return -1;
- currentApi = *halDataList;
- if(currentApi == apiToRemove) {
- *halDataList = currentApi->next;
- matchingApi = currentApi;
+ currentHalData = *halDataList;
+ if(currentHalData == halToRemove) {
+ *halDataList = currentHalData->next;
+ matchingHal = currentHalData;
}
else {
- while(currentApi && currentApi->next != apiToRemove)
- currentApi = currentApi->next;
+ while(currentHalData && currentHalData->next != halToRemove)
+ currentHalData = currentHalData->next;
- if(currentApi) {
- matchingApi = currentApi->next;
- currentApi->next = currentApi->next->next;
+ if(currentHalData) {
+ matchingHal = currentHalData->next;
+ currentHalData->next = currentHalData->next->next;
}
else {
return -2;
}
}
- free(matchingApi->apiName);
- free(matchingApi->sndCardPath);
- free(matchingApi->info);
- free(matchingApi->author);
- free(matchingApi->version);
- free(matchingApi->date);
+ free(matchingHal->apiName);
+ free(matchingHal->sndCardPath);
+ free(matchingHal->info);
+ free(matchingHal->author);
+ free(matchingHal->version);
+ free(matchingHal->date);
- if(matchingApi->internal) {
- HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalStreamsData);
- HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalPlaybacksData);
- HalUtlRemoveAllMixerData(&matchingApi->ctlHalSpecificData->ctlHalCapturesData);
+ if(matchingHal->internal) {
+ HalUtlRemoveAllMixerData(&matchingHal->internalHalData->streamsData);
+ HalUtlRemoveAllMixerData(&matchingHal->internalHalData->playbacksData);
+ HalUtlRemoveAllMixerData(&matchingHal->internalHalData->capturesData);
- HalUtlFreeAlsaCtlsMap(matchingApi->ctlHalSpecificData->ctlHalAlsaMapT);
+ HalUtlFreeAlsaCtlsMap(matchingHal->internalHalData->alsaMapT);
- free(matchingApi->ctlHalSpecificData);
+ free(matchingHal->internalHalData);
}
- free(matchingApi);
+ free(matchingHal);
return 0;
}
-int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **halDataList)
+int64_t HalUtlRemoveAllHalFromList(struct HalData **halDataList)
{
int8_t ret;
- int64_t CtlHalApiRemoved = 0;
+ int64_t halRemoved = 0;
if(! halDataList)
return -1;
@@ -245,63 +244,63 @@ int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **halDataList)
if(ret)
return (int64_t) ret;
- CtlHalApiRemoved++;
+ halRemoved++;
}
- return CtlHalApiRemoved;
+ return halRemoved;
}
-int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **halDataList)
+int64_t HalUtlGetNumberOfHalInList(struct HalData **halDataList)
{
- int64_t numberOfCtlHal = 0;
- struct SpecificHalData *currentApi;
+ int64_t numberOfHal = 0;
+ struct HalData *currentHalData;
if(! halDataList)
return -1;
- currentApi = *halDataList;
+ currentHalData = *halDataList;
- while(currentApi) {
- currentApi = currentApi->next;
- numberOfCtlHal++;
+ while(currentHalData) {
+ currentHalData = currentHalData->next;
+ numberOfHal++;
}
- return numberOfCtlHal;
+ return numberOfHal;
}
-struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **halDataList, char *apiName)
+struct HalData *HalUtlSearchHalDataByApiName(struct HalData **halDataList, char *apiName)
{
- struct SpecificHalData *currentApi;
+ struct HalData *currentHalData;
if(! halDataList || ! *halDataList || ! apiName)
return NULL;
- currentApi = *halDataList;
+ currentHalData = *halDataList;
- while(currentApi) {
- if(! strcmp(apiName, currentApi->apiName))
- return currentApi;
+ while(currentHalData) {
+ if(! strcmp(apiName, currentHalData->apiName))
+ return currentHalData;
- currentApi = currentApi->next;
+ currentHalData = currentHalData->next;
}
return NULL;
}
-struct SpecificHalData *HalUtlSearchReadyHalDataByCardId(struct SpecificHalData **halDataList, int cardId)
+struct HalData *HalUtlSearchReadyHalDataByCardId(struct HalData **halDataList, int cardId)
{
- struct SpecificHalData *currentApi;
+ struct HalData *currentHalData;
if(! halDataList || ! *halDataList)
return NULL;
- currentApi = *halDataList;
+ currentHalData = *halDataList;
- while(currentApi) {
- if(currentApi->status == HAL_STATUS_READY && currentApi->sndCardId == cardId)
- return currentApi;
+ while(currentHalData) {
+ if(currentHalData->status == HAL_STATUS_READY && currentHalData->sndCardId == cardId)
+ return currentHalData;
- currentApi = currentApi->next;
+ currentHalData = currentHalData->next;
}
return NULL;
@@ -311,35 +310,35 @@ struct SpecificHalData *HalUtlSearchReadyHalDataByCardId(struct SpecificHalData
* Hal Manager data handling functions *
******************************************************************************/
-uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info)
+uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *halMgrData, char *apiName, char *info)
{
- if(! apiHandle || ! HalMgrGlobalData || ! apiName || ! info)
+ if(! apiHandle || ! halMgrData || ! apiName || ! info)
return -1;
// Allocate and fill apiName and info strings
- HalMgrGlobalData->apiName = strdup(apiName);
- if(! HalMgrGlobalData->apiName)
+ halMgrData->apiName = strdup(apiName);
+ if(! halMgrData->apiName)
return -2;
- HalMgrGlobalData->info = strdup(info);
- if(! HalMgrGlobalData->info)
+ halMgrData->info = strdup(info);
+ if(! halMgrData->info)
return -3;
- HalMgrGlobalData->apiHandle = apiHandle;
+ halMgrData->apiHandle = apiHandle;
return 0;
}
-void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData)
+void HalUtlRemoveHalMgrData(struct HalMgrData *halMgrData)
{
- if(! HalMgrGlobalData)
+ if(! halMgrData)
return;
- if(HalMgrGlobalData->halDataList)
- HalUtlRemoveAllHalFromList(&HalMgrGlobalData->halDataList);
+ if(halMgrData->halDataList)
+ HalUtlRemoveAllHalFromList(&halMgrData->halDataList);
- free(HalMgrGlobalData->apiName);
- free(HalMgrGlobalData->info);
+ free(halMgrData->apiName);
+ free(halMgrData->info);
- free(HalMgrGlobalData);
+ free(halMgrData);
} \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal-utilities/4a-hal-utilities-data.h
index 1389aa6..f3de1a6 100644
--- a/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/4a-hal-utilities/4a-hal-utilities-data.h
@@ -30,7 +30,7 @@
#define HAL_STREAM_UPDATES_EVENT_NAME "stream-updates"
-// Enum for sharing hal (controller or external) status
+// Enum for hal status
enum HalStatus {
HAL_STATUS_UNAVAILABLE=0,
HAL_STATUS_AVAILABLE=1,
@@ -38,35 +38,35 @@ enum HalStatus {
};
// Structure to store stream data
-struct CtlHalMixerData {
+struct InternalHalMixerData {
char *verb;
char *verbToCall;
char *streamCardId;
afb_event_t event;
- struct CtlHalMixerData *next;
+ struct InternalHalMixerData *next;
};
-// Structure to store specific controller hal data
-struct CtlHalSpecificData {
+// Structure to store specific internal hal data
+struct InternalHalData {
char *mixerApiName;
char *prefix;
json_object *halMixerJ;
- struct CtlHalMixerData *ctlHalStreamsData;
+ struct InternalHalMixerData *streamsData;
afb_event_t streamUpdates;
- struct CtlHalMixerData *ctlHalPlaybacksData;
- struct CtlHalMixerData *ctlHalCapturesData;
+ struct InternalHalMixerData *playbacksData;
+ struct InternalHalMixerData *capturesData;
- struct CtlHalAlsaMapT *ctlHalAlsaMapT;
+ struct InternalHalAlsaMapT *alsaMapT;
afb_api_t apiHandle;
CtlConfigT *ctrlConfig;
};
-// Structure to store specific hal (controller or external) data
-struct SpecificHalData {
+// Structure to store specific hal (internal or external) data
+struct HalData {
char *apiName;
enum HalStatus status;
char *sndCardPath;
@@ -79,9 +79,9 @@ struct SpecificHalData {
char *date;
// Can be beefed up if needed
- struct CtlHalSpecificData *ctlHalSpecificData; // Can be NULL if external api
+ struct InternalHalData *internalHalData; // Can be NULL if external api
- struct SpecificHalData *next;
+ struct HalData *next;
};
// Structure to store hal manager data
@@ -91,26 +91,26 @@ struct HalMgrData {
afb_api_t apiHandle;
- struct SpecificHalData *halDataList;
+ struct HalData *halDataList;
};
-// Specfic Hal controller streams data handling functions
-struct CtlHalMixerData *HalUtlAddMixerDataToMixerDataList(struct CtlHalMixerData **mixerDataList);
-int8_t HalUtlRemoveSelectedMixerData(struct CtlHalMixerData **mixerDataList, struct CtlHalMixerData *mixerDataToRemove);
-int64_t HalUtlRemoveAllMixerData(struct CtlHalMixerData **mixerDataList);
-int64_t HalUtlGetNumberOfMixerDataInList(struct CtlHalMixerData **mixerDataList);
-struct CtlHalMixerData *HalUtlSearchMixerDataByProperties(struct CtlHalMixerData **mixerDataList, char *verb, char *verbToCall, char *streamCardId);
-
-// Exported verbs for 'struct SpecificHalData' handling
-struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **halDataList);
-int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **halDataList, struct SpecificHalData *ApiToRemove);
-int64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **halDataList);
-int64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **halDataList);
-struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **halDataList, char *apiName);
-struct SpecificHalData *HalUtlSearchReadyHalDataByCardId(struct SpecificHalData **halDataList, int cardId);
-
-// Exported verbs for 'struct HalMgrData' handling
-uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info);
-void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData);
+// Internal Hal - Streams data handling functions
+struct InternalHalMixerData *HalUtlAddMixerDataToMixerDataList(struct InternalHalMixerData **mixerDataList);
+int8_t HalUtlRemoveSelectedMixerData(struct InternalHalMixerData **mixerDataList, struct InternalHalMixerData *mixerDataToRemove);
+int64_t HalUtlRemoveAllMixerData(struct InternalHalMixerData **mixerDataList);
+int64_t HalUtlGetNumberOfMixerDataInList(struct InternalHalMixerData **mixerDataList);
+struct InternalHalMixerData *HalUtlSearchMixerDataByProperties(struct InternalHalMixerData **mixerDataList, char *verb, char *verbToCall, char *streamCardId);
+
+// Hal data handling functions
+struct HalData *HalUtlAddHalToHalList(struct HalData **halDataList);
+int8_t HalUtlRemoveSelectedHalFromList(struct HalData **halDataList, struct HalData *halToRemove);
+int64_t HalUtlRemoveAllHalFromList(struct HalData **halDataList);
+int64_t HalUtlGetNumberOfHalInList(struct HalData **halDataList);
+struct HalData *HalUtlSearchHalDataByApiName(struct HalData **halDataList, char *apiName);
+struct HalData *HalUtlSearchReadyHalDataByCardId(struct HalData **halDataList, int cardId);
+
+// Hal Manager data handling functions
+uint8_t HalUtlInitializeHalMgrData(afb_api_t apiHandle, struct HalMgrData *halMgrData, char *apiName, char *info);
+void HalUtlRemoveHalMgrData(struct HalMgrData *halMgrData);
#endif /* _HAL_UTILITIES_DATA_INCLUDE_ */ \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
index 3f30436..ed06b27 100644
--- a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
+++ b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
@@ -40,8 +40,8 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
afb_api_t apiHandle;
CtlConfigT *ctrlConfig;
- struct SpecificHalData *currentCtlHalData;
- struct CtlHalMixerData *currentMixerData = NULL;
+ struct HalData *currentHalData;
+ struct InternalHalMixerData *currentMixerData = NULL;
json_object *requestJson, *responseJ = NULL, *toReturnJ = NULL;
@@ -55,7 +55,8 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
return;
}
- if(! (currentCtlHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) {
+ currentHalData = (struct HalData *) getExternalData(ctrlConfig);
+ if(! currentHalData) {
afb_req_fail(request, "hal_controller_data", "Can't get current hal controller data");
return;
}
@@ -68,18 +69,19 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
if(json_object_is_type(requestJson, json_type_object) && json_object_get_object(requestJson)->count > 0)
json_object_object_add(requestJson, "verbose", json_object_new_boolean(1));
- apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName;
+ apiToCall = currentHalData->internalHalData->mixerApiName;
if(! apiToCall) {
afb_req_fail(request, "mixer_api", "Can't get mixer api");
return;
}
- if(currentCtlHalData->status != HAL_STATUS_READY) {
+ if(currentHalData->status != HAL_STATUS_READY) {
afb_req_fail(request, "hal_not_ready", "Seems that hal is not ready");
return;
}
- if(! (currentMixerData = (struct CtlHalMixerData *) afb_req_get_vcbdata(request))) {
+ currentMixerData = (struct InternalHalMixerData *) afb_req_get_vcbdata(request);
+ if(! currentMixerData) {
afb_req_fail(request, "hal_call_data", "Can't get current call data");
return;
}
@@ -227,27 +229,32 @@ void HalUtlActionOnAllStream(afb_req_t request)
* Add stream data and verb function *
******************************************************************************/
-struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle,
- char *verb,
- char *verbToCall,
- char *streamCardId)
+struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle,
+ char *verb,
+ char *verbToCall,
+ char *streamCardId)
{
json_object *streamAddedEventJ;
CtlConfigT *ctrlConfig;
- struct SpecificHalData *currentSpecificHalData;
- struct CtlHalMixerData *createdStreamData;
+ struct HalData *currentHalData;
+ struct InternalHalMixerData *createdStreamData;
if(! apiHandle || ! verb || ! verbToCall || ! streamCardId)
return NULL;
- if((! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) ||
- (! (currentSpecificHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) ||
- (! currentSpecificHalData->ctlHalSpecificData))
+ ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle);
+ if(! ctrlConfig)
return NULL;
- if(! (createdStreamData = HalUtlAddMixerDataToMixerDataList(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData)))
+ currentHalData = (struct HalData *) getExternalData(ctrlConfig);
+ if(! currentHalData ||
+ ! currentHalData->internalHalData)
+ return NULL;
+
+ createdStreamData = HalUtlAddMixerDataToMixerDataList(&currentHalData->internalHalData->streamsData);
+ if(! createdStreamData)
return NULL;
createdStreamData->verb = strdup(verb);
@@ -257,12 +264,12 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHand
if((! createdStreamData->verb) ||
(! createdStreamData->verbToCall) ||
(! createdStreamData->streamCardId)) {
- HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
+ HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, createdStreamData);
return NULL;
}
if(! (createdStreamData->event = afb_api_make_event(apiHandle, createdStreamData->verb))) {
- HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
+ HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, createdStreamData);
return NULL;
}
@@ -275,7 +282,7 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHand
0,
0)) {
AFB_API_ERROR(apiHandle,"Error while creating verb for stream : '%s'", createdStreamData->verb);
- HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, createdStreamData);
+ HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, createdStreamData);
return NULL;
}
@@ -285,7 +292,7 @@ struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHand
"name", createdStreamData->verb,
"cardId", createdStreamData->streamCardId);
- afb_event_push(currentSpecificHalData->ctlHalSpecificData->streamUpdates, streamAddedEventJ);
+ afb_event_push(currentHalData->internalHalData->streamUpdates, streamAddedEventJ);
return createdStreamData;
}
@@ -301,23 +308,28 @@ int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
CtlConfigT *ctrlConfig;
- struct SpecificHalData *currentSpecificHalData;
- struct CtlHalMixerData *toRemoveStreamData;
+ struct HalData *currentHalData;
+ struct InternalHalMixerData *toRemoveStreamData;
if(! apiHandle || ! verb || ! verbToCall || ! streamCardId)
return -1;
- if((! (ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle))) ||
- (! (currentSpecificHalData = (struct SpecificHalData *) getExternalData(ctrlConfig))) ||
- (! currentSpecificHalData->ctlHalSpecificData))
+ ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle);
+ if(! ctrlConfig)
return -2;
- if(! (toRemoveStreamData = HalUtlSearchMixerDataByProperties(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData,
- verb,
- verbToCall,
- streamCardId)))
+ currentHalData = (struct HalData *) getExternalData(ctrlConfig);
+ if(! currentHalData ||
+ ! currentHalData->internalHalData)
return -3;
+ toRemoveStreamData = HalUtlSearchMixerDataByProperties(&currentHalData->internalHalData->streamsData,
+ verb,
+ verbToCall,
+ streamCardId);
+ if(! toRemoveStreamData)
+ return -4;
+
wrap_json_pack(&streamRemovedEventJ,
"{s:s, s:s, s:s}",
"action", "removed",
@@ -327,16 +339,17 @@ int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
if(afb_api_del_verb(apiHandle, verb, NULL)) {
AFB_API_ERROR(apiHandle,"Error while deleting verb for stream : '%s'", verb);
json_object_put(streamRemovedEventJ);
- return -4;
+ return -5;
}
- if((returnedErr = HalUtlRemoveSelectedMixerData(&currentSpecificHalData->ctlHalSpecificData->ctlHalStreamsData, toRemoveStreamData))) {
+ returnedErr = HalUtlRemoveSelectedMixerData(&currentHalData->internalHalData->streamsData, toRemoveStreamData);
+ if(returnedErr) {
AFB_API_ERROR(apiHandle,"Error %i while removing data for stream : '%s'", returnedErr, verb);
json_object_put(streamRemovedEventJ);
- return -5;
+ return -6;
}
- afb_event_push(currentSpecificHalData->ctlHalSpecificData->streamUpdates, streamRemovedEventJ);
+ afb_event_push(currentHalData->internalHalData->streamUpdates, streamRemovedEventJ);
return 0;
} \ No newline at end of file
diff --git a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
index ca065e7..028dd1f 100644
--- a/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
+++ b/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
@@ -39,10 +39,10 @@ void HalUtlActionOnCapture(afb_req_t request);
void HalUtlActionOnAllStream(afb_req_t request);
// Add/Remove stream data and verb functions
-struct CtlHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle,
- char *verb,
- char *verbToCall,
- char *streamCardId);
+struct InternalHalMixerData *HalUtlAddStreamDataAndCreateStreamVerb(afb_api_t apiHandle,
+ char *verb,
+ char *verbToCall,
+ char *streamCardId);
int8_t HalUtlRemoveStreamDataAndDeleteStreamVerb(afb_api_t apiHandle,
char *verb,
char *verbToCall,