[pulseaudio-discuss] [PATCH 1/6] Implement the "volume sharing" feature.

Tanu Kaskinen tanuk at iki.fi
Fri Feb 25 07:44:30 PST 2011


On Thu, 2011-02-24 at 16:16 +0200, Tanu Kaskinen wrote:
> When we have a filter sink that does some processing, currently the
> benefits of the flat volume feature are not really available. That's
> because if you have a music player that is connected to the filter sink,
> the hardware sink doesn't have any idea of the music player's stream
> volume.
> 
> This problem is solved by this "volume sharing" feature. The volume
> sharing feature works so that the filter sinks that want to avoid the
> previously described problem declare that they don't want to have
> independent volume, but they follow the master sink volume instead.
> The PA_SINK_SHARE_VOLUME_WITH_MASTER sink flag is used for that
> declaration. Then the volume logic is changed so that the hardware
> sink calculates its real volume using also the streams connected to the
> filter sink in addition to the streams that are connected directly to
> the hardware sink. Basically we're trying to create an illusion that
> from volume point of view all streams are connected directly to the
> hardware sink.
> 
> For that illusion to work, the volumes of the filter sinks and their
> virtual streams have to be managed carefully according to a set of
> rules:
> 
> If a filter sink follows the hardware sink volume, then the filter sink's
>  * reference_volume always equals the hw sink's reference_volume
>  * real_volume always equals the hw sink's real_volume
>  * soft_volume is always 0dB (ie. no soft volume)
> 
> If a filter sink doesn't follow the hardware sink volume, then the filter
> sink's
>  * reference_volume can be whatever (completely independent from the hw sink)
>  * real_volume always equals reference_volume
>  * soft_volume always equals real_volume (and reference_volume)
> 
> If a filter sink follows the hardware sink volume, and the hardware sink
> supports flat volume, then the filter sink's virtual stream's
>  * volume always equals the hw sink's real_volume
>  * reference_ratio is calculated normally from the stream volume and the hw
>    sink's reference_volume
>  * real_ratio always equals 0dB (follows from the first point)
>  * soft_volume always equals volume_factor (follows from the previous point)
> 
> If a filter sink follows the hardware sink volume, and the hardware sink
> doesn't support flat volume, then the filter sink's virtual stream's
>  * volume is always 0dB
>  * reference_ratio is always 0dB
>  * real_ratio is always 0dB
>  * soft_volume always equals volume_factor
> 
> If a filter sink doesn't follow the hardware sink volume, then the filter
> sink's virtual stream is handled as a regular stream.
> 
> Since the volumes of the virtual streams are controlled by a set of rules,
> the user is not allowed to change the virtual streams' volumes. It would
> probably also make sense to forbid changing the filter sinks' volume, but
> that's not strictly necessary, and currently changing a filter sink's volume
> changes actually the hardware sink's volume, and from there it propagates to
> all filter sinks ("funny" effects are expected when adjusting a single
> channel in cases where all sinks don't have the same channel maps).

I almost forgot to give credit to Marc-André Lureau, who wrote the first
version of this patch a long time ago. So, Colin, if you commit this
patch, please add the following text to the commit message:

"""
This patch is based on the work of Marc-André Lureau, who did the
initial implementation for Pulseaudio 0.9.15.
"""

-- 
Tanu




More information about the pulseaudio-discuss mailing list