Commit 5bdd1368 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Create StreamRestore channel if none exists

Summary:
We need one channel to be able to control the volume. This restores D7485 which was broken by D20450 while fixing a different issue.
This patch tries to combine the two by only creating a new channel if none exists and not messing with existing ones.

BUG: 407397

Test Plan: Can control the notification volume in the KCM now. The slider position matches the one in pavucontrol

Reviewers: #plasma, drosca, broulik, ngraham

Reviewed By: ngraham

Subscribers: ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28822
parent 15960343
......@@ -100,6 +100,13 @@ qint64 StreamRestore::volume() const
void StreamRestore::setVolume(qint64 volume)
{
pa_cvolume vol = m_cache.valid ? m_cache.volume : m_volume;
// If no channel exists force one. We need one to be able to control the volume
// See https://bugs.kde.org/show_bug.cgi?id=407397
if (vol.channels == 0) {
vol.channels = 1;
}
for (int i = 0; i < vol.channels; ++i) {
vol.values[i] = volume;
}
......@@ -190,6 +197,13 @@ void StreamRestore::writeChanges(const pa_cvolume &volume, bool muted, const QSt
info.device = deviceData.isEmpty() ? nullptr : deviceData.constData();
info.mute = muted;
// If no channel exists force one. We need one to be able to control the volume
// See https://bugs.kde.org/show_bug.cgi?id=407397
if (info.channel_map.channels == 0) {
info.channel_map.channels = 1;
info.channel_map.map[0] = PA_CHANNEL_POSITION_MONO;
}
m_cache.valid = true;
m_cache.volume = volume;
m_cache.muted = muted;
......
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