diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-03-23 20:34:12 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-03-23 20:34:12 +0000 |
commit | d6a37ba73e6caeaa6efb8c78498250bd2317ccdf (patch) | |
tree | 32b1a5c9275e0105667e4e317b07465150fb645b /src/volume.c | |
parent | fc84fa54fccbee2e9cf3fe4fbaa4089500c24ab1 (diff) | |
download | mpd-d6a37ba73e6caeaa6efb8c78498250bd2317ccdf.tar.gz mpd-d6a37ba73e6caeaa6efb8c78498250bd2317ccdf.tar.xz mpd-d6a37ba73e6caeaa6efb8c78498250bd2317ccdf.zip |
volume fixes
git-svn-id: https://svn.musicpd.org/mpd/trunk@420 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/volume.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/volume.c b/src/volume.c index 16f130650..7906acbba 100644 --- a/src/volume.c +++ b/src/volume.c @@ -47,6 +47,8 @@ int volume_mixerType = VOLUME_MIXER_TYPE_SOFTWARE; char * volume_mixerDevice; +int volume_softwareSet = -1; + #ifndef NO_OSS_MIXER int volume_ossFd; int volume_ossControl = SOUND_MIXER_VOLUME; @@ -57,6 +59,7 @@ snd_mixer_t * volume_alsaMixerHandle = NULL; snd_mixer_elem_t * volume_alsaElem; long volume_alsaMin; long volume_alsaMax; +int volume_alsaSet = -1; #endif #ifndef NO_OSS_MIXER @@ -261,6 +264,7 @@ int getAlsaVolumeLevel() { int changeAlsaVolumeLevel(FILE * fp, int change, int rel) { float vol; long level; + long test; long max = volume_alsaMax; long min = volume_alsaMin; int err; @@ -274,12 +278,22 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) { } if (rel) { - vol = 100.0*(((float)(level-min))/(max-min)); + test = ((volume_alsaSet/100.0)*(max-min)+min)+0.5; + if(volume_alsaSet >= 0 && level==test) { + vol = volume_alsaSet; + } + else { + vol = 100.0*(((float)(level-min))/(max-min)); + } vol+=change; } else vol = change; + volume_alsaSet = vol+0.5; + volume_alsaSet = volume_alsaSet>100 ? 100 : + (volume_alsaSet<0 ? 0 : volume_alsaSet); + level = (long)(((vol/100.0)*(max-min)+min)+0.5); level = level>max?max:level; level = level<min?min:level; @@ -361,6 +375,10 @@ void openVolumeDevice() { } int getSoftwareVolume() { + if(volume_softwareSet >= 0) { + return volume_softwareSet; + } + return 50*log((getPlayerSoftwareVolume()*(M_E*M_E-1)/100.0)+1)+0.5; } @@ -389,6 +407,8 @@ int changeSoftwareVolume(FILE * fp, int change, int rel) { if(new>100) new = 100; else if(new<0) new = 0; + volume_softwareSet = new; + new = 100.0*(exp(new/50.0)-1)/(M_E*M_E-1)+0.5; setPlayerSoftwareVolume(new); |