Hi: I,ve finished this problem using snd_hctl_ apis. code as below: err = snd_hctl_open(&ctlhandle, "default", 0); elemt = snd_hctl_last_elem(ctlhandle); err = snd_hctl_elem_read(elemt, elemvalue); sndvolume0 = snd_ctl_elem_value_get_integer(elemvalue, 0); sndvolume1 = snd_ctl_elem_value_get_integer(elemvalue, 1); //Modified the sndvolume as we want. snd_ctl_elem_value_set_integer(elemvalue, 0, sndvolume0); snd_ctl_elem_value_set_integer(elemvalue, 1, sndvolume1); snd_hctl_elem_write(elemt, elemvalue); snd_hctl_wait(ctlhandle, 100); that code works, but the effect must be in this situations: use snd_hctl_open() after snd_pcm_open(); other the set_value won't work. i don't know why, but i can use this for my code. and that's over of this question.
Hi:
i'm doing some develop on a linux system, kernel version: 2.6.23.9. alsa-lib version:1.0.15.
now ffmpeg and alsa can work together to playback mp3/aac file. during this step:
snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, 0);
set_params(); //set hw and sw params. while(audio_data) { decode_audio_data(&audio_data, &data_len); snd_pcm_writei(audio_data. data_len); } and the mp3 playback is ok, now i'm going to add the volume control functions when the sound is playback.
but when i read the alsa-lib api funtions reference, i can not clearly know how i can control the pcm volume by alsa-lib functions.
and in alsamixer and amixer functions, seems complex to complete the operation. is it has a simple way to control the pcm volume? thanks for any suggestions. Explore the seven wonders of the world Learn more! |
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ Alsa-user mailing list Alsa-user@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/alsa-user