为什么PortAudio与其他音频程序不能很好地播放,或者如何将其连接? [英] Why does PortAudio not play nicely with other audio programs or how can I get it to?

查看:63
本文介绍了为什么PortAudio与其他音频程序不能很好地播放,或者如何将其连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PortAudio编写音频应用程序,但是如果在尝试运行程序时正在运行任何其他音频程序(通常是Firefox),则会出现以下错误:

I am trying to write an audio application using PortAudio, but if any other audio programs (usually Firefox) are running at the time which I try to run my program, I get the following error:

PaHost_OpenStream: could not open /dev/dsp for O_WRONLY
PaHost_OpenStream: ERROR - result = -10000
An error occured while using the portaudio stream
Error number: -10000
Error message: Host error.

很显然,这使我的程序变得毫无用处,因为如果另一个程序正在使用声音,它将无法正常工作.有办法解决这个问题还是我不​​应该使用PortAudio?

Obviously, this makes my program pretty useless since it won't work if another program is using sound. Is there a way to get around this or should I just not use PortAudio?

推荐答案

您需要为PortAudio选择一个名为"pulse"的设备才能与PulseAudio一起使用,PulseAudio是当今最大的Linux发行版上用于声卡共享的声音服务器..报错提示是尝试使用OSS/dev/dsp接口,完全不支持卡共享.

You need to choose a device named "pulse" for PortAudio to work with PulseAudio, which is the sound server used for sound card sharing on the biggest Linux distros nowadays. The error message suggests that it is trying to use the OSS /dev/dsp interface, which does not support card sharing at all.

您可以使用如下代码列出设备:

You can use code like this for listing the devices:

for (int i = 0, end = Pa_GetDeviceCount(); i != end; ++i) {
    PaDeviceInfo const* info = Pa_GetDeviceInfo(i);
    if (!info) continue;
    printf("%d: %s\n", i, info->name);
}

然后在流参数中为OpenStream提供正确的编号.

Then supply the right number to OpenStream within stream parameter.

请注意,您需要PortAudio v19.较早的v18仅支持OSS.

Notice that you need PortAudio v19. The older v18 only supported OSS.

这篇关于为什么PortAudio与其他音频程序不能很好地播放,或者如何将其连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆