Mercurial > audlegacy-plugins
comparison src/alsa-ng/alsa-core.c @ 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 |
comparison
equal
deleted
inserted
replaced
3173:3fd0d762371c | 3174:8106e1b31115 |
---|---|
216 } | 216 } |
217 | 217 |
218 static gint | 218 static gint |
219 alsaplug_output_time(void) | 219 alsaplug_output_time(void) |
220 { | 220 { |
221 gint ret = 0; | |
221 snd_pcm_sframes_t delay; | 222 snd_pcm_sframes_t delay; |
222 gsize bytes = wr_total; | 223 gsize bytes = wr_total; |
224 | |
225 g_mutex_lock(pcm_state_mutex); | |
223 | 226 |
224 if (pcm_going && pcm_handle != NULL) | 227 if (pcm_going && pcm_handle != NULL) |
225 { | 228 { |
226 if (!snd_pcm_delay(pcm_handle, &delay)) | 229 if (!snd_pcm_delay(pcm_handle, &delay)) |
227 { | 230 { |
230 bytes = 0; | 233 bytes = 0; |
231 else | 234 else |
232 bytes -= d; | 235 bytes -= d; |
233 } | 236 } |
234 | 237 |
235 return (bytes * 1000) / bps; | 238 ret = (bytes * 1000) / bps; |
236 } | 239 } |
237 | 240 |
238 return 0; | 241 g_mutex_unlock(pcm_state_mutex); |
242 | |
243 return ret; | |
239 } | 244 } |
240 | 245 |
241 static gint | 246 static gint |
242 alsaplug_written_time(void) | 247 alsaplug_written_time(void) |
243 { | 248 { |
249 gint ret = 0; | |
250 | |
251 g_mutex_lock(pcm_state_mutex); | |
252 | |
244 if (pcm_going) | 253 if (pcm_going) |
245 return (wr_total * 1000) / bps; | 254 ret = (wr_total * 1000) / bps; |
246 | 255 |
247 return 0; | 256 g_mutex_unlock(pcm_state_mutex); |
257 | |
258 return ret; | |
248 } | 259 } |
249 | 260 |
250 static gint | 261 static gint |
251 alsaplug_buffer_free(void) | 262 alsaplug_buffer_free(void) |
252 { | 263 { |