summaryrefslogtreecommitdiffstats
path: root/kmix/mixer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmix/mixer.cpp')
-rw-r--r--kmix/mixer.cpp76
1 files changed, 46 insertions, 30 deletions
diff --git a/kmix/mixer.cpp b/kmix/mixer.cpp
index 9e3aa359..0cc4fbcf 100644
--- a/kmix/mixer.cpp
+++ b/kmix/mixer.cpp
@@ -514,6 +514,9 @@ void Mixer::setVolume( int deviceidx, int percentage )
// @todo The next call doesn't handle negative volumes correctly.
vol.setAllVolumes( (percentage*vol.maxVolume())/100 );
_mixerBackend->writeVolumeToHW(deviceidx, vol);
+ // Make sure volume reading is synced
+ readSetFromHWforceUpdate();
+ TQTimer::singleShot(50, this, TQT_SLOT(readSetFromHW()));
}
/**
@@ -579,12 +582,15 @@ void Mixer::setAbsoluteVolume( int deviceidx, long absoluteVolume ) {
Volume vol=mixdev->getVolume();
vol.setAllVolumes( absoluteVolume );
_mixerBackend->writeVolumeToHW(deviceidx, vol);
+ // Make sure volume reading is synced
+ readSetFromHWforceUpdate();
+ TQTimer::singleShot(50, this, TQT_SLOT(readSetFromHW()));
}
// @dcop , especially for use in KMilo
-long Mixer::absoluteVolume( int deviceidx )
+long Mixer::absoluteVolume(int deviceidx)
{
- MixDevice *mixdev= mixDeviceByType( deviceidx );
+ MixDevice *mixdev= mixDeviceByType(deviceidx);
if (!mixdev) return 0;
Volume vol=mixdev->getVolume();
@@ -593,9 +599,9 @@ long Mixer::absoluteVolume( int deviceidx )
}
// @dcop , especially for use in KMilo
-long Mixer::absoluteVolumeMax( int deviceidx )
+long Mixer::absoluteVolumeMax(int deviceidx)
{
- MixDevice *mixdev= mixDeviceByType( deviceidx );
+ MixDevice *mixdev= mixDeviceByType(deviceidx);
if (!mixdev) return 0;
Volume vol=mixdev->getVolume();
@@ -604,9 +610,9 @@ long Mixer::absoluteVolumeMax( int deviceidx )
}
// @dcop , especially for use in KMilo
-long Mixer::absoluteVolumeMin( int deviceidx )
+long Mixer::absoluteVolumeMin(int deviceidx)
{
- MixDevice *mixdev= mixDeviceByType( deviceidx );
+ MixDevice *mixdev= mixDeviceByType(deviceidx);
if (!mixdev) return 0;
Volume vol=mixdev->getVolume();
@@ -626,44 +632,54 @@ int Mixer::masterVolume()
}
// @dcop
-void Mixer::increaseVolume( int deviceidx )
+void Mixer::increaseVolume(int deviceidx, int percentage)
{
- MixDevice *mixdev= mixDeviceByType( deviceidx );
- if (mixdev != 0)
+ MixDevice *mixdev= mixDeviceByType(deviceidx);
+ if (mixdev && percentage > 0)
{
Volume vol = mixdev->getVolume();
- long inc = vol.maxVolume() / 20;
- if (inc == 0)
- {
- inc = 1;
- }
- for (int i = 0; i < vol.count(); i++)
+ long maxVol = vol.maxVolume();
+ if (maxVol > 0)
{
- long newVal = (vol[i]) + inc;
- mixdev->setVolume(i, newVal < vol.maxVolume() ? newVal : vol.maxVolume());
+ for (int i = 0; i < vol.count(); i++)
+ {
+ double perc = 100.0 * vol[i] / maxVol;
+ perc += percentage;
+ if (perc > 100.0)
+ {
+ perc = 100.0;
+ }
+ long newVal = (long)(perc * maxVol / 100.0);
+ mixdev->setVolume(i, newVal);
+ }
+ commitVolumeChange(mixdev);
}
- commitVolumeChange(mixdev);
}
}
// @dcop
-void Mixer::decreaseVolume( int deviceidx )
+void Mixer::decreaseVolume(int deviceidx, int percentage)
{
- MixDevice *mixdev= mixDeviceByType( deviceidx );
- if (mixdev != 0)
+ MixDevice *mixdev= mixDeviceByType(deviceidx);
+ if (mixdev && percentage > 0)
{
Volume vol = mixdev->getVolume();
- long inc = vol.maxVolume() / 20;
- if (inc == 0)
- {
- inc = 1;
- }
- for (int i = 0; i < vol.count(); i++)
+ long maxVol = vol.maxVolume();
+ if (maxVol > 0)
{
- long newVal = (vol[i]) - inc;
- mixdev->setVolume(i, newVal > 0 ? newVal : 0);
+ for (int i = 0; i < vol.count(); i++)
+ {
+ double perc = 100.0 * vol[i] / maxVol;
+ perc -= percentage;
+ if (perc < 0.0)
+ {
+ perc = 0.0;
+ }
+ long newVal = (long)(perc * maxVol / 100.0);
+ mixdev->setVolume(i, newVal);
+ }
+ commitVolumeChange(mixdev);
}
- commitVolumeChange(mixdev);
}
}