# HG changeset patch # User Sascha Hlusiak # Date 1206376833 -3600 # Node ID bb55de702ffbf4d5ed9ad8266fe64ce6541d604a # Parent e67bce91d70c29c0187328863691e10af9bc44ed alsa: Make spinlocks a bit less scary. Don't lock up in alsa_flush when output is closed. diff -r e67bce91d70c -r bb55de702ffb src/alsa/audio.c --- a/src/alsa/audio.c Thu Mar 20 01:37:46 2008 +0900 +++ b/src/alsa/audio.c Mon Mar 24 17:40:33 2008 +0100 @@ -53,7 +53,8 @@ static snd_mixer_elem_t *pcm_element; static snd_mixer_t *mixer; -static gboolean going, paused, mixer_start = TRUE; +static volatile gboolean going; +static gboolean paused, mixer_start = TRUE; static gboolean prebuffer, remove_prebuffer; static gboolean alsa_can_pause; @@ -64,7 +65,7 @@ static char *thread_buffer; /* audio intermediate buffer */ static int rd_index, wr_index; /* current read/write position in int-buffer */ static gboolean pause_request; /* pause status currently requested */ -static int flush_request; /* flush status (time) currently requested */ +static volatile int flush_request; /* flush status (time) currently requested */ static int prebuffer_size; GStaticMutex alsa_mutex = G_STATIC_MUTEX_INIT; @@ -329,7 +330,7 @@ void alsa_flush(int time) { flush_request = time; - while (flush_request != -1) + while ((flush_request != -1) && (going)) g_usleep(10000); }