[pulseaudio-discuss] Setting default sink programmatically in PulseAudio 2.1

Frank Groeneveld frankgroeneveld at gmail.com
Thu Feb 14 10:55:51 PST 2013


Hello,

I'm trying to develop a program that will capture all audio using
PulseAudio 2.1. It needs to capture this and prevent the audio from
being played back over the default speakers. To achive this, I'm
loading the null module programmatically like so:

pa_context_load_module(context, "module-null-sink", NULL,
module_loaded, userdata);

This works great and the callback receives an index number of the
sink. However, I can't seem to find out how to set the default sink to
this new sink. I know how to do it via the commandline:

pacmd set-default-sink null

However, I'd rather do it using a normal function call. Is that
possible in PulseAudio 2.1?

Also, unloading the module using pa_context_unload_module doesn't seem
to work, the success callback is never called, although I'm calling
the unload function with the correct index number (the one received
when loading). Unloading using the following command works fine:

pacmd unload-module <index-number>

Any help will be greatly appreciated.

Regards,
Frank Groeneveld


More information about the pulseaudio-discuss mailing list