summaryrefslogtreecommitdiffstats
path: root/src/4a-internals-hal
diff options
context:
space:
mode:
Diffstat (limited to 'src/4a-internals-hal')
-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
5 files changed, 24 insertions, 65 deletions
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);