Blame SOURCES/0003-Global-Keyboard-Shortcuts-XF86Audio-now-only-affect-.patch

3fe5b5
From ff429cc9fd0889e632a7916b263bed4e4a64d4e1 Mon Sep 17 00:00:00 2001
3fe5b5
From: Christian Esken <esken@kde.org>
3fe5b5
Date: Tue, 5 Feb 2013 00:30:57 +0100
3fe5b5
Subject: [PATCH 3/8] Global Keyboard Shortcuts XF86Audio* now only affect
3fe5b5
 EITHER playback OR capture BUGS: 300783
3fe5b5
3fe5b5
---
3fe5b5
 apps/kmix.cpp      | 10 ++++------
3fe5b5
 core/mixdevice.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
3fe5b5
 core/mixdevice.h   |  1 +
3fe5b5
 gui/mdwslider.cpp  | 46 +++++-----------------------------------------
3fe5b5
 4 files changed, 58 insertions(+), 47 deletions(-)
3fe5b5
3fe5b5
diff --git a/apps/kmix.cpp b/apps/kmix.cpp
3fe5b5
index dd2861a..8e1fa5e 100644
3fe5b5
--- a/apps/kmix.cpp
3fe5b5
+++ b/apps/kmix.cpp
3fe5b5
@@ -1133,12 +1133,10 @@ KMixWindow::increaseOrDecreaseVolume(bool increase)
3fe5b5
   if (md.get() == 0)
3fe5b5
     return; // shouldn't happen, but lets play safe
3fe5b5
 
3fe5b5
-  md->setMuted(false);
3fe5b5
-  if (increase)
3fe5b5
-    mixer->increaseVolume(md->id()); // this is awkward. Better move the increaseVolume impl to the Volume class.
3fe5b5
-  else
3fe5b5
-    mixer->decreaseVolume(md->id());
3fe5b5
-  // md->playbackVolume().increase(); // not yet implemented
3fe5b5
+  Volume::VolumeTypeFlag volumeType = md->playbackVolume().hasVolume() ? Volume::Playback : Volume::Capture;
3fe5b5
+  md->increaseOrDecreaseVolume(!increase, volumeType);
3fe5b5
+  md->mixer()->commitVolumeChange(md);
3fe5b5
+
3fe5b5
   showVolumeDisplay();
3fe5b5
 }
3fe5b5
 
3fe5b5
diff --git a/core/mixdevice.cpp b/core/mixdevice.cpp
3fe5b5
index 662fd85..06b883e 100644
3fe5b5
--- a/core/mixdevice.cpp
3fe5b5
+++ b/core/mixdevice.cpp
3fe5b5
@@ -164,6 +164,54 @@ shared_ptr<MixDevice> MixDevice::addToPool()
3fe5b5
 
3fe5b5
 
3fe5b5
 /**
3fe5b5
+ * Changes the internal state of this MixDevice.
3fe5b5
+ * It does not commit the change to the hardware.
3fe5b5
+ *
3fe5b5
+ * You might want to call something like m_mixdevice->mixer()->commitVolumeChange(m_mixdevice); after calling this method.
3fe5b5
+ */
3fe5b5
+void MixDevice::increaseOrDecreaseVolume(bool decrease, Volume::VolumeTypeFlag volumeType)
3fe5b5
+{
3fe5b5
+	bool debugme =  id() == "PCM:0" ;
3fe5b5
+	if (volumeType & Volume::Playback)
3fe5b5
+	{
3fe5b5
+		kDebug() << "VolumeType=" << volumeType << "   p";
3fe5b5
+		Volume& volP = playbackVolume();
3fe5b5
+		long inc = volP.volumeStep(decrease);
3fe5b5
+
3fe5b5
+		if (debugme)
3fe5b5
+		  kDebug() << ( decrease ? "decrease by " : "increase by " ) << inc ;
3fe5b5
+
3fe5b5
+		if (!decrease && isMuted())
3fe5b5
+		{
3fe5b5
+			// increasing from muted state: unmute and start with a low volume level
3fe5b5
+			if (debugme)
3fe5b5
+				kDebug() << "set all to " << inc << "muted old=" << isMuted();
3fe5b5
+
3fe5b5
+			setMuted(false);
3fe5b5
+			volP.setAllVolumes(inc);
3fe5b5
+		}
3fe5b5
+		else
3fe5b5
+		{
3fe5b5
+			volP.changeAllVolumes(inc);
3fe5b5
+			if (debugme)
3fe5b5
+				kDebug() << (decrease ? "decrease by " : "increase by ") << inc;
3fe5b5
+		}
3fe5b5
+	}
3fe5b5
+
3fe5b5
+	if (volumeType & Volume::Capture)
3fe5b5
+	{
3fe5b5
+		kDebug() << "VolumeType=" << volumeType << "   c";
3fe5b5
+
3fe5b5
+		Volume& volC = captureVolume();
3fe5b5
+		long inc = volC.volumeStep(decrease);
3fe5b5
+		volC.changeAllVolumes(inc);
3fe5b5
+	}
3fe5b5
+
3fe5b5
+}
3fe5b5
+
3fe5b5
+
3fe5b5
+
3fe5b5
+/**
3fe5b5
  * Returns the name of the config group
3fe5b5
  * @param Prefix of the group, e.g. "View_ALSA_USB_01"
3fe5b5
  * @returns The config group name in the format "prefix.mixerId,controlId"
3fe5b5
diff --git a/core/mixdevice.h b/core/mixdevice.h
3fe5b5
index 556f809..177c3b2 100644
3fe5b5
--- a/core/mixdevice.h
3fe5b5
+++ b/core/mixdevice.h
3fe5b5
@@ -216,6 +216,7 @@ public:
3fe5b5
    bool write( KConfig *config, const QString& grp );
3fe5b5
    int getUserfriendlyVolumeLevel();
3fe5b5
 
3fe5b5
+   void increaseOrDecreaseVolume(bool decrease, Volume::VolumeTypeFlag volumeType);
3fe5b5
 
3fe5b5
 
3fe5b5
 protected:
3fe5b5
diff --git a/gui/mdwslider.cpp b/gui/mdwslider.cpp
3fe5b5
index 7c14673..5572d63 100644
3fe5b5
--- a/gui/mdwslider.cpp
3fe5b5
+++ b/gui/mdwslider.cpp
3fe5b5
@@ -959,7 +959,8 @@ void MDWSlider::setDisabled( bool value )
3fe5b5
 
3fe5b5
 
3fe5b5
 /**
3fe5b5
- * This slot is called on a Keyboard Shortcut event.
3fe5b5
+ * This slot is called on a Keyboard Shortcut event, except for the XF86Audio* shortcuts which hare handeled by the
3fe5b5
+ * KMixWindow class. So for 99.9% of all users, this methos is never called.
3fe5b5
  */
3fe5b5
 void MDWSlider::increaseVolume()
3fe5b5
 {
3fe5b5
@@ -967,7 +968,8 @@ void MDWSlider::increaseVolume()
3fe5b5
 }
3fe5b5
 
3fe5b5
 /**
3fe5b5
- * This slot is called on a Keyboard Shortcut event.
3fe5b5
+ * This slot is called on a Keyboard Shortcut event, except for the XF86Audio* shortcuts which hare handeled by the
3fe5b5
+ * KMixWindow class. So for 99.9% of all users, this methos is never called.
3fe5b5
  */
3fe5b5
 void MDWSlider::decreaseVolume()
3fe5b5
 {
3fe5b5
@@ -984,43 +986,7 @@ void MDWSlider::decreaseVolume()
3fe5b5
  */
3fe5b5
 void MDWSlider::increaseOrDecreaseVolume(bool decrease, Volume::VolumeTypeFlag volumeType)
3fe5b5
 {
3fe5b5
-	kDebug() << "VolumeType=" << volumeType;
3fe5b5
-	if (volumeType & Volume::Playback)
3fe5b5
-	{
3fe5b5
-		kDebug() << "VolumeType=" << volumeType << "   p";
3fe5b5
-		Volume& volP = m_mixdevice->playbackVolume();
3fe5b5
-		long inc = volP.volumeStep(decrease);
3fe5b5
-
3fe5b5
-		if ( mixDevice()->id() == "PCM:0" )
3fe5b5
-		  kDebug() << ( decrease ? "decrease by " : "increase by " ) << inc ;
3fe5b5
-
3fe5b5
-		if (!decrease && m_mixdevice->isMuted())
3fe5b5
-		{
3fe5b5
-			// increasing from muted state: unmute and start with a low volume level
3fe5b5
-			if (mixDevice()->id() == "PCM:0")
3fe5b5
-				kDebug() << "set all to " << inc << "muted old=" << m_mixdevice->isMuted();
3fe5b5
-
3fe5b5
-			m_mixdevice->setMuted(false);
3fe5b5
-			volP.setAllVolumes(inc);
3fe5b5
-		}
3fe5b5
-		else
3fe5b5
-		{
3fe5b5
-			volP.changeAllVolumes(inc);
3fe5b5
-			if (mixDevice()->id() == "PCM:0")
3fe5b5
-				kDebug()
3fe5b5
-				<< (decrease ? "decrease by " : "increase by ") << inc;
3fe5b5
-		}
3fe5b5
-	}
3fe5b5
-
3fe5b5
-	if (volumeType & Volume::Capture)
3fe5b5
-	{
3fe5b5
-		kDebug() << "VolumeType=" << volumeType << "   c";
3fe5b5
-
3fe5b5
-		Volume& volC = m_mixdevice->captureVolume();
3fe5b5
-		long inc = volC.volumeStep(decrease);
3fe5b5
-		volC.changeAllVolumes(inc);
3fe5b5
-	}
3fe5b5
-
3fe5b5
+	m_mixdevice->increaseOrDecreaseVolume(decrease, volumeType);
3fe5b5
 	// I should possibly not block, as the changes that come back from the Soundcard
3fe5b5
 	//      will be ignored (e.g. because of capture groups)
3fe5b5
 // 	kDebug() << "MDWSlider is blocking signals for " << m_view->id();
3fe5b5
@@ -1030,8 +996,6 @@ void MDWSlider::increaseOrDecreaseVolume(bool decrease, Volume::VolumeTypeFlag v
3fe5b5
 // 	m_view->blockSignals(oldViewBlockSignalState);
3fe5b5
 }
3fe5b5
 
3fe5b5
-
3fe5b5
-
3fe5b5
 void MDWSlider::moveStreamAutomatic()
3fe5b5
 {
3fe5b5
     m_mixdevice->mixer()->moveStream(m_mixdevice->id(), "");
3fe5b5
-- 
3fe5b5
1.8.1.4
3fe5b5