[pulseaudio-discuss] General Pulse audio async api questions
Lennart Poettering
lennart at poettering.net
Wed Jan 13 11:56:17 PST 2010
On Tue, 12.01.10 11:48, Forwind info (forward at forwind.net) wrote:
A few comments on top of those tanuk already provided:
> 1. To obtain the volume of primary Output Device.
> ans: Fetch the sink info via pa_context_get_sink_info_by_index(). The
> return value will contain volume data type (pa_cvolume).
>
> 2.Differentiate between headphone volume if plugged in and speaker volume
> ans: Detect headphone connection - PulseAudio intend to expose
> jack-sensing once it becomes available to them from below. Its in the
> pipeline apparently. I need to do some more investigation around this. Some
> devices expose individual headphone volumes as opposed to speaker volumes
> others don't.
Note that only very few audio devices actually have independant
headphone and speaker volumes. PA supports different mixer paths by
means of the device port functionality, but you may not assume that a
particular path is available. Also, PA will not allow you to control
the volume of a path that is currently not active. The reason for that
is that this is often not even possible since multiple paths might not
be independant of each other.
> 4. If the sound is muted and some exterior application attempts to play
> sound then flag it
> ans: Subscribe to the PA_SUBSCRIPTION_EVENT_SINK_INPUT event and on the
> callback check to see if that sink is muted (boolean). Note if the client
> application is paused, the sink is then muted and the client app is restart
> the event will not be triggered. This might be not satisfy UI spec
> requirements. Check with MPT.
If you want to control this the best way is probably to write a little
module that lives inside of PA and can flag this synchrnously instead
of doing that out-of-process asynchronously.
> 5. Ability to mute all output sinks.
> ans: pa_context_set_sink_mute_by_index()- iterate through all sinks
> returned via pa_context_get_sink_info_list(). Maybe there is a mute
> all switch - could not see it in the docs right now - will ask on #pa on
> freenode.
I'd be happy to merge a patch that would treat
pa_context_set_sink_mute_by_index() with an index of PA_INVALID_INDEX
as a request to mute all sinks, and similarly for sources.
> 6. Unmute all outputs and return to previous volumes.
> ans: PA's module-stream-restore - more investigation. Apparently this
> will store previous volumes of all sinks and restore them when required.
muting and volume changing is orthogonal. PA treats them completely
indendantly. (Note however that some client programs do apply some
connection here: i.e. gnome-volume-control mutes the device if you
pull the volume to minimum)
> 8. Set individual outputs volumes to max.
> ans: Set the sink (output device) in question to PA_VOLUME_NORM.
> pa_cvolume_reset() - should do this for the sink in question.
> PA_VOLUME_NORM roughly corresponds to 0DB => MAX volume without clipping.
PA_VOLUME_NORM really means max hw amplification. As tanuk pointed out
the 0dB value of the hw is at the "base" volume. And if you want
digital amp you can even go > PA_VOLUME_NORM which is even louder.
Also see:
http://pulseaudio.org/wiki/WritingVolumeControlUIs#Volumes
Lennart
--
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
More information about the pulseaudio-discuss
mailing list