summaryrefslogtreecommitdiffstats
path: root/4a-hal
diff options
context:
space:
mode:
Diffstat (limited to '4a-hal')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c2
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c96
2 files changed, 77 insertions, 21 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
index 0c2a95d..390431e 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
@@ -61,7 +61,7 @@ static CtlSectionT ctrlSectionsDefault[] =
static AFB_ApiVerbs CtlHalApiStaticVerbs[] =
{
/* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
- { .verb = "info", .callback = HalCtlsInfo, .info = "List available streams/playbacks/captures... for this api" },
+ { .verb = "info", .callback = HalCtlsInfo, .info = "List available streams/playbacks/captures/controls for this api" },
{ .verb = NULL } // Marker for end of the array
};
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
index b9ba537..ca3ba6b 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c
@@ -489,18 +489,26 @@ json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct Ctl
}
for(idx = 0; idx < currentMixerDataT->count; idx++) {
- if(dataType == MIXER_DATA_STREAMS) {
- wrap_json_pack(&currentMixerData,
- "{s:s s:s}",
- "name", currentMixerDataT->data[idx].verb,
- "cardId", currentMixerDataT->data[idx].streamCardId);
- }
- else {
- wrap_json_pack(&currentMixerData,
- "{s:s s:s}",
- "name", currentMixerDataT->data[idx].verb,
- "mixer-name", currentMixerDataT->data[idx].verbToCall,
- "uid", currentMixerDataT->data[idx].streamCardId ? currentMixerDataT->data[idx].streamCardId : "none");
+ switch(dataType) {
+ case MIXER_DATA_STREAMS:
+ wrap_json_pack(&currentMixerData,
+ "{s:s s:s}",
+ "name", currentMixerDataT->data[idx].verb,
+ "cardId", currentMixerDataT->data[idx].streamCardId);
+ break;
+
+ case MIXER_DATA_PLAYBACKS:
+ case MIXER_DATA_CAPTURES :
+ wrap_json_pack(&currentMixerData,
+ "{s:s s:s}",
+ "name", currentMixerDataT->data[idx].verb,
+ "mixer-name", currentMixerDataT->data[idx].verbToCall,
+ "uid", currentMixerDataT->data[idx].streamCardId ? currentMixerDataT->data[idx].streamCardId : "none");
+ break;
+
+ default:
+ json_object_put(mixerDataArray);
+ return NULL;
}
json_object_array_add(mixerDataArray, currentMixerData);
}
@@ -508,6 +516,40 @@ json_object *HalCtlsGetJsonArrayForMixerDataTable(AFB_ApiT apiHandle, struct Ctl
return mixerDataArray;
}
+json_object *HalCtlsGetJsonArrayForControls(AFB_ApiT apiHandle, struct CtlHalAlsaMapT *currentAlsaMapDataT)
+{
+ unsigned int idx;
+
+ json_object *alsaMapDataArray, *currentAlsaMapData;
+
+ if(! apiHandle) {
+ AFB_ApiError(apiHandle, "Can't get current hal controller api handle");
+ return NULL;
+ }
+
+ if(! currentAlsaMapDataT) {
+ AFB_ApiError(apiHandle, "Can't get Alsa map data table to handle");
+ return NULL;
+ }
+
+ alsaMapDataArray = json_object_new_array();
+ if(! alsaMapDataArray) {
+ AFB_ApiError(apiHandle, "Can't generate json mixer data array");
+ return NULL;
+ }
+
+ for(idx = 0; idx < currentAlsaMapDataT->ctlsCount; idx++) {
+ wrap_json_pack(&currentAlsaMapData,
+ "{s:s s:s}",
+ "name", currentAlsaMapDataT->ctls[idx].uid,
+ "info", currentAlsaMapDataT->ctls[idx].info ? currentAlsaMapDataT->ctls[idx].info : "none");
+
+ json_object_array_add(alsaMapDataArray, currentAlsaMapData);
+ }
+
+ return alsaMapDataArray;
+}
+
void HalCtlsInfo(AFB_ReqT request)
{
char *apiToCall, *returnedStatus = NULL, *returnedInfo = NULL;
@@ -517,7 +559,7 @@ void HalCtlsInfo(AFB_ReqT request)
struct SpecificHalData *currentCtlHalData;
- json_object *requestJson, *toReturnJ = NULL, *requestAnswer, *streamsArray, *playbacksArray, *capturesArray;
+ json_object *requestJson, *toReturnJ = NULL, *requestAnswer, *streamsArray, *playbacksArray, *capturesArray, *controlsArray;
apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
if(! apiHandle) {
@@ -566,25 +608,39 @@ void HalCtlsInfo(AFB_ReqT request)
return;
}
- streamsArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle, &currentCtlHalData->ctlHalSpecificData->ctlHalStreamsData, MIXER_DATA_STREAMS);
- if(! streamsArray) {
+ if(! (streamsArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle,
+ &currentCtlHalData->ctlHalSpecificData->ctlHalStreamsData,
+ MIXER_DATA_STREAMS))) {
AFB_ReqFail(request, "streams_data", "Didn't succeed to generate streams data array");
return;
}
- playbacksArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle, &currentCtlHalData->ctlHalSpecificData->ctlHalPlaybacksData, MIXER_DATA_PLAYBACKS);
- if(! playbacksArray) {
+ if(! (playbacksArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle,
+ &currentCtlHalData->ctlHalSpecificData->ctlHalPlaybacksData,
+ MIXER_DATA_PLAYBACKS))) {
AFB_ReqFail(request, "playbacks_data", "Didn't succeed to generate playbacks data array");
return;
}
- capturesArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle, &currentCtlHalData->ctlHalSpecificData->ctlHalCapturesData, MIXER_DATA_CAPTURES);
- if(! capturesArray) {
+ if(! (capturesArray = HalCtlsGetJsonArrayForMixerDataTable(apiHandle,
+ &currentCtlHalData->ctlHalSpecificData->ctlHalCapturesData,
+ MIXER_DATA_CAPTURES))) {
AFB_ReqFail(request, "captures_data", "Didn't succeed to generate captures data array");
return;
}
- wrap_json_pack(&requestAnswer, "{s:o s:o s:o}", "streams", streamsArray, "playbacks", playbacksArray, "captures", capturesArray);
+ if(! (controlsArray = HalCtlsGetJsonArrayForControls(apiHandle,
+ currentCtlHalData->ctlHalSpecificData->ctlHalAlsaMapT))) {
+ AFB_ReqFail(request, "controls_data", "Didn't succeed to generate controls data array");
+ return;
+ }
+
+ wrap_json_pack(&requestAnswer,
+ "{s:o s:o s:o s:o}",
+ "streams", streamsArray,
+ "playbacks", playbacksArray,
+ "captures", capturesArray,
+ "controls", controlsArray);
AFB_ReqSuccess(request, requestAnswer, "Requested data");
} \ No newline at end of file