Quote:
Originally Posted by geekmaster
Considering that "wince" is the English word for a facial expression that is often used to express pain or great displeasure, Perhaps WinCE is aptly named. 
|
Alsamixer is notoriously poor. the 13.1 Slackware kernel includes a version that is so bad if you use it you have to reboot the machine to get the INPUT working again on some devices.... Sound familiar? Don't even start me on the buggy monitoring and forgotten settings...
I would advise strongly against ever using (it in it's current state, which seems fairly stable at "poor"). There are better ways, I did include Alsamixer in my tips - but I also prefaced with - "If it's anything like my one it will be rubbish".
YMMV but it won't be high.
Spoiler:
Code:
void SetAlsaMasterVolume(long volume)
{
long min, max;
snd_mixer_t *handle;
snd_mixer_selem_id_t *sid;
const char *card = "default";
const char *selem_name = "Master";
snd_mixer_open(&handle, 0);
snd_mixer_attach(handle, card);
snd_mixer_selem_register(handle, NULL, NULL);
snd_mixer_load(handle);
snd_mixer_selem_id_alloca(&sid);
snd_mixer_selem_id_set_index(sid, 0);
snd_mixer_selem_id_set_name(sid, selem_name);
snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);
snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
snd_mixer_selem_set_playback_volume_all(elem, volume * max / 100);
snd_mixer_close(handle);
}
http://www.alsa-project.org/alsa-doc...ple_mixer.html
Fails becase there is no "mixer" component declared by the alsa
Spoiler:
Code:
int SetAlsaMasterVolume(audio_volume_action action, long* outvol)
{
int ret = 0;
int fd, devs;
snd_mixer_t* handle;
snd_mixer_elem_t* elem;
snd_mixer_selem_id_t* sid;
static const char* mix_name = "Master";
static const char* card = "default";
static int mix_index = 0;
long pmin, pmax;
long get_vol, set_vol;
float f_multi;
snd_mixer_selem_id_alloca(&sid);
//sets simple-mixer index and name
snd_mixer_selem_id_set_index(sid, mix_index);
snd_mixer_selem_id_set_name(sid, mix_name);
if ((snd_mixer_open(&handle, 0)) < 0) return -1;
if ((snd_mixer_attach(handle, card)) < 0) {
snd_mixer_close(handle);
return -2;
}
if ((snd_mixer_selem_register(handle, NULL, NULL)) < 0) {
snd_mixer_close(handle);
return -3;
}
ret = snd_mixer_load(handle);
if (ret < 0) {
snd_mixer_close(handle);
return -4;
}
elem = snd_mixer_find_selem(handle, sid);
if (!elem) {
snd_mixer_close(handle);
return -5;
}
long minv, maxv;
snd_mixer_selem_get_playback_volume_range (elem, &minv, &maxv);
fprintf(stderr, "Volume range <%i,%i>\n", minv, maxv);
if(action == AUDIO_VOLUME_GET) {
if(snd_mixer_selem_get_playback_volume(elem, 0, outvol) < 0) {
snd_mixer_close(handle);
return -6;
}
fprintf(stderr, "Get volume %i with status %i\n", *outvol, ret);
/* make the value bound to 100 */
*outvol -= minv;
maxv -= minv;
minv = 0;
*outvol = 100 * (*outvol) / maxv; // make the value bound from 0 to 100
}
else if(action == AUDIO_VOLUME_SET) {
if(*outvol < 0 || *outvol > VOLUME_BOUND) // out of bounds
return -7;
*outvol = (*outvol * (maxv - minv) / (100-1)) + minv;
if(snd_mixer_selem_set_playback_volume(elem, 0, *outvol) < 0) {
snd_mixer_close(handle);
return -8;
}
if(snd_mixer_selem_set_playback_volume(elem, 1, *outvol) < 0) {
snd_mixer_close(handle);
return -9;
}
fprintf(stderr, "Set volume %i with status %i\n", *outvol, ret);
}
snd_mixer_close(handle);
return 0;
}
Fails for the same reason.
I suspect we need to do the alsactl setup satisfactorily before the programmatic side will work. One for my pile perhaps once I have this fft thingy happening.
Apologies that it is crappy, I can confirm it tried to mute the sound on mine too, fortunately I knew to go thru the settings one by one to reset them to play - while another shell played music, until I found the culprit, which on this occasion looked to be the actual master volume

sigh.
definitely a flaky app, that will be best bypassed in the medium term via the code I have posted above.