Mercurial > audlegacy-plugins
changeset 3174:8106e1b31115
alsa-ng: alsaplug_written_time(), alsaplug_output_time(): Lock pcm_state_mutex.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 15 May 2009 16:12:30 -0500 |
parents | 3fd0d762371c |
children | 1bb4cad57923 |
files | src/alsa-ng/alsa-core.c |
diffstat | 1 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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