From 509c14ede44b5d95f5ecc7d1e78a2c54609688e4 Mon Sep 17 00:00:00 2001 From: Jonathan Aillet Date: Thu, 31 May 2018 16:39:56 +0200 Subject: Store uid of the hal mixer configuration and use it Stores uid of the hal mixer configuration in the specific controller hal structure. Use this uid as prefix when calling softmixer api. Change-Id: Iab00518e02e0f9ff6dbd78c126eda45225c55256 Signed-off-by: Jonathan Aillet --- 4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c | 25 +++++++++++++++-------- 4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h | 3 --- 4a-hal/4a-hal-utilities/4a-hal-utilities-data.h | 1 + 3 files changed, 18 insertions(+), 11 deletions(-) (limited to '4a-hal') 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 317f0b3..30f89ba 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c @@ -64,9 +64,12 @@ int HalCtlsHalMixerConfig(afb_dynapi *apiHandle, CtlSectionT *section, json_obje if(wrap_json_unpack(MixerJ, "{s:s}", "mixerapi", ¤tHalData->ctlHalSpecificData->mixerApiName)) return -5; - if(! json_object_object_get_ex(MixerJ, "streams", &streamsArray)) + if(wrap_json_unpack(MixerJ, "{s:s}", "uid", ¤tHalData->ctlHalSpecificData->halSoftMixerVerb)) return -6; + if(! json_object_object_get_ex(MixerJ, "streams", &streamsArray)) + return -7; + switch(json_object_get_type(streamsArray)) { case json_type_object: streamCount = 1; @@ -75,7 +78,7 @@ int HalCtlsHalMixerConfig(afb_dynapi *apiHandle, CtlSectionT *section, json_obje streamCount = json_object_array_length(streamsArray); break; default: - return -7; + return -8; } currentHalData->ctlHalSpecificData->ctlHalStreamsData.count = streamCount; @@ -93,7 +96,7 @@ int HalCtlsHalMixerConfig(afb_dynapi *apiHandle, CtlSectionT *section, json_obje currentStream = streamsArray; if(wrap_json_unpack(currentStream, "{s:s}", "uid", ¤tStreamName)) - return -9-idx; + return -10-idx; currentHalData->ctlHalSpecificData->ctlHalStreamsData.data[idx].name = strdup(currentStreamName); currentHalData->ctlHalSpecificData->ctlHalStreamsData.data[idx].cardId = NULL; @@ -104,7 +107,7 @@ int HalCtlsHalMixerConfig(afb_dynapi *apiHandle, CtlSectionT *section, json_obje } if(HalUtlLoadVerbs(apiHandle, CtlHalDynApiStreamVerbs)) - return -8; + return -9; } return 0; @@ -126,7 +129,7 @@ void HalCtlsActionOnStream(afb_request *request) { int verbToCallSize; - char *apiToCall, *verbToCall; + char *apiToCall, *halSoftMixerVerb, *verbToCall; afb_dynapi *apiHandle; CtlConfigT *ctrlConfig; @@ -165,15 +168,21 @@ void HalCtlsActionOnStream(afb_request *request) return; } + halSoftMixerVerb = currentCtlHalData->ctlHalSpecificData->halSoftMixerVerb; + if(! halSoftMixerVerb) { + afb_request_fail(request, "hal_softmixer_verb", "Can't get hal mixer verb prefix"); + return; + } + // TODO JAI: check status of hal before doing anything - // TODO JAI : remove action prefix, streams should be created as verb by mixer - verbToCallSize = (int) strlen(API_STREAM_PREFIX) + (int) strlen(request->verb) + 2; + // TODO JAI : remove verb to call prefix, each hal should have its own api in softmixer, and each streams should be created as verb by mixer + verbToCallSize = (int) strlen(halSoftMixerVerb) + (int) strlen(request->verb) + 2; verbToCall = (char *) alloca(verbToCallSize * sizeof(char)); verbToCall[0] = '\0'; verbToCall[verbToCallSize - 1] = '\0'; - strcat(verbToCall, API_STREAM_PREFIX); + strcat(verbToCall, halSoftMixerVerb); strcat(verbToCall, "/"); strcat(verbToCall, request->verb); diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h index 8238c37..e6c7dfd 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.h @@ -25,9 +25,6 @@ #include -// TODO JAI: remove this define -#define API_STREAM_PREFIX "simple_mixer" - // HAL controllers sections parsing functions int HalCtlsHalMixerConfig(afb_dynapi *apiHandle, CtlSectionT *section, json_object *MixerJ); int HalCtlsHalMapConfig(afb_dynapi *apiHandle, CtlSectionT *section, json_object *StreamControlsJ); diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h index f9b9b36..1d15785 100644 --- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h +++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h @@ -45,6 +45,7 @@ struct CtlHalStreamsDataT { struct CtlHalSpecificData { char *mixerApiName; + char *halSoftMixerVerb; json_object *halMixerJ; struct CtlHalStreamsDataT ctlHalStreamsData; -- cgit 1.2.3-korg