changeset 2457:bb55de702ffb

alsa: Make spinlocks a bit less scary. Don't lock up in alsa_flush when output is closed.
author Sascha Hlusiak <contact@saschahlusiak.de>
date Mon, 24 Mar 2008 17:40:33 +0100
parents e67bce91d70c
children 853c7686e922
files src/alsa/audio.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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);
 }