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
This commit is contained in:
Warren Dukes 2004-04-01 22:11:29 +00:00
parent 8216f304c4
commit b41f540579
1 changed files with 26 additions and 34 deletions

View File

@ -36,13 +36,14 @@
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#endif #endif
#define VOLUME_MIXER_TYPE_SOFTWARE 0 #define VOLUME_MIXER_TYPE_SOFTWARE 0
#define VOLUME_MIXER_TYPE_OSS 1 #define VOLUME_MIXER_TYPE_OSS 1
#define VOLUME_MIXER_TYPE_ALSA 2 #define VOLUME_MIXER_TYPE_ALSA 2
#define VOLUME_MIXER_SOFTWARE_DEFAULT "" #define VOLUME_MIXER_SOFTWARE_DEFAULT ""
#define VOLUME_MIXER_OSS_DEFAULT "/dev/mixer" #define VOLUME_MIXER_OSS_DEFAULT "/dev/mixer"
#define VOLUME_MIXER_ALSA_DEFAULT "default" #define VOLUME_MIXER_ALSA_DEFAULT "default"
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "Master"
int volume_mixerType = VOLUME_MIXER_TYPE_SOFTWARE; int volume_mixerType = VOLUME_MIXER_TYPE_SOFTWARE;
char * volume_mixerDevice; char * volume_mixerDevice;
@ -170,6 +171,7 @@ int changeOssVolumeLevel(FILE * fp, int change, int rel) {
int prepAlsaMixer(char * card) { int prepAlsaMixer(char * card) {
int err; int err;
snd_mixer_elem_t * elem; snd_mixer_elem_t * elem;
char * controlName = VOLUME_MIXER_ALSA_CONTROL_DEFAULT;
if((err = snd_mixer_open(&volume_alsaMixerHandle,0))<0) { if((err = snd_mixer_open(&volume_alsaMixerHandle,0))<0) {
ERROR("problems opening alsa mixer: %s\n",snd_strerror(err)); 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); elem = snd_mixer_first_elem(volume_alsaMixerHandle);
if(getConf()[CONF_MIXER_CONTROL]) { if(getConf()[CONF_MIXER_CONTROL]) {
while(elem) { controlName = getConf()[CONF_MIXER_CONTROL];
if(snd_mixer_elem_get_type(elem) }
==SND_MIXER_ELEM_SIMPLE)
{
if(strcasecmp(getConf()[CONF_MIXER_CONTROL],
snd_mixer_selem_get_name(elem))
==0)
{
break;
}
}
elem = snd_mixer_elem_next(elem);
}
if(elem) { while(elem) {
volume_alsaElem = elem; if(snd_mixer_elem_get_type(elem)==SND_MIXER_ELEM_SIMPLE) {
snd_mixer_selem_get_playback_volume_range( if(strcasecmp(controlName,
volume_alsaElem, snd_mixer_selem_get_name(elem))==0)
&volume_alsaMin,&volume_alsaMax); {
return 0; break;
}
} }
elem = snd_mixer_elem_next(elem);
} }
else {
if(elem) {
volume_alsaElem = elem; volume_alsaElem = elem;
if(snd_mixer_elem_get_type(volume_alsaElem) snd_mixer_selem_get_playback_volume_range(
==SND_MIXER_ELEM_SIMPLE) volume_alsaElem,
{ &volume_alsaMin,&volume_alsaMax);
snd_mixer_selem_get_playback_volume_range( return 0;
volume_alsaElem,
&volume_alsaMin,&volume_alsaMax);
return 0;
}
} }
ERROR("can't find alsa mixer_control \"%s\"\n",controlName);
snd_mixer_close(volume_alsaMixerHandle); snd_mixer_close(volume_alsaMixerHandle);
return -1; return -1;
} }