diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/4a-hal-utilities/4a-hal-utilities-data.c | 81 | ||||
-rw-r--r-- | lib/4a-hal-utilities/4a-hal-utilities-data.h | 17 | ||||
-rw-r--r-- | lib/4a-hal-utilities/4a-hal-utilities-ping.c | 2 |
3 files changed, 97 insertions, 3 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c index 6d1afd0..865bebb 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-data.c +++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c @@ -313,6 +313,26 @@ int HalUtlGetNumberOfProbedDevicesInList(struct cds_list_head *probedDevicesList return HalUtlGetNumberOfNodesInList(probedDevicesListHead); } +int HalUtlGetNumberOfDynamicProbedDevicesInList(struct cds_list_head *probedDevicesListHead) +{ + int numberOfDynamicProbedDevicesInList = 0; + + struct InternalHalProbedDevice *currentProbedDevice; + + if(! probedDevicesListHead) + return -1; + + if(cds_list_empty(probedDevicesListHead)) + return 0; + + cds_list_for_each_entry(currentProbedDevice, probedDevicesListHead, node) { + if(currentProbedDevice->deviceClass == DYNAMIC_PROBED_DEVICE) + numberOfDynamicProbedDevicesInList++; + } + + return numberOfDynamicProbedDevicesInList; +} + struct InternalHalProbedDevice *HalUtlSearchProbedDeviceDataById(struct cds_list_head *probedDevicesListHead, char *uid) { @@ -467,8 +487,9 @@ json_object *HalUtlGetCompactJsonForSpecificDependencies(afb_api_t apiHandle, cardNb = requestedProbedDevice->deviceData->extendedCardNb; wrapRet = wrap_json_pack(&requestedProbedDeviceJ, - "{s:s s:s}", + "{s:s, s:b, s:s}", "uid", requestedProbedDevice->uid, + "available", cardNb ? 1 : 0, "cardNb", cardNb ? cardNb : "none"); if(wrapRet) { AFB_API_ERROR(apiHandle, @@ -771,6 +792,64 @@ json_object *HalUtlGetJsonArrayForAllDependencies(afb_api_t apiHandle, return requestedDependenciesInfoJ; } +json_object *HalUtlGetJsonArrayForAllDependenciesInfoWithHandledDependency(afb_api_t apiHandle, + struct cds_list_head *probedDevicesListHead, + enum DependencyInfoJsonFormat jsonFormat, + char *handledProbedDeviceUid) +{ + int err; + size_t idx, dependencyNb; + char *currentDependencyObjectUidString = NULL; + + json_object *requestedDependenciesInfoJ, *currentDependencyObject; + + if(! apiHandle) { + AFB_API_ERROR(apiHandle, "Api handle is not valid"); + return NULL; + } + + if(! probedDevicesListHead) { + AFB_API_ERROR(apiHandle, "Probed device list is not valid"); + return NULL; + } + + if(cds_list_empty(probedDevicesListHead)) { + AFB_API_INFO(apiHandle, "Probed device list is empty"); + return NULL; + } + + if(! handledProbedDeviceUid) { + AFB_API_ERROR(apiHandle, "Probed device uid is not valid"); + return NULL; + } + + requestedDependenciesInfoJ = HalUtlGetJsonArrayForAllDependencies(apiHandle, + probedDevicesListHead, + jsonFormat); + if(! requestedDependenciesInfoJ) { + AFB_API_ERROR(apiHandle, "Didn't succeed get all devices (dependencies) info"); + return NULL; + } + + dependencyNb = json_object_array_length(requestedDependenciesInfoJ); + for(idx = 0; idx < dependencyNb; idx++) { + currentDependencyObject = json_object_array_get_idx(requestedDependenciesInfoJ, idx); + + err = wrap_json_unpack(currentDependencyObject, "{s:s}", "uid", ¤tDependencyObjectUidString); + if(err) { + AFB_API_ERROR(apiHandle, "Dependency object is malformed (no uid key)"); + return NULL; + } + + if(! strcmp(handledProbedDeviceUid, currentDependencyObjectUidString)) + json_object_object_add(currentDependencyObject, "handled", json_object_new_boolean(1)); + else + json_object_object_add(currentDependencyObject, "handled", json_object_new_boolean(0)); + } + + return requestedDependenciesInfoJ; +} + /******************************************************************************* * Internal Hal - Streams data handling functions * ******************************************************************************/ diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h index a2b28dd..69ba747 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-data.h +++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h @@ -56,6 +56,16 @@ enum ProbedDeviceClasses { MANDATORY_PROBED_DEVICE = 3 }; +// Enum for dependencies mixer link status +enum DependencyMixerStatus { + DEPENDENCY_NO_MIXER_LINK = 0, + DEPENDENCY_MIXER_LINK_USELESS = 1, + DEPENDENCY_MIXER_ATTACH_SUCCEED = 2, + DEPENDENCY_MIXER_ATTACH_FAILED = 3, + DEPENDENCY_MIXER_DETACH_SUCCEED = 4, + DEPENDENCY_MIXER_DETACH_FAILED = 5 +}; + // Enum for probed devices (dependencies) info format requested enum DependencyInfoJsonFormat { DEPENDENCY_COMPACT_JSON = 0, @@ -91,6 +101,7 @@ struct InternalHalProbedDevice { json_object *requestedDeviceJ; struct InternalHalDeviceData *deviceData; + enum DependencyMixerStatus mixerLinkStatus; struct cds_list_head node; }; @@ -153,11 +164,13 @@ struct HalMgrData { // Internal Hal - Probed devices structure handling functions enum ProbedDeviceClasses HalUtlGetProbedDeviceClassFromString(char *probedDeviceString); char *HalUtlGetProbedDeviceClassString(enum ProbedDeviceClasses deviceClass); +void HalUtlFreeSelectedProbedDeviceDataAllocation(struct InternalHalDeviceData *probedDeviceDataToFree); struct InternalHalProbedDevice *HalUtlAddProbedDeviceToProbedDeviceList(struct cds_list_head *probedDevicesListHead); int HalUtlRemoveSelectedProbedDeviceFromList(struct cds_list_head *probedDevicesListHead, struct InternalHalProbedDevice *probedDeviceToRemove); int HalUtlRemoveAllProbedDevicesFromList(struct cds_list_head *probedDevicesListHead); int HalUtlGetNumberOfProbedDevicesInList(struct cds_list_head *probedDevicesListHead); +int HalUtlGetNumberOfDynamicProbedDevicesInList(struct cds_list_head *probedDevicesListHead); struct InternalHalProbedDevice *HalUtlSearchProbedDeviceDataById(struct cds_list_head *probedDevicesListHead, char *uid); int HalUtlGetProbedDeviceCardNbUsingUid(struct cds_list_head *probedDevicesListHead, char *uid); @@ -175,6 +188,10 @@ json_object *HalUtlGetJsonArrayForAvailableDependencies(afb_api_t apiHandle, json_object *HalUtlGetJsonArrayForAllDependencies(afb_api_t apiHandle, struct cds_list_head *probedDevicesListHead, enum DependencyInfoJsonFormat jsonFormat); +json_object *HalUtlGetJsonArrayForAllDependenciesInfoWithHandledDependency(afb_api_t apiHandle, + struct cds_list_head *probedDevicesListHead, + enum DependencyInfoJsonFormat jsonFormat, + char *handledProbedDeviceUid); // Internal Hal - Streams data handling functions struct InternalHalMixerData *HalUtlAddMixerDataToMixerDataList(struct cds_list_head *mixerDataListHead); diff --git a/lib/4a-hal-utilities/4a-hal-utilities-ping.c b/lib/4a-hal-utilities/4a-hal-utilities-ping.c index a40254f..4a3fc25 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-ping.c +++ b/lib/4a-hal-utilities/4a-hal-utilities-ping.c @@ -47,6 +47,4 @@ void HalUtlPing(afb_req_t request) } afb_req_success(request, countJ, "Ping count"); - - return; }
\ No newline at end of file |