File 0004-StreamRestore-Don-t-write-unnecessary-changes.patch of Package plasma5-pa

From 663a591fd47f27d912216073fd6ccb6ac9949e59 Mon Sep 17 00:00:00 2001
From: David Rosca <nowrep@gmail.com>
Date: Sat, 29 Apr 2017 18:39:47 +0200
Subject: [PATCH 4/4] StreamRestore: Don't write unnecessary changes

Applet updates mute state with every volume change - it does
writeChanges(volume) immediately following with writeChanges(mute)
and it seems to make PulseAudio to ignore the volume change.
This makes sure that writeChanges() is only called when something really
changed.

BUG: 367688
FIXED-IN: 5.10.0

Differential Revision: https://phabricator.kde.org/D5657
---
 src/streamrestore.cpp | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/streamrestore.cpp b/src/streamrestore.cpp
index f04b75a..f1aa325 100644
--- a/src/streamrestore.cpp
+++ b/src/streamrestore.cpp
@@ -82,9 +82,13 @@ QString StreamRestore::device() const
 void StreamRestore::setDevice(const QString &device)
 {
     if (m_cache.valid) {
-        writeChanges(m_cache.volume, m_cache.channelMap, m_cache.muted, device);
+        if (m_cache.device != device) {
+            writeChanges(m_cache.volume, m_cache.channelMap, m_cache.muted, device);
+        }
     } else {
-        writeChanges(m_volume, m_channelMap, m_muted, device);
+        if (m_device != device) {
+            writeChanges(m_volume, m_channelMap, m_muted, device);
+        }
     }
 }
 
@@ -115,9 +119,13 @@ bool StreamRestore::isMuted() const
 void StreamRestore::setMuted(bool muted)
 {
     if (m_cache.valid) {
-        writeChanges(m_cache.volume, m_cache.channelMap, muted, m_cache.device);
+        if (m_cache.muted != muted) {
+            writeChanges(m_cache.volume, m_cache.channelMap, muted, m_cache.device);
+        }
     } else {
-        writeChanges(m_volume, m_channelMap, muted, m_device);
+        if (m_muted != muted) {
+            writeChanges(m_volume, m_channelMap, muted, m_device);
+        }
     }
 }
 
-- 
2.12.0

openSUSE Build Service is sponsored by