Mercurial > audlegacy-plugins
comparison src/alsa-ng/alsa-core.c @ 3196:0f7180e3b163
alsa-ng: Enforce a minimum buffer size of 500ms.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Sun, 12 Jul 2009 08:30:13 -0500 |
parents | bbf2cd0df6c3 |
children | d2e01ca06335 |
comparison
equal
deleted
inserted
replaced
3195:16d4308fb36e | 3196:0f7180e3b163 |
---|---|
303 } | 303 } |
304 | 304 |
305 static gint | 305 static gint |
306 alsaplug_open_audio(AFormat fmt, gint rate, gint nch) | 306 alsaplug_open_audio(AFormat fmt, gint rate, gint nch) |
307 { | 307 { |
308 gint err, bitwidth, ringbuf_size; | 308 gint err, bitwidth, ringbuf_size, buf_size; |
309 snd_pcm_format_t afmt; | 309 snd_pcm_format_t afmt; |
310 snd_pcm_hw_params_t *hwparams = NULL; | 310 snd_pcm_hw_params_t *hwparams = NULL; |
311 | 311 |
312 afmt = alsaplug_format_convert(fmt); | 312 afmt = alsaplug_format_convert(fmt); |
313 if (afmt == SND_PCM_FORMAT_UNKNOWN) | 313 if (afmt == SND_PCM_FORMAT_UNKNOWN) |
340 return -1; | 340 return -1; |
341 } | 341 } |
342 | 342 |
343 bitwidth = snd_pcm_format_physical_width(afmt); | 343 bitwidth = snd_pcm_format_physical_width(afmt); |
344 bps = (rate * bitwidth * nch) >> 3; | 344 bps = (rate * bitwidth * nch) >> 3; |
345 ringbuf_size = aud_cfg->output_buffer_size * bps / 1000; | 345 |
346 buf_size = aud_cfg->output_buffer_size ? aud_cfg->output_buffer_size : 500; | |
347 ringbuf_size = buf_size * bps / 1000; | |
348 | |
346 if (alsaplug_ringbuffer_init(&pcm_ringbuf, ringbuf_size) == -1) { | 349 if (alsaplug_ringbuffer_init(&pcm_ringbuf, ringbuf_size) == -1) { |
347 _ERROR("alsaplug_ringbuffer_init failed"); | 350 _ERROR("alsaplug_ringbuffer_init failed"); |
348 return -1; | 351 return -1; |
349 } | 352 } |
353 | |
350 pcm_going = TRUE; | 354 pcm_going = TRUE; |
351 flush_request = -1; | 355 flush_request = -1; |
352 | 356 |
353 audio_thread = g_thread_create(alsaplug_loop, NULL, TRUE, NULL); | 357 audio_thread = g_thread_create(alsaplug_loop, NULL, TRUE, NULL); |
354 return 1; | 358 return 1; |