From 22069b25c077945dce04cc4ed37b0ab9581b204d Mon Sep 17 00:00:00 2001 From: Jonathan Aillet Date: Sat, 9 Jun 2018 18:01:22 +0200 Subject: Add search for a concurent hal at mixer attach At hal mixer attach, add search for an already ready hal using the same alsa audio device id. If this concurent hal exists, return an error. Change-Id: Ia17738fe87c7bc82fa1867ecd031dd07ffa73714 Signed-off-by: Jonathan Aillet --- .../4a-hal-controllers-mixer-handler.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.c index 93901a4..924054b 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.c @@ -22,8 +22,11 @@ #include #include "../4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h" +#include "../4a-hal-utilities/4a-hal-utilities-data.h" #include "../4a-hal-utilities/4a-hal-utilities-verbs-loader.h" +#include "../4a-hal-manager/4a-hal-manager.h" + #include "4a-hal-controllers-mixer-handler.h" #include "4a-hal-controllers-cb.h" @@ -108,7 +111,8 @@ int HalCtlsAttachToMixer(AFB_ApiT apiHandle) CtlConfigT *ctrlConfig; - struct SpecificHalData *currentCtlHalData; + struct SpecificHalData *currentCtlHalData, *concurentHalData = NULL; + struct SpecificHalData **firstHalData; json_object *returnJ, *toReturnJ; @@ -124,16 +128,28 @@ int HalCtlsAttachToMixer(AFB_ApiT apiHandle) return -2; } + // TODO JAI : add a test to see if the hal card id is already used + firstHalData = HalMngGetFirstHalData(); + if((concurentHalData = HalUtlSearchReadyHalDataByCarId(firstHalData, currentCtlHalData->sndCardId))) { + AFB_ApiError(apiHandle, + "%s: trying to attach mixer for hal '%s' but the alsa device %i is already in use with mixer by hal '%s'", + __func__, + currentCtlHalData->apiName, + currentCtlHalData->sndCardId, + concurentHalData->apiName); + return -3; + } + apiToCall = currentCtlHalData->ctlHalSpecificData->mixerApiName; if(! apiToCall) { AFB_ApiError(apiHandle, "%s: Can't get mixer api", __func__); - return -3; + return -4; } switch(currentCtlHalData->status) { case HAL_STATUS_UNAVAILABLE: AFB_ApiError(apiHandle, "%s: Seems that the hal corresponding card was not found by alsacore at startup", __func__); - return -4; + return -5; case HAL_STATUS_READY: AFB_ApiNotice(apiHandle, "%s: Seems that the hal mixer is already initialized", __func__); -- cgit 1.2.3-korg