运行portaudio示例时Ubuntu中的错误

时间:2015-02-22 03:41:48

标签: c ubuntu audio alsa portaudio

我在Ubuntu 14.04上安装了portaudio并编译了一个测试程序,如下所示:

gcc -o Test3c Test3c.c ../libportaudio.a -lrt -lasound -ljack -lpthread -lm

没有错误。 (Test3c.c与包含的pa_devs.c相同,可以找到here。)但是当我运行它时,

./Test3c

我明白了:

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)
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
PortAudio version number = 1899
PortAudio version text = 'PortAudio V19-devel (built Feb 14 2015 11:51:22)'
Number of devices = 20
--------------------------------------- device #0
Name                        = HDA Intel PCH: ALC892 Analog (hw:0,0)
Host API                    = ALSA
Max inputs = 2, Max outputs = 6
Default low input latency   =   0.0058
Default low output latency  =   0.0087
Default high input latency  =   0.0348
Default high output latency =   0.0348
Default sample rate         = 44100.00
Supported standard sample rates
 for half-duplex 16 bit 2 channel input = 
    44100.00, 48000.00, 96000.00, 192000.00
Supported standard sample rates
 for half-duplex 16 bit 6 channel output = 
None
Supported standard sample rates
 for full-duplex 16 bit 2 channel input, 6 channel output = 
None
--------------------------------------- device #1
Name                        = HDA Intel PCH: ALC892 Digital (hw:0,1)
Host API                    = ALSA
Max inputs = 0, Max outputs = 2
Default low input latency   =  -1.0000
Default low output latency  =   0.0058
Default high input latency  =  -1.0000
Default high output latency =   0.0348
Default sample rate         = 44100.00
Supported standard sample rates
 for half-duplex 16 bit 2 channel output = 
    32000.00, 44100.00, 48000.00, 88200.00,
    96000.00, 192000.00
--------------------------------------- device #2
Name                        = HDA Intel PCH: ALC892 Alt Analog (hw:0,2)
Host API                    = ALSA
Max inputs = 2, Max outputs = 0
Default low input latency   =   0.0058
Default low output latency  =  -1.0000
Default high input latency  =   0.0348
Default high output latency =  -1.0000
Default sample rate         = 44100.00
Supported standard sample rates
 for half-duplex 16 bit 2 channel input = 
    44100.00, 48000.00, 96000.00, 192000.00
--------------------------------------- device #3
Name                        = HDA NVidia: HDMI 0 (hw:1,3)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default low input latency   =  -1.0000
Default low output latency  =   0.0058
Default high input latency  =  -1.0000
Default high output latency =   0.0348
Default sample rate         = 44100.00
Supported standard sample rates
 for half-duplex 16 bit 8 channel output = 
    32000.00, 44100.00, 48000.00, 88200.00,
    96000.00, 192000.00
--------------------------------------- device #4
Name                        = HDA NVidia: HDMI 0 (hw:1,7)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default low input latency   =  -1.0000
Default low output latency  =   0.0058
Default high input latency  =  -1.0000
Default high output latency =   0.0348
Default sample rate         = 44100.00
Supported standard sample rates
 for half-duplex 16 bit 8 channel output = 
    32000.00, 44100.00, 48000.00, 88200.00,
    96000.00, 192000.00
--------------------------------------- device #5
Name                        = HDA NVidia: HDMI 0 (hw:1,8)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default low input latency   =  -1.0000
Default low output latency  =   0.0058
Default high input latency  =  -1.0000
Default high output latency =   0.0348
Default sample rate         = 44100.00
Supported standard sample rates
 for half-duplex 16 bit 8 channel output = 
    32000.00, 44100.00, 48000.00, 88200.00,
    96000.00, 192000.00
--------------------------------------- device #6
Name                        = HDA NVidia: HDMI 0 (hw:1,9)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default low input latency   =  -1.0000
Default low output latency  =   0.0058
Default high input latency  =  -1.0000
Default high output latency =   0.0348
Default sample rate         = 44100.00
Supported standard sample rates
 for half-duplex 16 bit 8 channel output = 
    32000.00, 44100.00, 48000.00, 88200.00,
    96000.00, 192000.00
--------------------------------------- device #7
Name                        = sysdefault
Host API                    = ALSA
Max inputs = 128, Max outputs = 128
Default low input latency   =   0.0213
Default low output latency  =   0.0213
Default high input latency  =   0.0213
Default high output latency =   0.0213
Default sample rate         = 48000.00
Supported standard sample rates
 for half-duplex 16 bit 128 channel input = 
     8000.00,  9600.00, 11025.00, 16000.00,
    22050.00, 32000.00, 44100.00, 48000.00,
    88200.00
Supported standard sample rates
 for half-duplex 16 bit 128 channel output = 
     8000.00,  9600.00, 11025.00, 16000.00,
    22050.00, 32000.00, 44100.00, 48000.00,
    88200.00
Supported standard sample rates
 for full-duplex 16 bit 128 channel input, 128 channel output = 
     8000.00,  9600.00, 11025.00, 16000.00,
    22050.00, 32000.00, 44100.00, 48000.00,
    88200.00
--------------------------------------- device #8
Name                        = front
Host API                    = ALSA
Max inputs = 0, Max outputs = 6
Default low input latency   =  -1.0000
Default low output latency  =   0.0058
Default high input latency  =  -1.0000
Default high output latency =   0.0348
Default sample rate         = 44100.00
Supported standard sample rates
 for half-duplex 16 bit 6 channel output = 
Test3c: pcm_params.c:2249: snd1_pcm_hw_params_slave: Assertion `err >= 0' failed.
Aborted (core dumped)

当调用Pa_IsFormatSupported()时,它会在列出设备的过程中崩溃。 Google告诉我“pcm_params.c”是指ALSA库。有没有人找到解决这类问题的方法?

3 个答案:

答案 0 :(得分:1)

所以我认为我找到了解决方案。在最近的错误之后,我注意到建议以不同的音频问题here以下列方式重新启动音频驱动程序:

pulseaudio -k && sudo alsa force-reload

我做到了,然后尝试运行已编译的程序,并再次出错(我想我不耐烦了)。然后我第二次做了这个命令,现在它可以工作了。

更新:一段时间后,我再次收到错误,并且必须重新启动驱动程序。

答案 1 :(得分:1)

目前我是Portaudio-linux主机的维护者,刚刚在这里遇到了这个问题。在Portaudio邮件列表上报告了同样的问题并进行了调查。断言在Alsa-lib中,现在已由Alsa开发人员删除,以支持错误返回。参见

http://git.alsa-project.org/?p=alsa-lib.git;a=commit;h=67f73b0fab466e780dcc0442e19894a1cbedc43b

某些设备似乎导致“前”(和其他一些)PCM上的6声道出现问题。这不是Portaudio的错,但是当它探测设备和PCM的功能时,它暴露了Alsa系统内的问题。断言断言后,它现在就失败了。

答案 2 :(得分:0)

我遇到了同样的问题并通过修复/ usr / share / alsa / pcm中的一些错误的pcm定义来解决它。在朝向文件底部的路径部分中,卡驱动程序引用的是与文件中定义的pcm不同的pcm。