aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.c66
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.h4
-rw-r--r--src/4a-internals-hal/4a-internals-hal-cb.c44
3 files changed, 74 insertions, 40 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c
index b6d8abb..6d1afd0 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c
@@ -611,8 +611,13 @@ json_object *HalUtlGetJsonForSpecificDependenciesUsingUid(afb_api_t apiHandle,
return NULL;
}
- if(! probedDevicesListHead || cds_list_empty(probedDevicesListHead)) {
- AFB_API_ERROR(apiHandle, "Probed device list is empty");
+ 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;
}
@@ -655,7 +660,7 @@ json_object *HalUtlGetJsonArrayForSelectedDependencies(afb_api_t apiHandle,
}
if(! probedDevicesListHead || cds_list_empty(probedDevicesListHead)) {
- AFB_API_ERROR(apiHandle, "Probed device list is empty");
+ AFB_API_ERROR(apiHandle, "Probed device list is not valid or empty");
return NULL;
}
@@ -699,8 +704,13 @@ json_object *HalUtlGetJsonArrayForAvailableDependencies(afb_api_t apiHandle,
return NULL;
}
- if(! probedDevicesListHead || cds_list_empty(probedDevicesListHead)) {
- AFB_API_ERROR(apiHandle, "Probed device list is empty");
+ 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;
}
@@ -713,6 +723,12 @@ json_object *HalUtlGetJsonArrayForAvailableDependencies(afb_api_t apiHandle,
return NULL;
}
+ if(! json_object_array_length(requestedDependenciesInfoJ)) {
+ AFB_API_INFO(apiHandle, "No available devices (dependencies) in list");
+ json_object_put(requestedDependenciesInfoJ);
+ return NULL;
+ }
+
return requestedDependenciesInfoJ;
}
@@ -727,8 +743,13 @@ json_object *HalUtlGetJsonArrayForAllDependencies(afb_api_t apiHandle,
return NULL;
}
- if(! probedDevicesListHead || cds_list_empty(probedDevicesListHead)) {
- AFB_API_ERROR(apiHandle, "Probed device list is empty");
+ 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;
}
@@ -737,7 +758,13 @@ json_object *HalUtlGetJsonArrayForAllDependencies(afb_api_t apiHandle,
jsonFormat,
ALL_DEPENDENCY);
if(! requestedDependenciesInfoJ) {
- AFB_API_ERROR(apiHandle, "Didn't succeed get available devices (dependencies) info");
+ AFB_API_ERROR(apiHandle, "Didn't succeed get all devices (dependencies) info");
+ return NULL;
+ }
+
+ if(! json_object_array_length(requestedDependenciesInfoJ)) {
+ AFB_API_ERROR(apiHandle, "No devices (dependencies) info returned but list is not empty");
+ json_object_put(requestedDependenciesInfoJ);
return NULL;
}
@@ -842,7 +869,7 @@ json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct cds_
}
if(cds_list_empty(mixerDataListHead)) {
- AFB_API_ERROR(apiHandle, "Mixer data list is empty");
+ AFB_API_INFO(apiHandle, "Mixer data list is empty");
return NULL;
}
@@ -863,6 +890,12 @@ json_object *HalUtlGetJsonArrayForAllMixersData(afb_api_t apiHandle, struct cds_
json_object_array_add(mixerDataArrayJ, currentMixerDataJ);
}
+ if(! json_object_array_length(mixerDataArrayJ)) {
+ AFB_API_ERROR(apiHandle, "No mixer info returned but list is not empty");
+ json_object_put(mixerDataArrayJ);
+ return NULL;
+ }
+
return mixerDataArrayJ;
}
@@ -992,8 +1025,13 @@ json_object *HalUtGetJsonArrayForAllHalMapControls(afb_api_t apiHandle, struct c
return NULL;
}
- if(! halMapListHead || cds_list_empty(halMapListHead)) {
- AFB_API_ERROR(apiHandle, "HalMap data list is empty");
+ if(! halMapListHead) {
+ AFB_API_ERROR(apiHandle, "HalMap data list is not valid");
+ return NULL;
+ }
+
+ if(cds_list_empty(halMapListHead)) {
+ AFB_API_INFO(apiHandle, "HalMap data list is empty");
return NULL;
}
@@ -1014,6 +1052,12 @@ json_object *HalUtGetJsonArrayForAllHalMapControls(afb_api_t apiHandle, struct c
json_object_array_add(halMapDataArrayJ, currentHalMapDataJ);
}
+ if(! json_object_array_length(halMapDataArrayJ)) {
+ AFB_API_ERROR(apiHandle, "No HalMap info returned but list is not empty");
+ json_object_put(halMapDataArrayJ);
+ return NULL;
+ }
+
return halMapDataArrayJ;
}
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h
index 5677dac..fe55495 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h
@@ -194,6 +194,10 @@ int HalUtlRemoveSelectedHalMapData(struct cds_list_head *halMapListHead,
struct InternalHalAlsaMap *halMapDataToRemove);
int HalUtlRemoveAllHalMapData(struct cds_list_head *halMapListHead);
int HalUtlGetNumberOfHalMapDataInList(struct cds_list_head *halMapListHead);
+json_object *HalUtlGetJsonForSpecificDependenciesUsingUid(afb_api_t apiHandle,
+ struct cds_list_head *probedDevicesListHead,
+ char *uid,
+ enum DependencyInfoJsonFormat jsonFormat);
json_object *HalUtGetJsonArrayForSpecificHalMapControl(afb_api_t apiHandle,
struct InternalHalAlsaMap *currentHalMapData);
json_object *HalUtGetJsonArrayForAllHalMapControls(afb_api_t apiHandle, struct cds_list_head *halMapListHead);
diff --git a/src/4a-internals-hal/4a-internals-hal-cb.c b/src/4a-internals-hal/4a-internals-hal-cb.c
index 71bf464..cc8fea5 100644
--- a/src/4a-internals-hal/4a-internals-hal-cb.c
+++ b/src/4a-internals-hal/4a-internals-hal-cb.c
@@ -1276,8 +1276,6 @@ int InternalHalHalDependenciesConfig(afb_api_t apiHandle, CtlSectionT *section,
void InternalHalInfo(afb_req_t request)
{
- int wrapRet;
-
char *apiToCall, *returnedError = NULL, *returnedInfo = NULL;
afb_api_t apiHandle;
@@ -1334,40 +1332,28 @@ void InternalHalInfo(afb_req_t request)
return;
}
- dependenciesArray = HalUtlGetJsonArrayForAvailableDependencies(apiHandle,
- &currentHalData->internalHalData->probedDevicesListHead,
- DEPENDENCY_FULL_JSON);
- if(! dependenciesArray) {
- afb_req_fail(request, "dependencies_data", "Didn't succeed to generate dependencies data array");
- return;
- }
+ requestAnswer = json_object_new_object();
+
+ dependenciesArray = HalUtlGetJsonArrayForAllDependencies(apiHandle,
+ &currentHalData->internalHalData->probedDevicesListHead,
+ DEPENDENCY_FULL_JSON);
+ if(dependenciesArray)
+ json_object_object_add(requestAnswer, "dependencies", dependenciesArray);
streamsArray = HalUtlGetJsonArrayForAllMixersData(apiHandle,
&currentHalData->internalHalData->streamsDataListHead);
- if(! streamsArray) {
- afb_req_fail(request, "streams_data", "Didn't succeed to generate streams data array");
- return;
- }
+ if(! streamsArray)
+ streamsArray = json_object_new_array(); // Always return an array for 4a-hl-api (to prevent segfault)
+ json_object_object_add(requestAnswer, "streams", streamsArray);
controlsArray = HalUtGetJsonArrayForAllHalMapControls(apiHandle,
&currentHalData->internalHalData->halMapListHead);
- if(! controlsArray) {
- afb_req_fail(request, "controls_data", "Didn't succeed to generate controls data array");
- return;
- }
+ if(controlsArray)
+ json_object_object_add(requestAnswer, "controls", controlsArray);
- wrapRet = wrap_json_pack(&requestAnswer,
- "{s:o s:o s:o}",
- "streams", streamsArray,
- "controls", controlsArray,
- "dependencies", dependenciesArray);
- if(wrapRet) {
- afb_req_fail(request,
- "halinfo_json_object",
- "Didn't succeed to allocate hal info response json object");
- json_object_put(streamsArray);
- json_object_put(controlsArray);
- return;
+ if(! json_object_get_object(requestAnswer)->count) {
+ json_object_put(requestAnswer);
+ requestAnswer = NULL;
}
afb_req_success(request, requestAnswer, "Requested data");