aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-06-24 14:43:09 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-06-26 16:52:56 +0200
commitb0f969293ff9a1391ebef68f243ee42cc776bea2 (patch)
treeb025625f4ba45effc1c57720dc22e9b9322a2cd6
parentc6cb9e4064c05ded2c52f833d5e26ab42a03d1de (diff)
As we are now using haldependencies to get hal card number(s), it does not make sense to store a global card number for a hal. BUG-AGL: SPEC-2329 Change-Id: If5beb84b71b5e5e67aeabd947b5c3edbf154fa3c Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.h2
-rw-r--r--src/4a-hal-manager/4a-hal-manager-cb.c29
-rw-r--r--src/4a-internals-hal/4a-internals-hal-alsacore-link.c51
-rw-r--r--src/4a-internals-hal/4a-internals-hal-alsacore-link.h1
-rw-r--r--src/4a-internals-hal/4a-internals-hal-api-loader.c8
-rw-r--r--src/4a-internals-hal/4a-internals-hal-cb.c28
-rw-r--r--src/4a-internals-hal/4a-internals-hal-cb.h1
7 files changed, 32 insertions, 88 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h
index bea92dd..5677dac 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h
@@ -125,8 +125,6 @@ struct InternalHalData {
struct HalData {
char *apiName;
enum HalStatus status;
- char *sndCardPath;
- int sndCardId;
char *uid;
char *info;
unsigned int internal;
diff --git a/src/4a-hal-manager/4a-hal-manager-cb.c b/src/4a-hal-manager/4a-hal-manager-cb.c
index a726d05..0768526 100644
--- a/src/4a-hal-manager/4a-hal-manager-cb.c
+++ b/src/4a-hal-manager/4a-hal-manager-cb.c
@@ -67,8 +67,6 @@ void HalMgrLoaded(afb_req_t request)
{
int requestJsonErr = 0, allHal = 0, verbose = 0, wrapRet = 0;
- char cardIdString[32];
-
afb_api_t apiHandle;
struct HalMgrData *halMgrData;
struct HalData *currentHalData;
@@ -110,10 +108,6 @@ void HalMgrLoaded(afb_req_t request)
if(allHal || currentHalData->status == HAL_STATUS_READY) {
// Case if request key is 'verbose' and value is bigger than 0
if(! requestJsonErr && verbose) {
- if(currentHalData->sndCardId >= 0)
- snprintf(cardIdString, sizeof(cardIdString), "hw:%i", currentHalData->sndCardId);
- else
- snprintf(cardIdString, sizeof(cardIdString), "not-found");
dependenciesJ = HalUtlGetJsonArrayForAllDependencies(apiHandle,
&currentHalData->internalHalData->probedDevicesListHead,
@@ -122,17 +116,15 @@ void HalMgrLoaded(afb_req_t request)
AFB_REQ_WARNING(request, "Didn't succeed to generate all dependencies compact json array");
wrapRet = wrap_json_pack(&apiRequestedInfoJ,
- "{s:s s:i s:s s:i s:s s:s s:s s:s s:s s:s s?:o}",
+ "{s:s s:i s:i s:s s:s s:s s:s s:s s?:o}",
"api", currentHalData->apiName,
"status", (int) currentHalData->status,
- "sndcard", currentHalData->sndCardPath,
"internal", (int) currentHalData->internal,
"uid", currentHalData->uid,
"info", currentHalData->info ? currentHalData->info : "",
"author", currentHalData->author ? currentHalData->author : "",
"version", currentHalData->version ? currentHalData->version : "",
"date", currentHalData->date ? currentHalData->date : "",
- "snd-dev-id", cardIdString,
"dependencies", dependenciesJ);
}
// Case if request is empty or not handled
@@ -157,9 +149,7 @@ void HalMgrLoaded(afb_req_t request)
void HalMgrLoad(afb_req_t request)
{
- int cardId = -1;
-
- char *apiName, *sndCardPath, *info = NULL, *author = NULL, *version = NULL, *date = NULL;
+ char *apiName, *uid, *info = NULL, *author = NULL, *version = NULL, *date = NULL;
afb_api_t apiHandle;
struct HalMgrData *halMgrData;
@@ -191,14 +181,13 @@ void HalMgrLoad(afb_req_t request)
}
if(wrap_json_unpack(apiReceivedMetadata,
- "{s:s s:s s?:s s?:s s?:s s?:s s?:i}",
+ "{s:s s:s s?:s s?:s s?:s s?:s}",
"api", &apiName,
- "uid", &sndCardPath,
+ "uid", &uid,
"info", &info,
"author", &author,
"version", &version,
- "date", &date,
- "snd-dev-id", &cardId)) {
+ "date", &date)) {
afb_req_fail(request, "api_metadata", "Can't metadata of api to register");
return;
}
@@ -218,11 +207,11 @@ void HalMgrLoad(afb_req_t request)
return;
}
- addedHal->sndCardPath = strdup(sndCardPath);
- if(! addedHal->sndCardPath) {
+ addedHal->uid = strdup(uid);
+ if(! addedHal->uid) {
afb_req_fail(request,
"sndcardpath_string_allocation",
- "Didn't succeed to store (allocate) 'sndCardPath' string");
+ "Didn't succeed to store (allocate) 'uid' string");
HalUtlRemoveSelectedHalFromList(&halMgrData->halDataListHead, addedHal);
return;
}
@@ -271,8 +260,6 @@ void HalMgrLoad(afb_req_t request)
}
}
- addedHal->sndCardId = cardId;
-
// TBD JAI: add subscription to this api status events, if subscription fails, remove hal from list
afb_req_success(request, NULL, "Api successfully registered");
diff --git a/src/4a-internals-hal/4a-internals-hal-alsacore-link.c b/src/4a-internals-hal/4a-internals-hal-alsacore-link.c
index 6a56e78..130cea5 100644
--- a/src/4a-internals-hal/4a-internals-hal-alsacore-link.c
+++ b/src/4a-internals-hal/4a-internals-hal-alsacore-link.c
@@ -102,57 +102,6 @@ int InternalHalGetCardInfo(afb_api_t apiHandle, json_object *requestJ, json_obje
return errorToReturn;
}
-int InternalHalGetCardIdByCardPath(afb_api_t apiHandle, char *devPath)
-{
- int errorToReturn, cardId, wrapRet;
-
- json_object *toSendJ, *responseJ = NULL;
-
- if(! apiHandle) {
- AFB_API_ERROR(apiHandle, "Api handle not available");
- return -1;
- }
-
- if(! devPath) {
- AFB_API_ERROR(apiHandle, "Dev path is not available");
- return -2;
- }
-
- wrapRet = wrap_json_pack(&toSendJ, "{s:s}", "cardPath", devPath);
- if(wrapRet) {
- AFB_API_ERROR(apiHandle, "Didn't succeed to allocate cardpath json object (needed to search for audio card using path)");
- return -3;
- }
-
- if(InternalHalGetCardInfo(apiHandle, toSendJ, &responseJ)) {
- AFB_API_ERROR(apiHandle, "Something went tried to get card information (using devpath : '%s')", devPath);
- errorToReturn = -4;
- }
- else if(! responseJ) {
- AFB_API_ERROR(apiHandle, "Seems that no response was returned when tried to get card info");
- errorToReturn = -5;
- }
- else if(! json_object_is_type(responseJ, json_type_object)) {
- AFB_API_ERROR(apiHandle,
- "Seems that %s call to api %s succeed but the returned response is invalid",
- ALSACORE_GETINFO_VERB,
- ALSACORE_API);
- errorToReturn = -6;
- }
- else if(wrap_json_unpack(responseJ, "{s:i}", "cardNb", &cardId)) {
- AFB_API_WARNING(apiHandle, "Response card id is not present/valid");
- errorToReturn = -7;
- }
- else {
- return cardId;
- }
-
- if(responseJ)
- json_object_put(responseJ);
-
- return errorToReturn;
-}
-
int InternalHalSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId)
{
int err = 0, wrapRet;
diff --git a/src/4a-internals-hal/4a-internals-hal-alsacore-link.h b/src/4a-internals-hal/4a-internals-hal-alsacore-link.h
index 9641c7c..03af081 100644
--- a/src/4a-internals-hal/4a-internals-hal-alsacore-link.h
+++ b/src/4a-internals-hal/4a-internals-hal-alsacore-link.h
@@ -42,7 +42,6 @@ snd_ctl_elem_type_t InternalHalMapsAlsaTypeToEnum(const char *label);
// Internals HAL alsacore calls funtions
int InternalHalGetCardInfo(afb_api_t apiHandle, json_object *requestJ, json_object **responseJ);
-int InternalHalGetCardIdByCardPath(afb_api_t apiHandle, char *devPath);
int InternalHalSubscribeToAlsaCardEvent(afb_api_t apiHandle, char *cardId);
int InternalHalUpdateAlsaCtlProperties(afb_api_t apiHandle, char *cardId, struct InternalHalAlsaCtl *currentAlsaCtl);
int InternalHalSetAlsaCtlValue(afb_api_t apiHandle, char *cardId, int ctlId, json_object *valuesJ);
diff --git a/src/4a-internals-hal/4a-internals-hal-api-loader.c b/src/4a-internals-hal/4a-internals-hal-api-loader.c
index 4fffe01..34e82ef 100644
--- a/src/4a-internals-hal/4a-internals-hal-api-loader.c
+++ b/src/4a-internals-hal/4a-internals-hal-api-loader.c
@@ -89,7 +89,6 @@ static int InternalHalInitOneApi(afb_api_t apiHandle)
// Fill HalDatadata structure
currentHalData->internal = 1;
- currentHalData->sndCardPath = (char *) ctrlConfig->uid;
currentHalData->uid = (char *) ctrlConfig->uid;
currentHalData->info = (char *) ctrlConfig->info;
@@ -100,17 +99,10 @@ static int InternalHalInitOneApi(afb_api_t apiHandle)
currentHalData->internalHalData->apiHandle = apiHandle;
currentHalData->internalHalData->ctrlConfig = ctrlConfig;
- currentHalData->sndCardId = InternalHalGetCardIdByCardPath(apiHandle, currentHalData->sndCardPath);
-
currentHalData->internalHalData->streamUpdates = afb_api_make_event(apiHandle, HAL_STREAM_UPDATES_EVENT_NAME);
if(! currentHalData->internalHalData->streamUpdates)
return -4;
- if(currentHalData->sndCardId < 0)
- currentHalData->status = HAL_STATUS_UNAVAILABLE;
- else
- currentHalData->status = HAL_STATUS_AVAILABLE;
-
// TBD JAI: handle refresh of hal status for dynamic card (/dev/by-id)
err = CtlConfigExec(apiHandle, ctrlConfig);
diff --git a/src/4a-internals-hal/4a-internals-hal-cb.c b/src/4a-internals-hal/4a-internals-hal-cb.c
index 5dc0a2e..6afc965 100644
--- a/src/4a-internals-hal/4a-internals-hal-cb.c
+++ b/src/4a-internals-hal/4a-internals-hal-cb.c
@@ -1153,11 +1153,12 @@ int InternalHalHandleOneHalDependencies(afb_api_t apiHandle, struct InternalHalP
}
int InternalHalHandleHalDependencies(afb_api_t apiHandle,
+ struct HalData *currentHalData,
struct cds_list_head *halDevicesToProbeListHead,
enum DependenciesHandlingType dependenciesHandlingType,
char *uid)
{
- int ret, validatedDepedency;
+ int ret, validatedDepedency, validatedDependenciesNumber = 0;
struct InternalHalProbedDevice *halCurrentDeviceToProbe;
@@ -1206,6 +1207,14 @@ int InternalHalHandleHalDependencies(afb_api_t apiHandle,
return -4;
}
+ if(ret > 0)
+ AFB_API_INFO(apiHandle,
+ "Didn't succeed to identifiate a unique device, uid:'%s' and request:'%s'",
+ halCurrentDeviceToProbe->uid,
+ json_object_get_string(halCurrentDeviceToProbe->requestedDeviceJ));
+ else
+ validatedDependenciesNumber++;
+
if(halCurrentDeviceToProbe->deviceClass == MANDATORY_PROBED_DEVICE &&
! halCurrentDeviceToProbe->deviceData) {
AFB_API_WARNING(apiHandle,
@@ -1217,12 +1226,21 @@ int InternalHalHandleHalDependencies(afb_api_t apiHandle,
}
}
- return 0;
+ if(validatedDependenciesNumber)
+ currentHalData->status = HAL_STATUS_AVAILABLE;
+
+ return validatedDependenciesNumber;
}
-int InternalHalHandleAllHalDependencies(afb_api_t apiHandle, struct cds_list_head *halDevicesToProbeListHead)
+int InternalHalHandleAllHalDependencies(afb_api_t apiHandle, struct HalData *currentHalData, struct cds_list_head *halDevicesToProbeListHead)
{
- return InternalHalHandleHalDependencies(apiHandle, halDevicesToProbeListHead, ALL_DEPENDENCIES, NULL);
+ int returned;
+
+ returned = InternalHalHandleHalDependencies(apiHandle, currentHalData, halDevicesToProbeListHead, ALL_DEPENDENCIES, NULL);
+ if(returned < 0)
+ return returned;
+
+ return 0;
}
int InternalHalHalDependenciesConfig(afb_api_t apiHandle, CtlSectionT *section, json_object *DependenciesJ)
@@ -1244,7 +1262,7 @@ int InternalHalHalDependenciesConfig(afb_api_t apiHandle, CtlSectionT *section,
return -3;
}
else if(! DependenciesJ &&
- (InternalHalHandleAllHalDependencies(apiHandle, &currentHalData->internalHalData->probedDevicesListHead)) < 0) {
+ (InternalHalHandleAllHalDependencies(apiHandle, currentHalData, &currentHalData->internalHalData->probedDevicesListHead)) < 0) {
AFB_API_ERROR(apiHandle, "Failed to handle 'haldependencies' section");
return -4;
}
diff --git a/src/4a-internals-hal/4a-internals-hal-cb.h b/src/4a-internals-hal/4a-internals-hal-cb.h
index 671abbb..4864d46 100644
--- a/src/4a-internals-hal/4a-internals-hal-cb.h
+++ b/src/4a-internals-hal/4a-internals-hal-cb.h
@@ -47,6 +47,7 @@ int InternalHalHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_obje
// Internals HAL - 'haldependencies' section parsing/handling functions
int InternalHalHandleHalDependencies(afb_api_t apiHandle,
+ struct HalData *currentHalData,
struct cds_list_head *halDevicesToProbeListHead,
enum DependenciesHandlingType dependenciesHandlingType,
char *uid);