snd_ctl_open失败了。无效的论点

时间:2016-11-23 10:13:17

标签: audio arm debian alsa

我正在开发一个在board嵌入ARM体系结构的声音上运行声音的应用程序,其中存在Debian发行版。

当我尝试打开插入电路板的USB(sound card)时,我会执行以下操作:

    while(1){

    if((err = snd_card_next(&card_num))<0){
        cout << "Can't get next card number" << endl;
        break;
    }
    if(card_num<0) break;

    snd_ctl_t *cardHandle;
    char   str[64];
        sprintf(str, "hw:%i", card_num);

    if ((err = snd_ctl_open(&cardHandle, str, 0)) < 0){
        cout << "Can't open card " << card_num << " , error = " << snd_strerror(err) << endl;
        continue;
    }

    snd_ctl_card_info_t *cardInfo;
        // We need to get a snd_ctl_card_info_t. Just alloc it on the stack
        snd_ctl_card_info_alloca(&cardInfo);

    if ((err = snd_ctl_card_info(cardHandle, cardInfo)) < 0){
        cout << "Can't get info for card " << card_num << endl;
        continue;
    }

        const char *mixer_name = snd_ctl_card_info_get_mixername(cardInfo);


    cout << "Card num " << card_num << " , name = " << snd_ctl_card_info_get_name(cardInfo) << " , mixer = " << mixer_name << endl;
    if(strcmp(mixer_name,"") > 0) {
        current_card_selected = card_num;
    }
    snd_ctl_close(cardHandle);
}

但是操作失败了,我得到了:

&#34;无法打开卡0,错误=无效参数&#34;

&#34;无法打开卡1,错误=无效参数&#34; (这是USB声卡)。

我的想法是str [64]传递被错误地定义为&#34; hw:0,0&#34;或者&#34; hw:1,0&#34; ;但我不知道要查看和更改哪个alsa配置文件。

在我的Ubuntu 16.04 Intel x86_64笔记本电脑上一切正常。

任何提示?提前致谢

0 个答案:

没有答案