From 7abf17edcdae7d29231ff6619f22212b0ef9eee7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 13 May 2006 20:47:55 +0000 Subject: [PATCH] fix fragment size calculation for module-alsa-source git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@852 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/module-alsa-source.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c index ad52271..a47e0bc 100644 --- a/src/modules/module-alsa-source.c +++ b/src/modules/module-alsa-source.c @@ -118,7 +118,11 @@ static void do_read(struct userdata *u) { u->memchunk.index = 0; } - assert(u->memchunk.memblock && u->memchunk.memblock->data && u->memchunk.length && u->memchunk.memblock->length && (u->memchunk.length % u->frame_size) == 0); + assert(u->memchunk.memblock); + assert(u->memchunk.length); + assert(u->memchunk.memblock->data); + assert(u->memchunk.memblock->length); + assert(u->memchunk.length % u->frame_size == 0); if ((frames = snd_pcm_readi(u->pcm_handle, (uint8_t*) u->memchunk.memblock->data + u->memchunk.index, u->memchunk.length / u->frame_size)) < 0) { if (frames == -EAGAIN) @@ -331,12 +335,12 @@ int pa__init(pa_core *c, pa_module*m) { frame_size = pa_frame_size(&ss); periods = 12; - fragsize = 1024; + fragsize = frame_size*1024; if (pa_modargs_get_value_u32(ma, "fragments", &periods) < 0 || pa_modargs_get_value_u32(ma, "fragment_size", &fragsize) < 0) { pa_log(__FILE__": failed to parse buffer metrics"); goto fail; } - period_size = fragsize; + period_size = fragsize/frame_size; u = pa_xmalloc0(sizeof(struct userdata)); m->userdata = u; @@ -419,9 +423,9 @@ int pa__init(pa_core *c, pa_module*m) { } u->frame_size = frame_size; - u->fragment_size = period_size; + u->fragment_size = period_size * frame_size; - pa_log(__FILE__": using %u fragments of size %lu bytes.", periods, (long unsigned)u->fragment_size); + pa_log(__FILE__": using %u fragments of size %lu bytes.", periods, (long unsigned) u->fragment_size); u->memchunk.memblock = NULL; u->memchunk.index = u->memchunk.length = 0; -- 2.7.4