summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2015-01-12 14:56:42 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2015-01-12 14:56:42 +0100
commitf5bbf06b6067ff582bd7726b2f295292dea33f70 (patch)
treec0b6430382618c72f85ef9db7e061fbf7895843d /device.c
parent6b229d7d5f6377a930191d9ba469b7707b8eb8a5 (diff)
downloadvdr-f5bbf06b6067ff582bd7726b2f295292dea33f70.tar.gz
vdr-f5bbf06b6067ff582bd7726b2f295292dea33f70.tar.bz2
Added the new parameters "Setup/Miscellaneous/Volume steps" and ".../Volume linearize"
Diffstat (limited to 'device.c')
-rw-r--r--device.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/device.c b/device.c
index 869c34a3..f0d6d728 100644
--- a/device.c
+++ b/device.c
@@ -4,11 +4,12 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: device.c 3.16 2015/01/07 12:53:55 kls Exp $
+ * $Id: device.c 3.17 2015/01/12 14:38:23 kls Exp $
*/
#include "device.h"
#include <errno.h>
+#include <math.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include "audio.h"
@@ -918,8 +919,10 @@ void cDevice::SetAudioChannel(int AudioChannel)
void cDevice::SetVolume(int Volume, bool Absolute)
{
int OldVolume = volume;
- volume = constrain(Absolute ? Volume : volume + Volume, 0, MAXVOLUME);
- SetVolumeDevice(volume);
+ double VolumeDelta = double(MAXVOLUME) / Setup.VolumeSteps;
+ double VolumeLinearize = (Setup.VolumeLinearize >= 0) ? (Setup.VolumeLinearize / 10.0 + 1.0) : (1.0 / ((-Setup.VolumeLinearize / 10.0) + 1.0));
+ volume = constrain(int(floor((Absolute ? Volume : volume + Volume) / VolumeDelta + 0.5) * VolumeDelta), 0, MAXVOLUME);
+ SetVolumeDevice(MAXVOLUME - int(pow(1.0 - pow(double(volume) / MAXVOLUME, VolumeLinearize), 1.0 / VolumeLinearize) * MAXVOLUME));
Absolute |= mute;
cStatus::MsgSetVolume(Absolute ? volume : volume - OldVolume, Absolute);
if (volume > 0) {