summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/resampler.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-08-18 19:55:18 +0000
committerLennart Poettering <lennart@poettering.net>2006-08-18 19:55:18 +0000
commit0e436a6926af56f37a74a03bb5e143e078ca0d55 (patch)
treef837bc433ba8b6f904e6d512f9c9c2552a9827db /src/pulsecore/resampler.c
parentff48681aaef919cd2c85e4572928e936397a615c (diff)
Rework memory management to allow shared memory data transfer. The central idea
is to allocate all audio memory blocks from a per-process memory pool which is available as read-only SHM segment to other local processes. Then, instead of writing the actual audio data to the socket just write references to this shared memory pool. To work optimally all memory blocks should now be of type PA_MEMBLOCK_POOL or PA_MEMBLOCK_POOL_EXTERNAL. The function pa_memblock_new() now generates memory blocks of this type by default. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1266 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/resampler.c')
-rw-r--r--src/pulsecore/resampler.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 23cdf381..74226714 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -42,7 +42,7 @@ struct pa_resampler {
pa_sample_spec i_ss, o_ss;
pa_channel_map i_cm, o_cm;
size_t i_fz, o_fz;
- pa_memblock_stat *memblock_stat;
+ pa_mempool *mempool;
void (*impl_free)(pa_resampler *r);
void (*impl_update_input_rate)(pa_resampler *r, uint32_t rate);
@@ -71,15 +71,16 @@ static int libsamplerate_init(pa_resampler*r);
static int trivial_init(pa_resampler*r);
pa_resampler* pa_resampler_new(
- const pa_sample_spec *a,
- const pa_channel_map *am,
- const pa_sample_spec *b,
- const pa_channel_map *bm,
- pa_memblock_stat *s,
- pa_resample_method_t resample_method) {
+ pa_mempool *pool,
+ const pa_sample_spec *a,
+ const pa_channel_map *am,
+ const pa_sample_spec *b,
+ const pa_channel_map *bm,
+ pa_resample_method_t resample_method) {
pa_resampler *r = NULL;
+ assert(pool);
assert(a);
assert(b);
assert(pa_sample_spec_valid(a));
@@ -88,7 +89,7 @@ pa_resampler* pa_resampler_new(
r = pa_xnew(pa_resampler, 1);
r->impl_data = NULL;
- r->memblock_stat = s;
+ r->mempool = pool;
r->resample_method = resample_method;
r->impl_free = NULL;
@@ -450,7 +451,7 @@ static void libsamplerate_run(pa_resampler *r, const pa_memchunk *in, pa_memchun
assert(p);
/* Take the existing buffer and make it a memblock */
- out->memblock = pa_memblock_new_dynamic(*p, out->length, r->memblock_stat);
+ out->memblock = pa_memblock_new_malloced(r->mempool, *p, out->length);
*p = NULL;
}
} else {
@@ -549,7 +550,7 @@ static void trivial_run(pa_resampler *r, const pa_memchunk *in, pa_memchunk *out
l = ((((n_frames+1) * r->o_ss.rate) / r->i_ss.rate) + 1) * fz;
out->index = 0;
- out->memblock = pa_memblock_new(l, r->memblock_stat);
+ out->memblock = pa_memblock_new(r->mempool, l);
for (o_index = 0;; o_index++, u->o_counter++) {
unsigned j;