diff options
Diffstat (limited to '4a-hal')
3 files changed, 28 insertions, 2 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c index a26fe0a..8f2f418 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c @@ -65,10 +65,31 @@ snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label) } /******************************************************************************* - * TODO JAI : add function to free 'CtlHalAlsaMapT' * + * Free contents of 'CtlHalAlsaMapT' data structure * ******************************************************************************/ +uint8_t HalCtlsFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap) +{ + int idx; + + if(! alsaCtlsMap) + return -1; + + if(alsaCtlsMap->ctlsCount > 0 && ! alsaCtlsMap->ctls) + return -2; + for(idx = 0; idx < alsaCtlsMap->ctlsCount; idx++) { + free(alsaCtlsMap->ctls[idx].action); + free(alsaCtlsMap->ctls[idx].ctl.alsaCtlProperties.enums); + free(alsaCtlsMap->ctls[idx].ctl.alsaCtlProperties.dbscale); + } + + free(alsaCtlsMap->ctls); + + free(alsaCtlsMap); + + return 0; +} /******************************************************************************* * HAL controllers alsacore calls funtions * diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h index 1776c80..d2749a1 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h @@ -49,7 +49,7 @@ struct CtlHalAlsaCtlProperties { int step; // TBD JAI : use them const char **enums; - struct CtlHalAlsaDBScale dbscale; + struct CtlHalAlsaDBScale *dbscale; }; struct CtlHalAlsaCtl { @@ -76,6 +76,9 @@ struct CtlHalAlsaMapT { // Alsa control types map from string function snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label); +// Free contents of 'CtlHalAlsaMapT' data structure +uint8_t HalCtlsFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap); + // HAL controllers alsacore calls funtions int HalCtlsGetCardIdByCardPath(AFB_ApiT apiHandle, char *devPath); int HalCtlsSubscribeToAlsaCardEvent(AFB_ApiT apiHandle, char *cardId); diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c index d2b9104..335a8b7 100644 --- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c +++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c @@ -122,6 +122,8 @@ uint8_t HalUtlRemoveSelectedHalFromList(struct HalMgrData *HalMgrGlobalData, str else { HalUtlRemoveAllCtlHalStreamsData(&matchingApi->ctlHalSpecificData->ctlHalStreamsData); + HalCtlsFreeAlsaCtlsMap(matchingApi->ctlHalSpecificData->ctlHalAlsaMapT); + free(matchingApi->ctlHalSpecificData); } |