alsa volume fixes
git-svn-id: https://svn.musicpd.org/mpd/trunk@421 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
d6a37ba73e
commit
9c9ce227f5
14
src/volume.c
14
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));
|
||||
|
@ -256,7 +258,11 @@ 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);
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue