[pulseaudio-discuss] Routing of audio to loudspeakers or headphones

Colin Guthrie gmane at colin.guthr.ie
Thu Sep 16 01:44:51 PDT 2010


'Twas brillig, and Tanu Kaskinen at 15/09/10 17:52 did gyre and gimble:
> On Wed, 2010-09-15 at 15:37 +0100, Colin Guthrie wrote:
>>> 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.
> 
> This is not entirely correct. PA_CORE_HOOK_SINK_STATE_CHANGED is fired
> only when the pa_sink.state variable changes, not when the active port
> changes. For monitoring port changes, either implement a new hook
> (PA_CORE_HOOK_SINK_PORT_CHANGED) and use it, or use the asynchronous
> subscription system (see src/pulsecore/core-subscribe.h for the API). I
> would prefer the first alternative - the synchronous hook callbacks are
> easier to get right than the asynchronous subscription callbacks.

Ahh right, thanks Tanu. Yeah I initially thought about the subscription
stuff but then somehow just assumed the hook system would be sufficient,
but didn't look into the details.

I do wonder however if a state change would ultimately be fired when the
port changes anyway... but if it does it would be too often anyway.

A new hook in the core would really be needed here which makes the job a
little more complex for you :(

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