summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/4a-internals-hal/4a-internals-hal-cb.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/src/4a-internals-hal/4a-internals-hal-cb.c b/src/4a-internals-hal/4a-internals-hal-cb.c
index 1e920c3..a8d6dc3 100644
--- a/src/4a-internals-hal/4a-internals-hal-cb.c
+++ b/src/4a-internals-hal/4a-internals-hal-cb.c
@@ -266,6 +266,56 @@ int InternalHalProcessOneHalMapObject(afb_api_t apiHandle, struct InternalHalAls
return 0;
}
+int InternalHalProcessAllHalMap(afb_api_t apiHandle, json_object *AlsaMapJ, struct InternalHalAlsaMapT *currentInternalHalAlsaMapT)
+{
+ int idx, err = 0;
+
+ struct InternalHalAlsaMap *ctlMaps;
+
+ json_object *currentAlsaMapJ;
+ json_type alsaMapType;
+
+ alsaMapType = json_object_get_type(AlsaMapJ);
+ switch(alsaMapType) {
+ case json_type_array:
+ currentInternalHalAlsaMapT->ctlsCount = (unsigned int) json_object_array_length(AlsaMapJ);
+ break;
+
+ case json_type_object:
+ currentInternalHalAlsaMapT->ctlsCount = 1;
+ break;
+
+ default:
+ currentInternalHalAlsaMapT->ctlsCount = 0;
+ currentInternalHalAlsaMapT->ctls = NULL;
+ AFB_API_ERROR(apiHandle, "Content of 'halmap' section is not valid ('%s')", json_object_get_string(AlsaMapJ));
+ return -1;
+ }
+
+ ctlMaps = calloc(currentInternalHalAlsaMapT->ctlsCount, sizeof(struct InternalHalAlsaMap));
+ if(! ctlMaps) {
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate halmap data table");
+ return -2;
+ }
+
+ for(idx = 0; idx < currentInternalHalAlsaMapT->ctlsCount; idx++) {
+ currentAlsaMapJ = (alsaMapType == json_type_array) ? json_object_array_get_idx(AlsaMapJ, idx) : AlsaMapJ;
+ err = InternalHalProcessOneHalMapObject(apiHandle, &ctlMaps[idx], currentAlsaMapJ);
+ if(err) {
+ AFB_API_ERROR(apiHandle,
+ "Didn't succeed to proccess halmap object %i ('%s')",
+ idx,
+ json_object_get_string(currentAlsaMapJ));
+ HalUtlFreeAlsaCtlsMap(currentInternalHalAlsaMapT);
+ return -3;
+ }
+ }
+
+ currentInternalHalAlsaMapT->ctls = ctlMaps;
+
+ return err;
+}
+
int InternalHalHandleOneHalMapObject(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaMap *alsaMap)
{
int err;
@@ -360,56 +410,6 @@ int InternalHalHandleOneHalMapObject(afb_api_t apiHandle, char *cardId, struct I
return 0;
}
-int InternalHalProcessAllHalMap(afb_api_t apiHandle, json_object *AlsaMapJ, struct InternalHalAlsaMapT *currentInternalHalAlsaMapT)
-{
- int idx, err = 0;
-
- struct InternalHalAlsaMap *ctlMaps;
-
- json_object *currentAlsaMapJ;
- json_type alsaMapType;
-
- alsaMapType = json_object_get_type(AlsaMapJ);
- switch(alsaMapType) {
- case json_type_array:
- currentInternalHalAlsaMapT->ctlsCount = (unsigned int) json_object_array_length(AlsaMapJ);
- break;
-
- case json_type_object:
- currentInternalHalAlsaMapT->ctlsCount = 1;
- break;
-
- default:
- currentInternalHalAlsaMapT->ctlsCount = 0;
- currentInternalHalAlsaMapT->ctls = NULL;
- AFB_API_ERROR(apiHandle, "Content of 'halmap' section is not valid ('%s')", json_object_get_string(AlsaMapJ));
- return -1;
- }
-
- ctlMaps = calloc(currentInternalHalAlsaMapT->ctlsCount, sizeof(struct InternalHalAlsaMap));
- if(! ctlMaps) {
- AFB_API_ERROR(apiHandle, "Didn't succeed to allocate halmap data table");
- return -2;
- }
-
- for(idx = 0; idx < currentInternalHalAlsaMapT->ctlsCount; idx++) {
- currentAlsaMapJ = (alsaMapType == json_type_array) ? json_object_array_get_idx(AlsaMapJ, idx) : AlsaMapJ;
- err = InternalHalProcessOneHalMapObject(apiHandle, &ctlMaps[idx], currentAlsaMapJ);
- if(err) {
- AFB_API_ERROR(apiHandle,
- "Didn't succeed to proccess halmap object %i ('%s')",
- idx,
- json_object_get_string(currentAlsaMapJ));
- HalUtlFreeAlsaCtlsMap(currentInternalHalAlsaMapT);
- return -3;
- }
- }
-
- currentInternalHalAlsaMapT->ctls = ctlMaps;
-
- return err;
-}
-
int InternalHalHandleAllHalMap(afb_api_t apiHandle, int sndCardId, struct InternalHalAlsaMapT *currentInternalHalAlsaMapT)
{
int idx, err = 0;