aboutsummaryrefslogtreecommitdiffstats
path: root/4a-hal
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-09 18:01:22 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:52:51 +0200
commit22069b25c077945dce04cc4ed37b0ab9581b204d (patch)
tree07c2711128d43b6b85535edc16574f8afb9582ec /4a-hal
parentbf9611f54cc183d6a7d61d0e4754de963c154d3a (diff)
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 <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal')
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-handler.c22
1 files 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 <stdbool.h>
#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__);