# HG changeset patch # User William Pitcock # Date 1242357874 18000 # Node ID adec82db531cbc493d30b0b5dfc27eb3bc2615a5 # Parent 26a2c237ef5310f3af99c933c9ed7da47e59349b alsa-ng: Everything but mixer (and custom output settings) should be working now. diff -r 26a2c237ef53 -r adec82db531c src/alsa-ng/alsa-core.c --- a/src/alsa-ng/alsa-core.c Thu May 14 21:08:03 2009 -0500 +++ b/src/alsa-ng/alsa-core.c Thu May 14 22:24:34 2009 -0500 @@ -25,14 +25,20 @@ static gboolean pcm_going = FALSE; static GThread *audio_thread = NULL; static gint bps; -static GMutex *pcm_mutex; -static GCond *pcm_cond; static gsize wr_total = 0; static gsize wr_hwframes = 0; static gint flush_request; +/******************************************************************************** + * ALSA Mixer setting functions. * + ********************************************************************************/ + +/******************************************************************************** + * ALSA PCM I/O functions. * + ********************************************************************************/ + static void alsaplug_write_buffer(gpointer data, gint length) { @@ -77,14 +83,13 @@ if (alsaplug_ringbuffer_read(&pcm_ringbuf, buf, 2048) == -1) { - GTimeVal pcm_abs_time; - - g_get_current_time(&pcm_abs_time); - g_time_val_add(&pcm_abs_time, 10000); - - g_mutex_lock(pcm_mutex); - g_cond_timed_wait(pcm_cond, pcm_mutex, &pcm_abs_time); - g_mutex_unlock(pcm_mutex); + /* less than 2048 bytes to go...? */ + gint remain = alsaplug_ringbuffer_used(&pcm_ringbuf); + if (remain <= 2048) + { + alsaplug_ringbuffer_read(&pcm_ringbuf, buf, remain); + alsaplug_write_buffer(buf, remain); + } continue; } @@ -92,6 +97,7 @@ alsaplug_write_buffer(buf, 2048); } + snd_pcm_drain(pcm_handle); snd_pcm_close(pcm_handle); pcm_handle = NULL; @@ -107,9 +113,6 @@ { gint card = -1; - pcm_mutex = g_mutex_new(); - pcm_cond = g_cond_new(); - if (snd_card_next(&card) != 0) return OUTPUT_PLUGIN_INIT_NO_DEVICES; @@ -163,6 +166,7 @@ pcm_going = FALSE; g_thread_join(audio_thread); + audio_thread = NULL; wr_total = 0; wr_hwframes = 0; @@ -226,7 +230,7 @@ static gint alsaplug_buffer_playing(void) { - return pcm_going; + return alsaplug_ringbuffer_used(&pcm_ringbuf) != 0; } /********************************************************************************