From 577e61ca8243f898824618ef7c1b37994ca30cdb Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 20 Jan 2021 13:06:27 -0500 Subject: [PATCH] cwAudioDeviceAlsa.cpp : Added calls to snd_config_update_free_global() to prevent memory leaks from showing up in valgrind. --- cwAudioDeviceAlsa.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cwAudioDeviceAlsa.cpp b/cwAudioDeviceAlsa.cpp index 771dec1..4214450 100644 --- a/cwAudioDeviceAlsa.cpp +++ b/cwAudioDeviceAlsa.cpp @@ -320,6 +320,7 @@ namespace cw if((err = snd_pcm_close(pcmH)) < 0) _alsaSetupError(err,inputFl,drp,"Error closing PCM handle"); + } } } @@ -411,6 +412,9 @@ namespace cw p->devAllocCnt = 0; p->devCnt = 0; + //https://stackoverflow.com/questions/13478861/alsa-mem-leak + snd_config_update_free_global(); + mem::release(p); return rc; @@ -970,8 +974,7 @@ namespace cw if((err = snd_pcm_open(&pcmH,drp->nameStr, inputFl ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, 0)) < 0 ) rc = _alsaSetupError(err,inputFl,drp,"Unable to open the PCM handle"); else - { - + { snd_pcm_hw_params_t* hwParams; snd_pcm_sw_params_t* swParams; @@ -1602,6 +1605,7 @@ cw::rc_t cw::audio::device::alsa::report( handle_t h ) _devReport(p->devArray + i ); } + //https://stackoverflow.com/questions/13478861/alsa-mem-leak snd_config_update_free_global(); return kOkRC;