# HG changeset patch # User Matti Hamalainen # Date 1244158368 -10800 # Node ID dca77b467ea2187152441d62a257008456532777 # Parent 1bb4cad5792375a37756a414659b067d0492842a Fix a race condition which can occur when flushing the output buffer, causing two locking g_conds to occur at unexpected order, halting the execution. diff -r 1bb4cad57923 -r dca77b467ea2 src/alsa-ng/alsa-core.c --- a/src/alsa-ng/alsa-core.c Sat May 16 15:41:43 2009 +0200 +++ b/src/alsa-ng/alsa-core.c Fri Jun 05 02:32:48 2009 +0300 @@ -32,7 +32,7 @@ static gint flush_request, paused; static GMutex *pcm_pause_mutex, *pcm_state_mutex; -static GCond *pcm_pause_cond, *pcm_state_cond; +static GCond *pcm_pause_cond, *pcm_state_cond, *pcm_flush_cond; /******************************************************************************** * ALSA Mixer setting functions. * @@ -83,7 +83,7 @@ wr_total = flush_request * (bps / 1000); flush_request = -1; - g_cond_broadcast(pcm_state_cond); + g_cond_broadcast(pcm_flush_cond); } if (alsaplug_ringbuffer_read(&pcm_ringbuf, buf, 2048) == -1) @@ -131,6 +131,7 @@ pcm_state_mutex = g_mutex_new(); pcm_state_cond = g_cond_new(); + pcm_flush_cond = g_cond_new(); if (snd_card_next(&card) != 0) return OUTPUT_PLUGIN_INIT_NO_DEVICES; @@ -282,11 +283,9 @@ g_mutex_lock(pcm_state_mutex); flush_request = time; g_cond_broadcast(pcm_state_cond); - g_mutex_unlock(pcm_state_mutex); /* ...then wait for the transaction to complete. */ - g_mutex_lock(pcm_state_mutex); - g_cond_wait(pcm_state_cond, pcm_state_mutex); + g_cond_wait(pcm_flush_cond, pcm_state_mutex); g_mutex_unlock(pcm_state_mutex); }