client: limit block size for zero-copy operations to mempool block size

This commit is contained in:
Lennart Poettering 2009-07-24 20:21:30 +02:00
parent e7ca058427
commit 211d0f3dcb
2 changed files with 18 additions and 6 deletions

View file

@ -1207,6 +1207,17 @@ int pa_stream_begin_write(
PA_CHECK_VALIDITY(s->context, data, PA_ERR_INVALID);
PA_CHECK_VALIDITY(s->context, nbytes && *nbytes != 0, PA_ERR_INVALID);
if (*nbytes != (size_t) -1) {
size_t m, fs;
m = pa_mempool_block_size_max(s->context->mempool);
fs = pa_frame_size(&s->sample_spec);
m = (m / fs) * fs;
if (*nbytes > m)
*nbytes = m;
}
if (!s->write_memblock) {
s->write_memblock = pa_memblock_new(s->context->mempool, *nbytes);
s->write_data = pa_memblock_acquire(s->write_memblock);