Commit 27aa584f authored by Zren (Chris Holland)'s avatar Zren (Chris Holland)

Make device "master volume" the max of all channels instead of the avg

When we use the avg, it's very easy to "boost" the "right speaker" over 100%.

Before this patch, if you set the left channel to 50% and leave the
right channel at 100% (via pavucontrol), the "master channel" will be
the average of 75%. If you then raise the "master channel" by 10%,
you raise the right channel to 110%.

Bug: 388553

Differential Revision: https://phabricator.kde.org/D9726
parent 03435453
......@@ -96,7 +96,7 @@ public:
newVolume = qBound<qint64>(0, newVolume, PA_VOLUME_MAX);
pa_cvolume newCVolume = cVolume;
if (channel == -1) { // -1 all channels
const qint64 diff = newVolume - pa_cvolume_avg(&cVolume);
const qint64 diff = newVolume - pa_cvolume_max(&cVolume);
for (int i = 0; i < newCVolume.channels; ++i) {
newCVolume.values[i] = qBound<qint64>(0, newCVolume.values[i] + diff, PA_VOLUME_MAX);
}
......
......@@ -38,7 +38,7 @@ VolumeObject::~VolumeObject()
qint64 VolumeObject::volume() const
{
return pa_cvolume_avg(&m_volume);
return pa_cvolume_max(&m_volume);
}
bool VolumeObject::isMuted() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment