代码之家  ›  专栏  ›  技术社区  ›  Steven Oxley

为什么PortAudio不能很好地与其他音频程序一起播放,或者我如何才能让它播放?

  •  2
  • Steven Oxley  · 技术社区  · 16 年前

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

    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.
    

    1 回复  |  直到 16 年前
        1
  •  4
  •   Tronic    16 年前

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

    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);
    }
    

    然后在stream参数内为OpenStream提供正确的编号。

    请注意,您需要PortaudioV19。旧版本的v18只支持OSS。