# HG changeset patch # User William Pitcock # Date 1242421615 18000 # Node ID 1b2350bdeaefddeaae2ea6ff79971f5f399886bf # Parent cb93b500a36478139e063dcff26435a9de26fef6 alsa-ng: Be less stupid if things don't open. diff -r cb93b500a364 -r 1b2350bdeaef src/alsa-ng/alsa-core.c --- 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