[pulseaudio-discuss] External Volume Controls

Colin Guthrie gmane at colin.guthr.ie
Tue Jun 24 02:06:50 PDT 2008


Hi,

Jerome Haltom wrote:
> So the question is has anybody done anything like this? If so, what did
> you end up with? Does any existing code exist for something like this?

Not sure to be honest.

> If not, what pointers do ya'll suggest I use to accomplish it? At most I
> am sort of thinking that I'd have to develop a PulseAudio module which
> would expose a virtual sink for each real sink, somehow having the
> volume adjustment stuff actually manipulate the amp.

Yeah that's probably the right approach. I'm not 100% sure, but I'd 
imagine module-remap-sink would be a good place to start. It just remaps 
channel of an existing sink so I think it would be a good template. I've 
not actually looked at the code tho', so someone more faimilar please 
pipe up if you know better.

You'd probably just have catch the volume control messages in 
sink_process_msg() and do your magic, and pass everything else on to the 
real underlying sink.

> Perhaps software for virtual sinks already exists, where you can map
> channels from one sink to another sink, and do silly stuff like callouts
> to external applications for volume adjustment, and I could just wire
> that up. Sort of doubt it, though.

Certainly the first part yeah - module-remap-sink :)

AFAIK it can't do callouts for other stuff - you'd have to write that 
in. It would be nicer if it was all self contained tho', shelling out is 
pretty nasty - you'd want some form of non-blocking asynchronous comms 
going on rather than waiting for an external app. I'd say that's more or 
less a requirement. Remap sink would seem to piggy back on to the thread 
of the underlying sink, so if you had no option but to shell out you'll 
have to create a new thread for this with an async message queue (or 
two?) to tell that thread what you want it to do (and to feed back). 
It's all a bit of a headfuk at first (I still don't get it fully!) as 
you have to constantly think about keeping things lock free and 
zero-copy! (tho' the latter shouldn't affect you).

PA.org is down right now as are Lennart's other sites... I guess he has 
some issues right now. I'd point you at the wiki if it was up.

The code for remap-sink can be seen in the meantime on my clone here:
http://colin.guthr.ie/git/pulseaudio/tree/src/modules/module-remap-sink.c

Hope this helps (and is vaguely correct!)


Col




More information about the pulseaudio-discuss mailing list