alsa: fix memory leaks from snd_*_open*()

ALSA uses a global config structure that's overwritten (and not
free'd) every time one of those functions is called, so we have
to manually call snd_config_update_free_global() to release it.

Hint taken from MEMORY-LEAK in the ALSA source code

git-svn-id: https://svn.musicpd.org/mpd/trunk@4381 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Eric Wong
2006-07-17 01:28:38 +00:00
parent 368034e199
commit 5f50870222
2 changed files with 5 additions and 1 deletions
+3 -1
View File
@@ -214,7 +214,9 @@ static int prepAlsaMixer(char * card) {
char * controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT;
ConfigParam * param;
if((err = snd_mixer_open(&volume_alsaMixerHandle,0))<0) {
err = snd_mixer_open(&volume_alsaMixerHandle,0);
snd_config_update_free_global();
if (err < 0) {
WARNING("problems opening alsa mixer: %s\n",snd_strerror(err));
return -1;
}