# HG changeset patch # User William Pitcock # Date 1242421950 18000 # Node ID 8106e1b311153461aa2154b32ce88a6adf30db82 # Parent 3fd0d762371c6b3bc7fcc83ea0f725df1873f6bd alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex. diff -r 3fd0d762371c -r 8106e1b31115 src/alsa-ng/alsa-core.c --- a/src/alsa-ng/alsa-core.c Fri May 15 16:10:31 2009 -0500 +++ b/src/alsa-ng/alsa-core.c Fri May 15 16:12:30 2009 -0500 @@ -218,9 +218,12 @@ static gint alsaplug_output_time(void) { + gint ret = 0; snd_pcm_sframes_t delay; gsize bytes = wr_total; + g_mutex_lock(pcm_state_mutex); + if (pcm_going && pcm_handle != NULL) { if (!snd_pcm_delay(pcm_handle, &delay)) @@ -232,19 +235,27 @@ bytes -= d; } - return (bytes * 1000) / bps; + ret = (bytes * 1000) / bps; } - return 0; + g_mutex_unlock(pcm_state_mutex); + + return ret; } static gint alsaplug_written_time(void) { + gint ret = 0; + + g_mutex_lock(pcm_state_mutex); + if (pcm_going) - return (wr_total * 1000) / bps; + ret = (wr_total * 1000) / bps; - return 0; + g_mutex_unlock(pcm_state_mutex); + + return ret; } static gint