[pulseaudio-discuss] [PATCH 11/11] protocol-native: Enable srchannel
David Henningsson
david.henningsson at canonical.com
Tue Apr 29 06:22:25 PDT 2014
The srchannel is enabled if protocol version >= 30 and
SHM is available.
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
src/pulsecore/protocol-native.c | 44 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 65b2636..c2ec644 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -2568,6 +2568,45 @@ static void command_exit(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
pa_pstream_send_simple_ack(c->pstream, tag); /* nonsense */
}
+static void setup_srchannel(pa_native_connection *c) {
+ pa_srchannel_template srt;
+ pa_srchannel *sr;
+ pa_memchunk mc;
+ pa_tagstruct *t;
+ int fdlist[2];
+
+ if (c->version < 30) {
+ pa_log_debug("Disabling srchannel, reason: Protocol too old");
+ return;
+ }
+
+ if (!c->protocol->core->rw_mempool) {
+ pa_log_debug("Disabling srchannel, reason: No rw memory pool");
+ return;
+ }
+
+ pa_log_debug("Enabling srchannel...");
+ sr = pa_srchannel_new(c->protocol->core->mainloop, c->protocol->core->rw_mempool);
+ pa_srchannel_export(sr, &srt);
+
+ /* Allow client to access the memblock */
+ mc.memblock = srt.memblock;
+ mc.index = 0;
+ mc.length = pa_memblock_get_length(srt.memblock);
+ pa_pstream_send_memblock(c->pstream, 0, 0, 0, &mc);
+
+ /* Send enable command to client */
+ t = pa_tagstruct_new(NULL, 0);
+ pa_tagstruct_putu32(t, PA_COMMAND_ENABLE_RINGBUFFER);
+ pa_tagstruct_putu32(t, (uint32_t) -1); /* tag */
+ fdlist[0] = srt.readfd;
+ fdlist[1] = srt.writefd;
+ pa_pstream_send_tagstruct_with_fds(c->pstream, t, 2, fdlist);
+
+ /* ...and switch over */
+ pa_pstream_set_srchannel(c->pstream, sr);
+}
+
static void command_auth(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_native_connection *c = PA_NATIVE_CONNECTION(userdata);
const void*cookie;
@@ -2699,6 +2738,11 @@ static void command_auth(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
#else
pa_pstream_send_tagstruct(c->pstream, reply);
#endif
+
+ if (do_shm)
+ setup_srchannel(c);
+ else
+ pa_log_debug("Disabling srchannel, reason: No SHM support");
}
static void command_set_client_name(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
--
1.9.1
More information about the pulseaudio-discuss
mailing list