summaryrefslogtreecommitdiffstats
path: root/lib/4a-hal-utilities
diff options
context:
space:
mode:
Diffstat (limited to 'lib/4a-hal-utilities')
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.c118
1 files changed, 89 insertions, 29 deletions
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c
index 3ac2a7c..6121b33 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c
@@ -238,6 +238,24 @@ int HalUtlIsDependencySelected(struct InternalHalProbedDevice *probedDevice, enu
}
}
+void HalUtlFreeSelectedProbedDeviceDataAllocation(struct InternalHalDeviceData *probedDeviceDataToFree)
+{
+ if(! probedDeviceDataToFree)
+ return;
+
+ free(probedDeviceDataToFree->extendedCardNb);
+ free(probedDeviceDataToFree->cardId);
+ free(probedDeviceDataToFree->cardShortName);
+ free(probedDeviceDataToFree->cardLongName);
+ free(probedDeviceDataToFree->cardDriver);
+ free(probedDeviceDataToFree->cardMixerName);
+ free(probedDeviceDataToFree->cardComponents);
+ free(probedDeviceDataToFree->playbackDeviceId);
+ free(probedDeviceDataToFree->playbackDeviceName);
+
+ free(probedDeviceDataToFree);
+}
+
void HalUtlFreeSelectedProbedDeviceAllocation(struct InternalHalProbedDevice *probedDeviceToFree)
{
if(! probedDeviceToFree)
@@ -245,19 +263,7 @@ void HalUtlFreeSelectedProbedDeviceAllocation(struct InternalHalProbedDevice *pr
free(probedDeviceToFree->uid);
- if(probedDeviceToFree->deviceData) {
- free(probedDeviceToFree->deviceData->extendedCardNb);
- free(probedDeviceToFree->deviceData->cardId);
- free(probedDeviceToFree->deviceData->cardShortName);
- free(probedDeviceToFree->deviceData->cardLongName);
- free(probedDeviceToFree->deviceData->cardDriver);
- free(probedDeviceToFree->deviceData->cardMixerName);
- free(probedDeviceToFree->deviceData->cardComponents);
- free(probedDeviceToFree->deviceData->playbackDeviceId);
- free(probedDeviceToFree->deviceData->playbackDeviceName);
-
- free(probedDeviceToFree->deviceData);
- }
+ HalUtlFreeSelectedProbedDeviceDataAllocation(probedDeviceToFree->deviceData);
if(probedDeviceToFree->requestedDeviceJ)
json_object_put(probedDeviceToFree->requestedDeviceJ);
@@ -318,6 +324,15 @@ struct InternalHalDeviceData *HalUtlAllocateAndFillProbedDeviceDataUsingInfoGetR
{
struct InternalHalDeviceData *currentProbedDeviceData;
+ char *cardId,
+ *cardShortName,
+ *cardLongName,
+ *cardDriver,
+ *cardMixerName,
+ *cardComponents,
+ *playbackDeviceId = NULL,
+ *playbackDeviceName = NULL;
+
if(! responseJ)
return NULL;
@@ -330,15 +345,15 @@ struct InternalHalDeviceData *HalUtlAllocateAndFillProbedDeviceDataUsingInfoGetR
if(wrap_json_unpack(responseJ, "{s:i, s:s, s:s, s:s, s:s, s:s, s:s, s?:i, s?:s, s?:s !}",
"cardNb", &currentProbedDeviceData->cardNb,
- "cardId", &currentProbedDeviceData->cardId,
- "cardShortName", &currentProbedDeviceData->cardShortName,
- "cardLongName", &currentProbedDeviceData->cardLongName,
- "cardDriver", &currentProbedDeviceData->cardDriver,
- "cardMixerName", &currentProbedDeviceData->cardMixerName,
- "cardComponents", &currentProbedDeviceData->cardComponents,
+ "cardId", &cardId,
+ "cardShortName", &cardShortName,
+ "cardLongName", &cardLongName,
+ "cardDriver", &cardDriver,
+ "cardMixerName", &cardMixerName,
+ "cardComponents", &cardComponents,
"playbackDeviceNb", &currentProbedDeviceData->playbackDeviceNb,
- "playbackDeviceId", &currentProbedDeviceData->playbackDeviceId,
- "playbackDeviceName", &currentProbedDeviceData->playbackDeviceName) ||
+ "playbackDeviceId", &playbackDeviceId,
+ "playbackDeviceName", &playbackDeviceName) ||
currentProbedDeviceData->cardNb == HAL_UNKNOWN_DEVICE ||
(currentProbedDeviceData->playbackDeviceNb == HAL_UNKNOWN_DEVICE &&
asprintf(&currentProbedDeviceData->extendedCardNb, "hw:%i", currentProbedDeviceData->cardNb) < 0) ||
@@ -346,10 +361,62 @@ struct InternalHalDeviceData *HalUtlAllocateAndFillProbedDeviceDataUsingInfoGetR
asprintf(&currentProbedDeviceData->extendedCardNb, "hw:%i,%i",
currentProbedDeviceData->cardNb,
currentProbedDeviceData->playbackDeviceNb) < 0)) {
- free(currentProbedDeviceData);
+ HalUtlFreeSelectedProbedDeviceDataAllocation(currentProbedDeviceData);
+ return NULL;
+ }
+
+ currentProbedDeviceData->cardId = strdup(cardId);
+ if(! currentProbedDeviceData->cardId) {
+ HalUtlFreeSelectedProbedDeviceDataAllocation(currentProbedDeviceData);
+ return NULL;
+ }
+
+ currentProbedDeviceData->cardShortName = strdup(cardShortName);
+ if(! currentProbedDeviceData->cardShortName) {
+ HalUtlFreeSelectedProbedDeviceDataAllocation(currentProbedDeviceData);
+ return NULL;
+ }
+
+ currentProbedDeviceData->cardLongName = strdup(cardLongName);
+ if(! currentProbedDeviceData->cardLongName) {
+ HalUtlFreeSelectedProbedDeviceDataAllocation(currentProbedDeviceData);
return NULL;
}
+ currentProbedDeviceData->cardDriver = strdup(cardDriver);
+ if(! currentProbedDeviceData->cardDriver) {
+ HalUtlFreeSelectedProbedDeviceDataAllocation(currentProbedDeviceData);
+ return NULL;
+ }
+
+ currentProbedDeviceData->cardMixerName = strdup(cardMixerName);
+ if(! currentProbedDeviceData->cardMixerName) {
+ HalUtlFreeSelectedProbedDeviceDataAllocation(currentProbedDeviceData);
+ return NULL;
+ }
+
+ currentProbedDeviceData->cardComponents = strdup(cardComponents);
+ if(! currentProbedDeviceData->cardComponents) {
+ HalUtlFreeSelectedProbedDeviceDataAllocation(currentProbedDeviceData);
+ return NULL;
+ }
+
+ if(playbackDeviceId) {
+ currentProbedDeviceData->playbackDeviceId = strdup(playbackDeviceId);
+ if(! currentProbedDeviceData->playbackDeviceId) {
+ HalUtlFreeSelectedProbedDeviceDataAllocation(currentProbedDeviceData);
+ return NULL;
+ }
+ }
+
+ if(playbackDeviceName) {
+ currentProbedDeviceData->playbackDeviceName = strdup(playbackDeviceName);
+ if(! currentProbedDeviceData->playbackDeviceName) {
+ HalUtlFreeSelectedProbedDeviceDataAllocation(currentProbedDeviceData);
+ return NULL;
+ }
+ }
+
return currentProbedDeviceData;
}
@@ -782,13 +849,6 @@ void HalUtlFreeSelectedHalAllocation(struct HalData *halDataToFree)
if(! halDataToFree)
return;
- free(halDataToFree->apiName);
- free(halDataToFree->sndCardPath);
- free(halDataToFree->info);
- free(halDataToFree->author);
- free(halDataToFree->version);
- free(halDataToFree->date);
-
if(halDataToFree->internal) {
free(halDataToFree->internalHalData->mixerApiName);
free(halDataToFree->internalHalData->prefix);