On Tue, 2014-04-29 at 15:22 +0200, David Henningsson wrote: > 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); There seems to be no way for the client to refuse this, so we can never stop supporting srchannel without breaking protocol compatibility. -- Tanu