diff options
author | Eric Wong <normalperson@yhbt.net> | 2006-07-17 01:28:38 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2006-07-17 01:28:38 +0000 |
commit | 5f508702229febe6c042de2d4fe6d23b855cd410 (patch) | |
tree | 17f081fcfc0ba3c5cbde288aff5a44a83652b937 /src | |
parent | 368034e1995e8cb27b96f98df0fe07542f446023 (diff) | |
download | mpd-5f508702229febe6c042de2d4fe6d23b855cd410.tar.gz mpd-5f508702229febe6c042de2d4fe6d23b855cd410.tar.xz mpd-5f508702229febe6c042de2d4fe6d23b855cd410.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/audioOutputs/audioOutput_alsa.c | 2 | ||||
-rw-r--r-- | src/volume.c | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index 351647ace..5150dd502 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -106,6 +106,7 @@ static int alsa_testDefault(void) int ret = snd_pcm_open(&handle, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); + snd_config_update_free_global(); if(ret) { WARNING("Error opening default alsa device: %s\n", @@ -152,6 +153,7 @@ static int alsa_openDevice(AudioOutput * audioOutput) err = snd_pcm_open(&ad->pcmHandle, ad->device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); + snd_config_update_free_global(); if(err < 0) { ad->pcmHandle = NULL; goto error; diff --git a/src/volume.c b/src/volume.c index b22d29e68..dca8f5115 100644 --- a/src/volume.c +++ b/src/volume.c @@ -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; } |