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"
This commit is contained in:
parent
7d0c32b450
commit
d0ab3a31ac
@ -74,8 +74,15 @@ static void freeAlsaData(AlsaData * ad)
|
|||||||
static int alsa_initDriver(struct audio_output *audioOutput,
|
static int alsa_initDriver(struct audio_output *audioOutput,
|
||||||
ConfigParam * param)
|
ConfigParam * param)
|
||||||
{
|
{
|
||||||
|
/* no need for pthread_once thread-safety when reading config */
|
||||||
|
static int free_global_registered;
|
||||||
AlsaData *ad = newAlsaData();
|
AlsaData *ad = newAlsaData();
|
||||||
|
|
||||||
|
if (!free_global_registered) {
|
||||||
|
atexit((void(*)(void))snd_config_update_free_global);
|
||||||
|
free_global_registered = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (param) {
|
if (param) {
|
||||||
BlockParam *bp;
|
BlockParam *bp;
|
||||||
|
|
||||||
@ -107,8 +114,6 @@ static int alsa_testDefault(void)
|
|||||||
|
|
||||||
int ret = snd_pcm_open(&handle, default_device,
|
int ret = snd_pcm_open(&handle, default_device,
|
||||||
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
||||||
snd_config_update_free_global();
|
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
WARNING("Error opening default ALSA device: %s\n",
|
WARNING("Error opening default ALSA device: %s\n",
|
||||||
snd_strerror(-ret));
|
snd_strerror(-ret));
|
||||||
@ -153,7 +158,6 @@ static int alsa_openDevice(struct audio_output *audioOutput)
|
|||||||
|
|
||||||
err = snd_pcm_open(&ad->pcmHandle, ad->device,
|
err = snd_pcm_open(&ad->pcmHandle, ad->device,
|
||||||
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
|
||||||
snd_config_update_free_global();
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
ad->pcmHandle = NULL;
|
ad->pcmHandle = NULL;
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
Reference in New Issue
Block a user