# HG changeset patch # User chainsaw # Date 1134003267 28800 # Node ID 852a1455dfb7aeaf074ff6fcf6144cd4f0c98735 # Parent ddb59458d7a96d7189d1055798650ddee9a73b05 [svn] Use a mutex, lower timeouts. Do not spin waiting for playback to start. diff -r ddb59458d7a9 -r 852a1455dfb7 Plugins/Input/wav/wav-sndfile.c --- a/Plugins/Input/wav/wav-sndfile.c Wed Dec 07 15:53:53 2005 -0800 +++ b/Plugins/Input/wav/wav-sndfile.c Wed Dec 07 16:54:27 2005 -0800 @@ -41,7 +41,7 @@ static int seek_time = -1; static GThread *decode_thread; - +GStaticMutex decode_mutex = G_STATIC_MUTEX_INIT; InputPlugin wav_ip = { NULL, @@ -122,6 +122,8 @@ { static short buffer [BUFFER_SIZE]; int samples; + g_static_mutex_lock(&decode_mutex); + decoding = TRUE; while (decoding) { @@ -132,7 +134,7 @@ { wav_ip.add_vis_pcm (wav_ip.output->written_time (), HOST_SIGNED_SHORT, sfinfo.channels, samples * sizeof (short), buffer); while ((wav_ip.output->buffer_free () < (samples * sizeof (short))) && decoding) - xmms_usleep (80000); + xmms_usleep (10000); wav_ip.output->write_audio (buffer, samples * sizeof (short)); } @@ -148,6 +150,7 @@ }; /* while (decoding) */ + g_static_mutex_unlock(&decode_mutex); g_thread_exit (NULL); return NULL; } /* play_loop */ @@ -186,8 +189,7 @@ decode_thread = g_thread_create ((GThreadFunc)play_loop, NULL, TRUE, NULL); - while (decoding == FALSE) - xmms_usleep (80000); + xmms_usleep (40000); } /* play_start */ static void