李辉才超人回来了下车:Use ALSA lib apis to set the Mic Capture Volu...
来源:百度文库 编辑:中财网 时间:2024/05/09 11:51:51
Use ALSA lib apis to set the Mic Capture Volume
分类: Linux 技术相关 2009-07-23 20:43 591人阅读 评论(0) 收藏 举报下面这个函数的作用相当与 调用ALSA utility amixer 设置 Mic Capture Volume。
#amixer cset name="Mic Capture Volume" 10
[cpp] view plaincopy?
- #include
- static char card[64] = "default";
- BOOL
- CXXXSoundDevice::SetMicCaptureVolume(UINT32 uVolume)
- {
- int err;
- int orig_volume = 0;
- static snd_ctl_t *handle = NULL;
- snd_ctl_elem_info_t *info;
- snd_ctl_elem_id_t *id;
- snd_ctl_elem_value_t *control;
- unsigned int count;
- snd_ctl_elem_type_t type;
- snd_ctl_elem_info_alloca(&info);
- snd_ctl_elem_id_alloca(&id);
- snd_ctl_elem_value_alloca(&control);
- snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);/* default */
- snd_ctl_elem_id_set_name(id, "Mic Capture Volume");
- // snd_ctl_elem_id_set_index(id, 1); // "Mic Capture Volume" does not have index.
- if ((err = snd_ctl_open(&handle, card, 0)) < 0) {
- BTLOGERROR(LCBTLib,"Control %s open error: %s/n", card, snd_strerror(err));
- return FALSE;
- }
- snd_ctl_elem_info_set_id(info, id);
- if ((err = snd_ctl_elem_info(handle, info)) < 0) {
- BTLOGERROR(LCBTLib,"Cannot find the given element from control %s/n", card);
- snd_ctl_close(handle);
- handle = NULL;
- return FALSE;
- }
- type = snd_ctl_elem_info_get_type(info);
- count = snd_ctl_elem_info_get_count(info);
- if(type != SND_CTL_ELEM_TYPE_INTEGER || 1 != count) {
- BTLOGERROR(LCBTLib,"Cannot find the given element from control %s/n", card);
- snd_ctl_close(handle);
- handle = NULL;
- return FALSE;
- }
- snd_ctl_elem_value_set_id(control, id);
- if (!snd_ctl_elem_read(handle, control)) {
- orig_volume = snd_ctl_elem_value_get_integer(control, 0);
- }
- if(uVolume != orig_volume) {
- BTLOGERROR(LCBTLib,"uVolume != orig_volume ##################### new_value(%d) orgin_value(%d)/n",uVolume,orig_volume);
- snd_ctl_elem_value_set_integer(control, 0, static_cast
(uVolume)); - if ((err = snd_ctl_elem_write(handle, control)) < 0) {
- BTLOGERROR(LCBTLib,"Control %s element write error: %s/n", card, snd_strerror(err));
- snd_ctl_close(handle);
- handle = NULL;
- return FALSE;
- }
- }
- snd_ctl_close(handle);
- handle = NULL;
- return TRUE;
- }
谁知道在那里可以下到 linux 的alsa万能驱动的 utils 和lib 包?
how to use 酷狗
how to use 金山词霸?
How to use mp3?
how to use paltalk
how to use been?
Hou to use mp5 beter?
put something to good use
use to be怎么翻译
use......to best advantage是什么意思
get how to use it
How to use English well?
how to use pt to downloading film
什么是APIs~?
翻译 : CSPs connect to the Web via any standard Web server, using fast APIs
use to和use for用法相同吗?
谁能帮我讲讲use to do use to doing used to do 的用法?
how to use" alcohol 120%
anybody know how to use borland c++
how to use"take over'
how to use the real silk correctly
Attemp to use an invalid database pointer
use the clues to complete the puzzle
We can use metal to make Coins.