tags:

views:

118

answers:

1

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.

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?

+2  A: 

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

Then supply the right number to OpenStream within stream parameter.

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

Tronic
Ugh, time to go compile PortAudio v19 then, I guess :P
Steven Oxley
Actually, v19 alone seems to have fixed my problem - it must selected the PulseAudio back-end by default.
Steven Oxley
the device is usually called default on ubuntu.
Phillip Whelan