diff options
Diffstat (limited to 'lib/4a-hal-utilities')
-rw-r--r-- | lib/4a-hal-utilities/4a-hal-utilities-alsa-data.h | 10 | ||||
-rw-r--r-- | lib/4a-hal-utilities/4a-hal-utilities-data.c | 53 | ||||
-rw-r--r-- | lib/4a-hal-utilities/4a-hal-utilities-data.h | 2 |
3 files changed, 55 insertions, 10 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.h b/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.h index d548c73..b387468 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.h +++ b/lib/4a-hal-utilities/4a-hal-utilities-alsa-data.h @@ -30,6 +30,8 @@ #include <ctl-config.h> +#define HAL_UNKNOWN_DEVICE -1 + struct InternalHalAlsaDBScale { int min; int max; @@ -44,7 +46,7 @@ struct InternalHalAlsaCtlProperties { int maxval; int step; // TBD JAI : use them - const char **enums; + char **enums; struct InternalHalAlsaDBScale *dbscale; }; @@ -58,6 +60,12 @@ struct InternalHalAlsaCtl { }; struct InternalHalAlsaMap { + char *targetUid; + char *targetInfo; + + char *targetedDependency; + int cardNb; + char *uid; char *info; diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c index cebc223..b6d8abb 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-data.c +++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c @@ -68,6 +68,7 @@ void *HalUtlAddNodeInList(struct cds_list_head *listHead, enum LinkedListType li if(! returned) return NULL; nodeToAdd = &((struct InternalHalAlsaMap *) returned)->node; + ((struct InternalHalAlsaMap *) returned)->cardNb = HAL_UNKNOWN_DEVICE; break; case LINKED_LIST_FOR_HAL_DATA: @@ -871,12 +872,18 @@ json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct cds_ void HalUtlFreeSelectedHalMapDataAllocation(struct InternalHalAlsaMap *halMapDataToFree) { + free(halMapDataToFree->targetUid); + free(halMapDataToFree->targetInfo); + + free(halMapDataToFree->targetedDependency); + free(halMapDataToFree->uid); free(halMapDataToFree->info); free(halMapDataToFree->action); - free(halMapDataToFree->ctl.name); + if(halMapDataToFree->ctl.name != halMapDataToFree->uid) + free(halMapDataToFree->ctl.name); if(halMapDataToFree->ctl.alsaCtlCreation) { free(halMapDataToFree->ctl.alsaCtlCreation->enums); @@ -918,7 +925,7 @@ json_object *HalUtGetJsonArrayForSpecificHalMapControl(afb_api_t apiHandle, { int wrapRet; - json_object *currentAlsaMapDataJ; + json_object *currentAlsaMapInfoJ, *additionalInfoJ; if(! apiHandle) { AFB_API_ERROR(apiHandle, "Can't get current internal hal api handle"); @@ -930,16 +937,48 @@ json_object *HalUtGetJsonArrayForSpecificHalMapControl(afb_api_t apiHandle, return NULL; } - wrapRet = wrap_json_pack(¤tAlsaMapDataJ, - "{s:s s:s}", + wrapRet = wrap_json_pack(¤tAlsaMapInfoJ, + "{s:s s:s s:s}", "name", currentHalMapData->uid, - "info", currentHalMapData->info ? currentHalMapData->info : "none"); + "info", currentHalMapData->info ? currentHalMapData->info : "none", + "target", currentHalMapData->targetedDependency); if(wrapRet) { - AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current streams json object"); + AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current halmap control first part of info json object"); return NULL; } - return currentAlsaMapDataJ; + if(currentHalMapData->cardNb == HAL_UNKNOWN_DEVICE || + ! currentHalMapData->ctl.alsaCtlProperties) { + json_object_object_add(currentAlsaMapInfoJ, "available", json_object_new_boolean(0)); + } + else { + wrapRet = wrap_json_pack(&additionalInfoJ, + "{s:b s:i s:s}", + "available", 1, + "cardNb", currentHalMapData->cardNb, + "cardControlName", currentHalMapData->ctl.name ? currentHalMapData->ctl.name : "'N/A'"); + if(wrapRet) { + AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current halmap control second part of info json object"); + json_object_put(currentAlsaMapInfoJ); + return NULL; + } + + wrap_json_object_add(currentAlsaMapInfoJ, additionalInfoJ); + } + + wrapRet = wrap_json_pack(&additionalInfoJ, + "{s:s s:s}", + "halmap-uid", currentHalMapData->targetUid, + "halmap-info", currentHalMapData->targetInfo ? currentHalMapData->targetInfo : "none"); + if(wrapRet) { + AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current halmap control third part of info json object"); + json_object_put(currentAlsaMapInfoJ); + return NULL; + } + + wrap_json_object_add(currentAlsaMapInfoJ, additionalInfoJ); + + return currentAlsaMapInfoJ; } json_object *HalUtGetJsonArrayForAllHalMapControls(afb_api_t apiHandle, struct cds_list_head *halMapListHead) diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h index 1ecfe00..bea92dd 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-data.h +++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h @@ -30,8 +30,6 @@ #include "4a-hal-utilities-alsa-data.h" -#define HAL_UNKNOWN_DEVICE -1 - #define HAL_STREAM_UPDATES_EVENT_NAME "stream-updates" // Enum for linked list type |