diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-04-01 22:11:29 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-04-01 22:11:29 +0000 |
commit | b41f5405792593af471290628b3b7ded74ba2709 (patch) | |
tree | a245b8ef7b42955d5f3cda1f9bd74072a6e6986a /src | |
parent | 8216f304c46060a07d7cd93e9935de26d971c6c4 (diff) | |
download | mpd-b41f5405792593af471290628b3b7ded74ba2709.tar.gz mpd-b41f5405792593af471290628b3b7ded74ba2709.tar.xz mpd-b41f5405792593af471290628b3b7ded74ba2709.zip |
for alsa mixer default to Master element, not the first element
git-svn-id: https://svn.musicpd.org/mpd/trunk@583 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/volume.c | 58 |
1 files changed, 25 insertions, 33 deletions
diff --git a/src/volume.c b/src/volume.c index 74c84a698..da320c57f 100644 --- a/src/volume.c +++ b/src/volume.c @@ -36,13 +36,14 @@ #include <alsa/asoundlib.h> #endif -#define VOLUME_MIXER_TYPE_SOFTWARE 0 -#define VOLUME_MIXER_TYPE_OSS 1 -#define VOLUME_MIXER_TYPE_ALSA 2 +#define VOLUME_MIXER_TYPE_SOFTWARE 0 +#define VOLUME_MIXER_TYPE_OSS 1 +#define VOLUME_MIXER_TYPE_ALSA 2 -#define VOLUME_MIXER_SOFTWARE_DEFAULT "" -#define VOLUME_MIXER_OSS_DEFAULT "/dev/mixer" -#define VOLUME_MIXER_ALSA_DEFAULT "default" +#define VOLUME_MIXER_SOFTWARE_DEFAULT "" +#define VOLUME_MIXER_OSS_DEFAULT "/dev/mixer" +#define VOLUME_MIXER_ALSA_DEFAULT "default" +#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "Master" int volume_mixerType = VOLUME_MIXER_TYPE_SOFTWARE; char * volume_mixerDevice; @@ -170,6 +171,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) { int prepAlsaMixer(char * card) { int err; snd_mixer_elem_t * elem; + char * controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT; if((err = snd_mixer_open(&volume_alsaMixerHandle,0))<0) { ERROR("problems opening alsa mixer: %s\n",snd_strerror(err)); @@ -199,40 +201,30 @@ int prepAlsaMixer(char * card) { elem = snd_mixer_first_elem(volume_alsaMixerHandle); if(getConf()[CONF_MIXER_CONTROL]) { - while(elem) { - if(snd_mixer_elem_get_type(elem) - ==SND_MIXER_ELEM_SIMPLE) + controlName = getConf()[CONF_MIXER_CONTROL]; + } + + while(elem) { + if(snd_mixer_elem_get_type(elem)==SND_MIXER_ELEM_SIMPLE) { + if(strcasecmp(controlName, + snd_mixer_selem_get_name(elem))==0) { - if(strcasecmp(getConf()[CONF_MIXER_CONTROL], - snd_mixer_selem_get_name(elem)) - ==0) - { - break; - } + break; } - elem = snd_mixer_elem_next(elem); - } - - if(elem) { - volume_alsaElem = elem; - snd_mixer_selem_get_playback_volume_range( - volume_alsaElem, - &volume_alsaMin,&volume_alsaMax); - return 0; } + elem = snd_mixer_elem_next(elem); } - else { + + if(elem) { volume_alsaElem = elem; - if(snd_mixer_elem_get_type(volume_alsaElem) - ==SND_MIXER_ELEM_SIMPLE) - { - snd_mixer_selem_get_playback_volume_range( - volume_alsaElem, - &volume_alsaMin,&volume_alsaMax); - return 0; - } + snd_mixer_selem_get_playback_volume_range( + volume_alsaElem, + &volume_alsaMin,&volume_alsaMax); + return 0; } + ERROR("can't find alsa mixer_control \"%s\"\n",controlName); + snd_mixer_close(volume_alsaMixerHandle); return -1; } |