summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rosca <[email protected]>2017-05-06 15:34:46 +0200
committerDavid Rosca <[email protected]>2017-05-06 15:35:39 +0200
commit462628981947e298c5785864ee709bb1bf24e784 (patch)
tree7603bd726b836376a614198ffdd1cc9e29ebc6fe
parentcb52cc8826d47b3f4634d2d1e6f08d2ba750fdec (diff)
Preserve channel balance when changing volume
BUG: 362832 Differential Revision: https://phabricator.kde.org/D5546
-rw-r--r--src/context.h3
-rw-r--r--src/volumeobject.cpp2
2 files changed, 3 insertions, 2 deletions
diff --git a/src/context.h b/src/context.h
index 3ebace8..5bc0f14 100644
--- a/src/context.h
+++ b/src/context.h
@@ -96,8 +96,9 @@ 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);
for (int i = 0; i < newCVolume.channels; ++i) {
- newCVolume.values[i] = newVolume;
+ newCVolume.values[i] = qBound<qint64>(0, newCVolume.values[i] + diff, PA_VOLUME_MAX);
}
} else {
Q_ASSERT(newCVolume.channels > channel);
diff --git a/src/volumeobject.cpp b/src/volumeobject.cpp
index c9c51f8..a8315b6 100644
--- a/src/volumeobject.cpp
+++ b/src/volumeobject.cpp
@@ -38,7 +38,7 @@ VolumeObject::~VolumeObject()
qint64 VolumeObject::volume() const
{
- return m_volume.values[0];
+ return pa_cvolume_avg(&m_volume);
}
bool VolumeObject::isMuted() const