File 0005-StreamRestore-Always-set-channel-count-to-1.patch of Package plasma5-pa

From 792248092d25512ef2fe37ff4c79c02242832626 Mon Sep 17 00:00:00 2001
From: David Rosca <nowrep@gmail.com>
Date: Wed, 23 Aug 2017 14:36:24 +0200
Subject: StreamRestore: Always set channel count to 1

This is what pavucontrol is doing too.

BUG: 383787
FIXED-IN: 5.11

Differential Revision: https://phabricator.kde.org/D7485
---
 src/streamrestore.cpp | 27 +++++++++++++--------------
 src/streamrestore.h   |  3 +--
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/src/streamrestore.cpp b/src/streamrestore.cpp
index 1d5973e..46fa0c6 100644
--- a/src/streamrestore.cpp
+++ b/src/streamrestore.cpp
@@ -83,11 +83,11 @@ void StreamRestore::setDevice(const QString &device)
 {
     if (m_cache.valid) {
         if (m_cache.device != device) {
-            writeChanges(m_cache.volume, m_cache.channelMap, m_cache.muted, device);
+            writeChanges(m_cache.volume, m_cache.muted, device);
         }
     } else {
         if (m_device != device) {
-            writeChanges(m_volume, m_channelMap, m_muted, device);
+            writeChanges(m_volume, m_muted, device);
         }
     }
 }
@@ -100,14 +100,13 @@ qint64 StreamRestore::volume() const
 void StreamRestore::setVolume(qint64 volume)
 {
     pa_cvolume vol = m_cache.valid ? m_cache.volume : m_volume;
-    for (int i = 0; i < vol.channels; ++i) {
-        vol.values[i] = volume;
-    }
+    vol.channels = 1;
+    vol.values[0] = volume;
 
     if (m_cache.valid) {
-        writeChanges(vol, m_cache.channelMap, m_cache.muted, m_cache.device);
+        writeChanges(vol, m_cache.muted, m_cache.device);
     } else {
-        writeChanges(vol, m_channelMap, m_muted, m_device);
+        writeChanges(vol, m_muted, m_device);
     }
 }
 
@@ -120,11 +119,11 @@ void StreamRestore::setMuted(bool muted)
 {
     if (m_cache.valid) {
         if (m_cache.muted != muted) {
-            writeChanges(m_cache.volume, m_cache.channelMap, muted, m_cache.device);
+            writeChanges(m_cache.volume, muted, m_cache.device);
         }
     } else {
         if (m_muted != muted) {
-            writeChanges(m_volume, m_channelMap, muted, m_device);
+            writeChanges(m_volume, muted, m_device);
         }
     }
 }
@@ -161,9 +160,9 @@ void StreamRestore::setChannelVolume(int channel, qint64 volume)
     vol.values[channel] = volume;
 
     if (m_cache.valid) {
-        writeChanges(vol, m_cache.channelMap, m_cache.muted, m_cache.device);
+        writeChanges(vol, m_cache.muted, m_cache.device);
     } else {
-        writeChanges(vol, m_channelMap, m_muted, m_device);
+        writeChanges(vol, m_muted, m_device);
     }
 }
 
@@ -178,21 +177,21 @@ void StreamRestore::setDeviceIndex(quint32 deviceIndex)
     qCWarning(PLASMAPA) << "Not implemented";
 }
 
-void StreamRestore::writeChanges(const pa_cvolume &volume, const pa_channel_map &channelMap, bool muted, const QString &device)
+void StreamRestore::writeChanges(const pa_cvolume &volume, bool muted, const QString &device)
 {
     const QByteArray nameData = m_name.toUtf8();
     const QByteArray deviceData = device.toUtf8();
 
     pa_ext_stream_restore_info info;
     info.name = nameData.constData();
-    info.channel_map = channelMap;
+    info.channel_map.channels = 1;
+    info.channel_map.map[0] = PA_CHANNEL_POSITION_MONO;
     info.volume = volume;
     info.device = deviceData.isEmpty() ? nullptr : deviceData.constData();
     info.mute = muted;
 
     m_cache.valid = true;
     m_cache.volume = volume;
-    m_cache.channelMap = channelMap;
     m_cache.muted = muted;
     m_cache.device = device;
 
diff --git a/src/streamrestore.h b/src/streamrestore.h
index 1c059b7..7131e1c 100644
--- a/src/streamrestore.h
+++ b/src/streamrestore.h
@@ -78,7 +78,7 @@ signals:
     void deviceIndexChanged();
 
 private:
-    void writeChanges(const pa_cvolume &volume, const pa_channel_map &channelMap, bool muted, const QString &device);
+    void writeChanges(const pa_cvolume &volume, bool muted, const QString &device);
 
     QString m_name;
     QString m_device;
@@ -90,7 +90,6 @@ private:
     struct {
         bool valid = false;
         pa_cvolume volume;
-        pa_channel_map channelMap;
         bool muted;
         QString device;
     } m_cache;
-- 
cgit v0.11.2

openSUSE Build Service is sponsored by