[pulseaudio-discuss] Routing of audio to loudspeakers or headphones
Colin Guthrie
gmane at colin.guthr.ie
Wed Sep 15 07:37:28 PDT 2010
'Twas brillig, and Kim Therkelsen at 15/09/10 14:58 did gyre and gimble:
>> > Incidentally, just on this particular point....
>> >
>> > If you do update module-ladspa-sink and bring that patch up to date (I'm
>> > not sure how much work was needed to make it work with current git
>> > master?), then please submit this patch separately to the one adding the
>> > master_port support.
>>
>> (sorry for multiple replies)
>>
>> Oh and now I look at the patch itself, when you are tidying it up, can
>> you change the terminology a bit. I see it adds input_ and
>> output_port_map arguments. As this patch is based of 0.9.12, this is
>> before we added support for "ports" in PA itself.
>>
>> Ultimately can you change the term "port" as used here, to not conflict
>> with our own "port" terminology? I guess something
>> "input_ladspaport_map" or similar to differentiate it.
>>
>> Internal variable names should probably also be adapted for the same
>> reasons of clarity.
>
> Thank you very much for your help Colin. It means a lot to me.
>
> I have changed the variable names and added a pa_master_ports argument.
> Right now the code is located here:
> http://therkelsen.info/temp/module-ladspa-sink.c
>
> I will split the code up as you suggest so that I do not commit two
> changes at a time. Now I have to figure out how I submit the code and
> how it is reviewed etc..
The best bet is to use git. Git allows you to "clone" our upstream
repository and make your changes. You can then push your changes to some
location (e.g. github, gitorious etc.) and ask for a review or a "pull
request".
Alternatively for newer contributors and such like you can use the "git
email" command to send patches directly to this list so we can review
and apply.
Ultimately you can make lots of small commits to your local git clone to
your hearts content. It's a very convenient way of working.
> Most important to me is to figure out how you make the module
> unload/load automatically as the headphone jack is plugged/unplugged.
> Right now the module just fails to load if the master port is not the
> one for the headphones.
Ultimately you'll have to make the module listen to the
PA_CORE_HOOK_SINK_STATE_CHANGED hook. The callback assigned to this hook
will be called whenever a sink changes in the PA daemon (e.g. when it's
port is changed). You can inspect the current active_port and either
load, unload or noop as appropriate the actual sink object itself.
> Perhaps I should monitor the active master port from within the
> module-ladspa-sink and turn the processing off when the active master
> port is not correct instead of failing when loading?
Essentially this is correct. The hook callback will ultimately provide
you with this information. You then just need to make sure you deal
gracefully with the sink object you create.
I hope that helps.
Have a look at the code in module combine. for the above noted
PA_CORE_HOOK_SINK_STATE_CHANGED and hopefully you can follow the logic
from there (hint: when called, make sure the sink* given in the callback
is the sink you are interested in before inspecting it's active_port).
Col
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
More information about the pulseaudio-discuss
mailing list