我最近开始在C程序中使用PortAudio,但是我在初始化它时遇到了麻烦。 问题出在Pa_Initialize()函数中。
这是我的代码:
#include "portaudio.h" #include #include main() { PaError err; err = Pa_Initialize(); if ( err != paNoError ) goto error; error: Pa_Terminate(); fprintf( stderr, "******* ERROR *******n" ); fprintf( stderr, "Error number: %dn", err ); fprintf( stderr, "Error message: %sn", Pa_GetErrorText( err ) ); return err; }
我收到以下错误:
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave ******* ERROR ******* Error number: 0 Error message: Success
该代码在Linux Mint 17.2和Ubuntu 14.04上进行了尝试。 唯一的区别是在Ubuntu上,最后一行,
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
没有出现。
编辑2:前两行也没有显示在Ubuntu中。
我也试过消除错误的处理,只留下Pa_Initialize(); 在主要function。 正如预期的那样,只有错误消息的最后三行消失了。
我在网上做了一些研究,但找不到有同样问题的人。
PortAudio文档也没有帮助。
编辑1:早些时候,我尝试在Python中使用PyAudio。 虽然它使用PortAudio,但初始化在那里工作。
编辑3:以下代码给我一个“分段错误”消息:
码:
#include "portaudio.h" #include #include main() { PaStreamParameters *inputParameters; PaError err; err = Pa_Initialize(); if ( err != paNoError ) goto error; (*inputParameters).device = Pa_GetDefaultInputDevice(); error: Pa_Terminate(); fprintf( stderr, "******* ERROR *******n" ); fprintf( stderr, "Error number: %dn", err ); fprintf( stderr, "Error message: %sn", Pa_GetErrorText( err ) ); return err; }
消息(最后一行是新的):
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) bt_audio_service_open: connect() failed: Connection refused (111) ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave Segmentation fault
编辑4:在Raspberry Pi 2B上,执行第一个代码时收到以下消息:
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40 ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41 ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50 ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51 ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71 ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream ******* ERROR ******* Error number: 0 Error message: Success
以上就是c/c++开发分享Ubuntu和Raspbian上的Portaudio错误相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/522831.html