summaryrefslogtreecommitdiffstats
path: root/src/pulse
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/pulse
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/pulse')
-rw-r--r--src/pulse/context.c8
-rw-r--r--src/pulse/internal.h2
-rw-r--r--src/pulse/stream.c7
3 files changed, 9 insertions, 8 deletions
diff --git a/src/pulse/context.c b/src/pulse/context.c
index 34f517f0..b3530542 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -128,7 +128,7 @@ pa_context *pa_context_new(pa_mainloop_api *mainloop, const char *name) {
c->subscribe_callback = NULL;
c->subscribe_userdata = NULL;
- c->memblock_stat = pa_memblock_stat_new();
+ c->mempool = pa_mempool_new(1);
c->local = -1;
c->server_list = NULL;
c->server = NULL;
@@ -177,7 +177,7 @@ static void context_free(pa_context *c) {
if (c->playback_streams)
pa_dynarray_free(c->playback_streams, NULL, NULL);
- pa_memblock_stat_unref(c->memblock_stat);
+ pa_mempool_free(c->mempool);
if (c->conf)
pa_client_conf_free(c->conf);
@@ -407,7 +407,9 @@ static void setup_context(pa_context *c, pa_iochannel *io) {
pa_context_ref(c);
assert(!c->pstream);
- c->pstream = pa_pstream_new(c->mainloop, io, c->memblock_stat);
+ c->pstream = pa_pstream_new(c->mainloop, io, c->mempool);
+
+ pa_pstream_use_shm(c->pstream, 1);
pa_pstream_set_die_callback(c->pstream, pstream_die_callback, c);
pa_pstream_set_recieve_packet_callback(c->pstream, pstream_packet_callback, c);
diff --git a/src/pulse/internal.h b/src/pulse/internal.h
index 96028d83..afcfaeff 100644
--- a/src/pulse/internal.h
+++ b/src/pulse/internal.h
@@ -69,7 +69,7 @@ struct pa_context {
pa_context_subscribe_cb_t subscribe_callback;
void *subscribe_userdata;
- pa_memblock_stat *memblock_stat;
+ pa_mempool *mempool;
int local;
int do_autospawn;
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 677df009..180cd096 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -437,8 +437,7 @@ void pa_create_stream_callback(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSED
pa_frame_size(&s->sample_spec),
1,
0,
- NULL,
- s->context->memblock_stat);
+ NULL);
}
s->channel_valid = 1;
@@ -604,9 +603,9 @@ int pa_stream_write(
return 0;
if (free_cb)
- chunk.memblock = pa_memblock_new_user((void*) data, length, free_cb, 1, s->context->memblock_stat);
+ chunk.memblock = pa_memblock_new_user(s->context->mempool, (void*) data, length, free_cb, 1);
else {
- chunk.memblock = pa_memblock_new(length, s->context->memblock_stat);
+ chunk.memblock = pa_memblock_new(s->context->mempool, length);
memcpy(chunk.memblock->data, data, length);
}