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
16
src/volume.c
16
src/volume.c
|
@ -248,6 +248,8 @@ int getAlsaVolumeLevel() {
|
||||||
long min = volume_alsaMin;
|
long min = volume_alsaMin;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
snd_mixer_handle_events(volume_alsaMixerHandle);
|
||||||
|
|
||||||
if((err = snd_mixer_selem_get_playback_volume(volume_alsaElem,
|
if((err = snd_mixer_selem_get_playback_volume(volume_alsaElem,
|
||||||
SND_MIXER_SCHN_FRONT_LEFT,&level))<0) {
|
SND_MIXER_SCHN_FRONT_LEFT,&level))<0) {
|
||||||
ERROR("problems getting alsa volume: %s\n",snd_strerror(err));
|
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_selem_get_playback_volume(volume_alsaElem,
|
||||||
SND_MIXER_SCHN_FRONT_LEFT,&level);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -269,6 +275,8 @@ int changeAlsaVolumeLevel(FILE * fp, int change, int rel) {
|
||||||
long min = volume_alsaMin;
|
long min = volume_alsaMin;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
snd_mixer_handle_events(volume_alsaMixerHandle);
|
||||||
|
|
||||||
if((err = snd_mixer_selem_get_playback_volume(volume_alsaElem,
|
if((err = snd_mixer_selem_get_playback_volume(volume_alsaElem,
|
||||||
SND_MIXER_SCHN_FRONT_LEFT,&level))<0) {
|
SND_MIXER_SCHN_FRONT_LEFT,&level))<0) {
|
||||||
myfprintf(fp,"%s problems getting volume\n",
|
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) {
|
if(volume_alsaSet >= 0 && level==test) {
|
||||||
vol = volume_alsaSet;
|
vol = volume_alsaSet;
|
||||||
}
|
}
|
||||||
else {
|
else vol = 100.0*(((float)(level-min))/(max-min));
|
||||||
vol = 100.0*(((float)(level-min))/(max-min));
|
|
||||||
}
|
|
||||||
vol+=change;
|
vol+=change;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue