[pulseaudio-discuss] [PATCH 21/23] Introduce pa_router

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Mon Nov 25 00:11:44 PST 2013


On Mon, 2013-11-25 at 04:50 +0100, David Henningsson wrote:
> On 11/20/2013 10:26 AM, Tanu Kaskinen wrote:
> > Router modules will create a pa_router object, and extend its
> > functionality with callbacks. There can be only one router in the
> > system at a time. At this first stage, the only functionality the base
> > pa_router is to notify the router modules about new and removed nodes.
> 
> Then there is another concept we can take away to keep it simple atm -
> there is no need to have a "base pa_router", you can just notify the
> router implementation through hooks instead.

One point of pa_router is that it's ensured that there's only one router
loaded at a time in the system. That's useful, because a router is
responsible of managing all stream routing and profile and port
activation, so having two routers in the system would make the behaviour
unpredictable when those two routers conflict.

Another benefit of a dedicated object is that it's easier to define a
proper interface for the routers. It's usually not documented what a
hook callback is expected to do. I failed with the naming and
documentation of the pa_router_add_node() function and the associated
callback, though. That really isn't any better than a hook in terms of
interface clarity. I should have named it
pa_router_set_initial_routing() or something like that, because setting
the initial routing for a node is what the router is expected to do.

One more benefit of not using hooks is that hooks can have just one
"call data" parameter. I extended the interface of pa_router.add_node()
yesterday:

int (*add_node)(pa_router *router, pa_node *node, pa_node **initial_connections, unsigned n_initial_connections);

So it can now return an error, and it has access to the requested
initial connections. This is more cumbersome to do with hooks. I have to
either define a new struct holding the connection request data that will
be passed to the hook, or I'll have to add fields to pa_node that
contain that same information (not nice, because the information is
relevant only at the node creation phase).

Those were the reasons why I prefer pa_router over just using hooks.
Tell me if you changed your mind and you prefer pa_router too, otherwise
I'll remove pa_router for now and make do with hooks.

-- 
Tanu



More information about the pulseaudio-discuss mailing list