[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdemultimedia/kmix
From:       Christian Esken <esken () kde ! org>
Date:       2005-02-04 21:33:56
Message-ID: 20050204213356.AD5481D00E () office ! kde ! org
[Download RAW message or body]

CVS commit by esken: 

DCOP calls decreaseVolume() and increaseVolume() are now more precise (by doing better internal rounding).
This fixes the problem with users who experience "strange" results on those DCOP calls.
Also this fixes an interoperability problem with KMilo.
BUG: 66537


  M +38 -0     mixer.cpp   1.89
  M +2 -1      volume.h   1.12


--- kdemultimedia/kmix/mixer.cpp  #1.88:1.89
@@ -31,4 +31,5 @@
 #include "mixer.h"
 #include "kmix-platforms.cpp"
+#include "volume.h"
 
 
@@ -516,6 +517,21 @@ int Mixer::masterVolume()
 void Mixer::increaseVolume( int deviceidx )
 {
+  MixDevice *mixdev= mixDeviceByType( deviceidx );
+  if (mixdev != 0) {
+     Volume vol=mixdev->getVolume();
+     double fivePercent = vol.maxVolume() / 20;
+     for (unsigned int i=Volume::CHIDMIN; i <= Volume::CHIDMAX; i++) {
+        int volToChange = vol.getVolume((Volume::ChannelID)i);
+        if ( fivePercent < 1 ) fivePercent = 1;
+        volToChange += (int)fivePercent;
+        vol.setVolume((Volume::ChannelID)i, volToChange);
+     }
+     writeVolumeToHW(deviceidx, vol);
+  }
+
+  /* see comment at the end of decreaseVolume()
   int vol=volume(deviceidx);
   setVolume(deviceidx, vol+5);
+  */
 }
 
@@ -523,6 +539,28 @@ void Mixer::increaseVolume( int deviceid
 void Mixer::decreaseVolume( int deviceidx )
 {
+  MixDevice *mixdev= mixDeviceByType( deviceidx );
+  if (mixdev != 0) {
+     Volume vol=mixdev->getVolume();
+     double fivePercent = vol.maxVolume() / 20;
+     for (unsigned int i=Volume::CHIDMIN; i <= Volume::CHIDMAX; i++) {
+        int volToChange = vol.getVolume((Volume::ChannelID)i);
+        std::cout << "Mixer::decreaseVolume(): before: volToChange " <<i<< "=" <<volToChange << std::endl;
+        if ( fivePercent < 1 ) fivePercent = 1;
+        volToChange -= (int)fivePercent;
+        std::cout << "Mixer::decreaseVolume():  after: volToChange " <<i<< "=" <<volToChange << std::endl;
+        vol.setVolume((Volume::ChannelID)i, volToChange);
+        int volChanged = vol.getVolume((Volume::ChannelID)i);
+        std::cout << "Mixer::decreaseVolume():  check: volChanged " <<i<< "=" <<volChanged << std::endl;
+     } // for
+     writeVolumeToHW(deviceidx, vol);
+  }
+
+  /************************************************************
+    It is important, not to implement this method like this: this->volume()
   int vol=volume(deviceidx);
   setVolume(deviceidx, vol-5);
+     It creates too big rounding errors. If you don't beleive me, then
+     do a decreaseVolume() and increaseVolume() with "vol.maxVolume() == 31".
+   ***********************************************************/
 }
 

--- kdemultimedia/kmix/volume.h  #1.11:1.12
@@ -21,5 +21,6 @@ class Volume
 
 
- enum ChannelID { LEFT     = 0, RIGHT     = 1, CENTER = 2,
+ enum ChannelID { CHIDMIN  = 0,
+                  LEFT     = 0, RIGHT     = 1, CENTER = 2,
                   REARLEFT = 3, REARRIGHT = 4, WOOFER = 5,
                   LEFTREC  = 6, RIGHTREC  = 7,


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic