Make the recording a bit more chunky so that we can fit in the pool and have

efficient blocks.


git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1327 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Pierre Ossman 2006-08-23 07:57:43 +00:00
parent b27ffbec8c
commit 79c4a6842c

View file

@ -82,6 +82,8 @@ struct userdata {
pa_memchunk memchunk; pa_memchunk memchunk;
unsigned int page_size;
uint32_t frame_size; uint32_t frame_size;
uint32_t buffer_size; uint32_t buffer_size;
unsigned int written_bytes, read_bytes; unsigned int written_bytes, read_bytes;
@ -193,7 +195,8 @@ static void do_write(struct userdata *u) {
static void do_read(struct userdata *u) { static void do_read(struct userdata *u) {
pa_memchunk memchunk; pa_memchunk memchunk;
int err, l; int err;
size_t l;
ssize_t r; ssize_t r;
assert(u); assert(u);
@ -205,6 +208,11 @@ static void do_read(struct userdata *u) {
err = ioctl(u->fd, I_NREAD, &l); err = ioctl(u->fd, I_NREAD, &l);
assert(err >= 0); assert(err >= 0);
/* This is to make sure it fits in the memory pool. Also, a page
should be the most efficient transfer size. */
if (l > u->page_size)
l = u->page_size;
memchunk.memblock = pa_memblock_new(u->core->mempool, l); memchunk.memblock = pa_memblock_new(u->core->mempool, l);
assert(memchunk.memblock); assert(memchunk.memblock);
if ((r = pa_iochannel_read(u->io, memchunk.memblock->data, memchunk.memblock->length)) < 0) { if ((r = pa_iochannel_read(u->io, memchunk.memblock->data, memchunk.memblock->length)) < 0) {
@ -589,6 +597,10 @@ int pa__init(pa_core *c, pa_module*m) {
u->memchunk.memblock = NULL; u->memchunk.memblock = NULL;
u->memchunk.length = 0; u->memchunk.length = 0;
/* We use this to get a reasonable chunk size */
u->page_size = sysconf(_SC_PAGESIZE);
u->frame_size = pa_frame_size(&ss); u->frame_size = pa_frame_size(&ss);
u->buffer_size = buffer_size; u->buffer_size = buffer_size;