[pulseaudio-discuss] Moving sources and sinks

Lennart Poettering lennart at poettering.net
Mon May 5 18:28:19 PDT 2008


On Sun, 04.05.08 14:15, Tanu Kaskinen (tanuk at iki.fi) wrote:

> 
> On Sat, May 03, 2008 at 04:48:05PM -0700, Nick Thompson wrote:
> > Given what you say (above) about per device routing not being possible I 
> > think the area I'd like to concentrate on is figuring out how a module 
> > can detect streams as they are being created.  That way it could get the 
> > call in to switch sink input before the stream is started.  So figuring 
> > this out would be a great start.
> 
> This is how I think it might work:
> 
> 1. Register yourself to listen to new sink input events. The
> pa_core structure (core.h) has an array of hooks, each
> corresponding to one type of event. The following will do
> the registration:
> 
> pa_hook_connect(core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW],
>                 my_callback,
>                 my_userdata);
> 
> There the "core" variable is a pointer to pa_core.
> my_callback is a function that gets called when the event
> happens, and my_userdata is pointer to any data you want the
> callback function to have access to.
> 
> 2. Change the destination sink. The callback gets as
> parameters a pointer to pa_core, a pointer to
> pa_sink_input_new_data, and the userdata pointer you gave in
> the registration function. pa_sink_input_new_data has the
> field "sink", which you can set in the callback to be the
> sink you want the sink input to connect to.

This is exactly how it should be done!

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4



More information about the pulseaudio-discuss mailing list