# HG changeset patch # User John Lindgren # Date 1248295336 14400 # Node ID 83b1a4e5f4535396b7700080a93a6d51a328fe36 # Parent d2e01ca063359111b8f80bbbc2c905025447afd5 alsa-ng: Keep mixer open even when playback stopped. diff -r d2e01ca06335 -r 83b1a4e5f453 src/alsa-ng/alsa-core.c --- a/src/alsa-ng/alsa-core.c Mon Jul 13 15:37:47 2009 -0500 +++ b/src/alsa-ng/alsa-core.c Wed Jul 22 16:42:16 2009 -0400 @@ -299,9 +299,24 @@ if (alsaplug_cfg.mixer_card == NULL) alsaplug_cfg.mixer_card = g_strdup("default"); + if (!alsaplug_mixer_new(&amixer)) + mixer_ready = TRUE; + return OUTPUT_PLUGIN_INIT_FOUND_DEVICES; } +static void alsaplug_cleanup(void) +{ + if (mixer_ready == TRUE) + { + snd_mixer_detach(amixer, alsaplug_cfg.mixer_card); + snd_mixer_close(amixer); + + amixer = NULL; + mixer_ready = FALSE; + } +} + static gint alsaplug_open_audio(AFormat fmt, gint rate, gint nch) { @@ -317,9 +332,6 @@ return -1; } - if (!alsaplug_mixer_new(&amixer)) - mixer_ready = TRUE; - if ((err = snd_pcm_open(&pcm_handle, alsaplug_cfg.pcm_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { _ERROR("snd_pcm_open: %s", snd_strerror(err)); @@ -383,15 +395,6 @@ g_thread_join(audio_thread); audio_thread = NULL; - - if (mixer_ready == TRUE) - { - snd_mixer_detach(amixer, alsaplug_cfg.mixer_card); - snd_mixer_close(amixer); - - amixer = NULL; - mixer_ready = FALSE; - } } static void @@ -512,6 +515,7 @@ .description = "ALSA Output Plugin (-ng)", .probe_priority = 1, .init = alsaplug_init, + .cleanup = alsaplug_cleanup, .open_audio = alsaplug_open_audio, .close_audio = alsaplug_close_audio, .write_audio = alsaplug_write_audio,