Ubuntu和Raspbian上的Portaudio错误

时间:2015-08-23 17:40:20

标签: c linux alsa portaudio

我最近开始在C程序中使用PortAudio,但我在初始化时遇到了麻烦。问题出在 Pa_Initialize()函数。

这是我的代码:

#include "portaudio.h"
#include <stdio.h>
#include <stdlib.h>

main() {

    PaError err;

    err = Pa_Initialize();
    if ( err != paNoError ) goto error;

    error:
        Pa_Terminate();
        fprintf( stderr, "******* ERROR *******\n" );
        fprintf( stderr, "Error number: %d\n", err );
        fprintf( stderr, "Error message: %s\n", 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(); 。正如预期的那样,只有错误消息的最后三行消失了。

我在网上做了一些研究,但找不到有同样问题的人。

PortAudio documentation也没有帮助。

编辑1:早些时候,我尝试在Python中使用PyAudio。虽然它使用PortAudio,但初始化工作在那里。

编辑3:以下代码给出了一个&#34;分段错误&#34;消息:

代码:

#include "portaudio.h"
#include <stdio.h>
#include <stdlib.h>

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: %d\n", err );
        fprintf( stderr, "Error message: %s\n", 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

0 个答案:

没有答案