aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-03-23 21:18:19 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-03-23 21:18:19 +0000
commit9c9ce227f50302379f9cb0d0af517e1a9f1e2b64 (patch)
tree8493cac959969ef0de5e3401b0d5aa9ad93a8dd0
parentd6a37ba73e6caeaa6efb8c78498250bd2317ccdf (diff)
downloadmpd-9c9ce227f50302379f9cb0d0af517e1a9f1e2b64.tar.gz
mpd-9c9ce227f50302379f9cb0d0af517e1a9f1e2b64.tar.xz
mpd-9c9ce227f50302379f9cb0d0af517e1a9f1e2b64.zip
alsa volume fixes
git-svn-id: https://svn.musicpd.org/mpd/trunk@421 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/volume.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/volume.c b/src/volume.c
index 7906acbba..d38a2c2c8 100644
--- a/src/volume.c
+++ b/src/volume.c
@@ -248,6 +248,8 @@ int getAlsaVolumeLevel() {
long min = volume_alsaMin;
int err;
+ snd_mixer_handle_events(volume_alsaMixerHandle);
+
if((err = snd_mixer_selem_get_playback_volume(volume_alsaElem,
SND_MIXER_SCHN_FRONT_LEFT,&level))<0) {
ERROR("problems getting alsa volume: %s\n",snd_strerror(err));
@@ -255,8 +257,12 @@ int getAlsaVolumeLevel() {
}
snd_mixer_selem_get_playback_volume(volume_alsaElem,
- SND_MIXER_SCHN_FRONT_LEFT,&level);
- ret = (int)(100*(((float)(level-min))/(max-min))+0.5);
+ SND_MIXER_SCHN_FRONT_LEFT,&level);
+ ret = ((volume_alsaSet/100.0)*(max-min)+min)+0.5;
+ if(volume_alsaSet>0 && ret==level) {
+ ret = volume_alsaSet;
+ }
+ else ret = (int)(100*(((float)(level-min))/(max-min))+0.5);
return ret;
}
@@ -269,6 +275,8 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
long min = volume_alsaMin;
int err;
+ snd_mixer_handle_events(volume_alsaMixerHandle);
+
if((err = snd_mixer_selem_get_playback_volume(volume_alsaElem,
SND_MIXER_SCHN_FRONT_LEFT,&level))<0) {
myfprintf(fp,"%s problems getting volume\n",
@@ -282,9 +290,7 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
if(volume_alsaSet >= 0 && level==test) {
vol = volume_alsaSet;
}
- else {
- vol = 100.0*(((float)(level-min))/(max-min));
- }
+ else vol = 100.0*(((float)(level-min))/(max-min));
vol+=change;
}
else