Mercurial > audlegacy-plugins
changeset 3172:1b2350bdeaef
alsa-ng: Be less stupid if things don't open.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 15 May 2009 16:06:55 -0500 |
parents | cb93b500a364 |
children | 3fd0d762371c |
files | src/alsa-ng/alsa-core.c |
diffstat | 1 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alsa-ng/alsa-core.c Fri May 15 04:20:09 2009 -0500 +++ b/src/alsa-ng/alsa-core.c Fri May 15 16:06:55 2009 -0500 @@ -183,7 +183,12 @@ alsaplug_close_audio(void) { g_mutex_lock(pcm_state_mutex); + pcm_going = FALSE; + wr_total = 0; + wr_hwframes = 0; + bps = 0; + g_mutex_unlock(pcm_state_mutex); g_cond_broadcast(pcm_state_cond); @@ -191,9 +196,6 @@ g_thread_join(audio_thread); audio_thread = NULL; - wr_total = 0; - wr_hwframes = 0; - bps = 0; } static void @@ -206,8 +208,10 @@ g_mutex_unlock(pcm_pause_mutex); } + g_mutex_lock(pcm_state_mutex); wr_total += length; alsaplug_ringbuffer_write(&pcm_ringbuf, data, length); + g_mutex_unlock(pcm_state_mutex); g_cond_broadcast(pcm_state_cond); } @@ -267,7 +271,18 @@ static gint alsaplug_buffer_playing(void) { - return alsaplug_ringbuffer_used(&pcm_ringbuf) != 0; + gint ret; + + g_mutex_lock(pcm_state_mutex); + + if (pcm_going == FALSE) + ret = 0; + else + ret = alsaplug_ringbuffer_used(&pcm_ringbuf) != 0; + + g_mutex_unlock(pcm_state_mutex); + + return ret; } static void