[pulseaudio-discuss] Setting default sink programmatically in PulseAudio 2.1
Damir Jelić
poljarinho at gmail.com
Mon Feb 18 12:23:11 PST 2013
Hi.
On Thu, Feb 14, 2013 at 07:55:51PM +0100, Frank Groeneveld wrote:
> 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?
You can use pa_context_set_default_sink().
>
> 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.
You can look up how pactl does this.
More information about the pulseaudio-discuss
mailing list