Mercurial > audlegacy-plugins
changeset 3198:83b1a4e5f453
alsa-ng: Keep mixer open even when playback stopped.
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Wed, 22 Jul 2009 16:42:16 -0400 |
parents | d2e01ca06335 |
children | 263c7d983100 |
files | src/alsa-ng/alsa-core.c |
diffstat | 1 files changed, 16 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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,