diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-09-07 22:20:02 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-07 22:25:01 -0700 |
commit | ee548be22b81f5ff920ae008957b2d7208fb6dac (patch) | |
tree | 33f080270862ef73f5da565886ddf17bd3bb10f7 | |
parent | 544efdf5aaaf4b77f44f250b4dbfdd3ed0c87a4c (diff) | |
download | mpd-ee548be22b81f5ff920ae008957b2d7208fb6dac.tar.gz mpd-ee548be22b81f5ff920ae008957b2d7208fb6dac.tar.xz mpd-ee548be22b81f5ff920ae008957b2d7208fb6dac.zip |
alsa: only run snd_config_update_free_global once atexit
This is safer than the patch in
http://www.musicpd.org/mantis/view.php?id=1542
with multiple audio outputs enabled.
Sadly, I only noticed that patch/problem when I googled for
"snd_config_update_free_global"
-rw-r--r-- | src/audioOutputs/audioOutput_alsa.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index ef4ae54ff..013dd70cb 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -89,8 +89,15 @@ static void freeAlsaData(AlsaData * ad) static int alsa_initDriver(AudioOutput * audioOutput, ConfigParam * param) { + /* no need for pthread_once thread-safety when reading config */ + static int free_global_registered; AlsaData *ad = newAlsaData(); + if (!free_global_registered) { + atexit((void(*)(void))snd_config_update_free_global); + free_global_registered = 1; + } + if (param) { BlockParam *bp; @@ -122,8 +129,6 @@ static int alsa_testDefault(void) int ret = snd_pcm_open(&handle, default_device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); - snd_config_update_free_global(); - if (ret) { WARNING("Error opening default ALSA device: %s\n", snd_strerror(-ret)); @@ -168,7 +173,6 @@ static int alsa_openDevice(AudioOutput * audioOutput) err = E(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; |