[pulseaudio-discuss] master volume check
lennart at poettering.net
Thu Oct 15 19:49:53 PDT 2009
On Tue, 13.10.09 13:38, Forwind info (forward at forwind.net) wrote:
> At the moment I am trying to write a simple gtk application which in essence
> can detect this scenario :
> 'master' volume is muted. And at the same time a client application is
> attempting to play audio.
> I have been digging through the API and I can't find anything obvious about
> the master volume.
You should subescribe to sink changes with pa_context_subscribe(). Then
you need to enumerate the output sinks with
pa_context_get_sink_info_list(). Look for pa_sink_info::mute and
pa_sink_info::cvolume for the current mute state and the volume. Use
pa_cvolume_is_muted() on pa_sink_info::cvolume to easily check if all
channels of the volume are set to muted. i.e. something like this:
muted = si->muted || pa_cvolume_is_muted(&si->cvolume);
Then, wehn you get a subscription event simply ask for an update of
the pa_sink_info for that sink via
That way you will be able to follow the mute status of all audio sinks
(aka "output devices"). Now if you also want to track the streams
connecting to them you do basically the same for the sink inputs (aka
"output streams"). The logic is very similar for that. If you want to
know which sink input (i.e. stream) connects to which sink
(i.e. output device) then compare pa_sink_input::sink and
Hope this is not too confusing.
> I am using the Glib asynchronous api. So far I can query the server about
> the number channels and their respective volumes but I cannot query the
> overall master volume.
There is no overall master volume, because we distinguish different
devices. The best you can get is the volume of each sink seperately.
> I thought it would be a case of setting up a callback whereby any channel
> attempting to play a stream would notify a custom call back which would then
> check if all channels are muted and then notify the GUI accordingly.
> another idea was to use PA_STREAM_START_MUTED. Connect to all streams and on
> a playback event check if any has this stream state ? clutching at straws to
> be honest. long time since I toyed with C API's.
No need to bother with that flag. The introspection APIs should offer
all you need.
Hope this helps!
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
More information about the pulseaudio-discuss