[pulseaudio-discuss] [PATCH 08/11] client: Allow client to receive the srchannel memblock
David Henningsson
david.henningsson at canonical.com
Tue Apr 29 06:22:22 PDT 2014
We assume it's an srchannel memblock if it is writable and does not come
from our own mempool.
In a future implementation, maybe we can have more than one
srchannel open at the same time, but at this point we only
support one.
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
src/pulse/context.c | 26 ++++++++++++++++++++++++++
src/pulse/internal.h | 1 +
2 files changed, 27 insertions(+)
diff --git a/src/pulse/context.c b/src/pulse/context.c
index f3adf4c..7456ee5 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -213,6 +213,11 @@ static void context_unlink(pa_context *c) {
c->pstream = NULL;
}
+ if (c->srmemblock) {
+ pa_memblock_unref(c->srmemblock);
+ c->srmemblock = NULL;
+ }
+
if (c->client) {
pa_socket_client_unref(c->client);
c->client = NULL;
@@ -338,6 +343,17 @@ static void pstream_packet_callback(pa_pstream *p, pa_packet *packet, const pa_a
pa_context_unref(c);
}
+static bool is_srmemblock(pa_context *c, const pa_memchunk *chunk)
+{
+ if (!chunk || !chunk->memblock)
+ return false;
+ if (pa_memblock_is_read_only(chunk->memblock))
+ return false;
+ if (pa_memblock_is_ours(chunk->memblock))
+ return false;
+ return true;
+}
+
static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t offset, pa_seek_mode_t seek, const pa_memchunk *chunk, void *userdata) {
pa_context *c = userdata;
pa_stream *s;
@@ -350,6 +366,16 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
pa_context_ref(c);
+ if (is_srmemblock(c, chunk)) {
+ if (c->srmemblock) {
+ pa_log_warn("There is already an srmemblock. Ignoring the new one.");
+ }
+ else {
+ c->srmemblock = chunk->memblock;
+ pa_memblock_ref(c->srmemblock);
+ }
+ }
+
if ((s = pa_hashmap_get(c->record_streams, PA_UINT32_TO_PTR(channel)))) {
if (chunk->memblock) {
diff --git a/src/pulse/internal.h b/src/pulse/internal.h
index c5084d5..dc5dc66 100644
--- a/src/pulse/internal.h
+++ b/src/pulse/internal.h
@@ -65,6 +65,7 @@ struct pa_context {
pa_socket_client *client;
pa_pstream *pstream;
pa_pdispatch *pdispatch;
+ pa_memblock *srmemblock;
pa_hashmap *record_streams, *playback_streams;
PA_LLIST_HEAD(pa_stream, streams);
--
1.9.1
More information about the pulseaudio-discuss
mailing list