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

Colin Guthrie gmane at colin.guthr.ie
Tue Sep 14 07:00:56 PDT 2010


'Twas brillig, and Kim Therkelsen at 14/09/10 10:48 did gyre and gimble:
> Based on the advice from Colin Guthrie I am now trying to modify the
> module-ladspa-sink module so that it takes a "master_port" argument and
> only creates the virtual sink when the master sink's port matches the
> argument value (and unload it when it changes). I think it should be
> possible to leave the master_port argument out and let the functionality
> fall back to the original functionality to ensure backward compatibility. 

Yes, backwards compatibility is a good plan.

> Furthermore I have updated module-ladspa-sink to support multiple audio
> channels based on:
> http://www.pulseaudio.org/attachment/ticket/410/pulseaudio-0.9.12-multichannel-ladspa.patch

Oh dear, that's been there an awful long time :(

I guess it's been missed due to general Trac weirdness :(


> Unfortunately I can not find much information about how to handle these
> "ports" in the source code.
> I can see that pavucontrol can switch between the ports and from the
> "info" command in pulseaudio I get:
> 
> 1 sink(s) available.
>   * index: 0
>     name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
>     driver: <module-alsa-card.c>
>     flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
> DYNAMIC_LATENCY
> ...
>     ports:
>         analog-output: Analog Output (priority 9900)
>         analog-output-speaker: Analog Speakers (priority 10000)
>         analog-output-headphones: Analog Headphones (priority 9000)
>     active port: <analog-output-headphones>
> ...
> 
> But how do I update int pa__init(pa_module*m) to perform the port check?
> Which command should I use to ask PA which port is active?

In the pa__init() function, you'll need to read and store the
master_port argument first of all.

In the userdata struct there is a pa_sink* sink element.

When this is populated, you'll see from looking at pulsecore/sink.h that
it is just a struct.

In that struct you will see "pa_device_port *active_port" member.

This is where you can find the active port of the sink you are attaching to.


Hope that's the info you need.

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