Discussion:
[Portaudio] OpenStream function succeeds but no audio
S Jagannathan
2008-01-05 07:48:54 UTC
Permalink
Hello all,

I use Pa_OpenStream to open an output audio stream. The function
succeeds but I get an internal error as follows and I cannot hear any
audio. Can you please suggest why this happening?

Thank you
Jagan.
output from my program >>>
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 877
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir,
&self->pcm )'
failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 1016
Expression 'PaAlsaStreamComponent_Initialize( &self->playback,
alsaApi, outParam
s, StreamDirection_Out, NULL !=
callback )' failed in 'src/hostapi/alsa/pa_linux

_alsa.c', line: 1223
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi,
inputParameters, outpu
tParameters, sampleRate,
framesPerBuffer, callback, streamFlags, userData )' fai

led in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1786
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 877
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir,
&self->pcm )'
failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 1016
Expression 'PaAlsaStreamComponent_Initialize( &self->playback,
alsaApi, outParam
s, StreamDirection_Out, NULL !=
callback )' failed in 'src/hostapi/alsa/pa_linux

_alsa.c', line: 1223
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi,
inputParameters, outpu
tParameters, sampleRate,
framesPerBuffer, callback, streamFlags, userData )' fai

led in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1786
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 877
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir,
&self->pcm )'
failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 1016
Expression 'PaAlsaStreamComponent_Initialize( &self->playback,
alsaApi, outParam
s, StreamDirection_Out, NULL !=
callback )' failed in 'src/hostapi/alsa/pa_linux

_alsa.c', line: 1223
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi,
inputParameters, outpu
tParameters, sampleRate,
framesPerBuffer, callback, streamFlags, userData )' fai

led in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1786
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 877
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir,
&self->pcm )'
failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 1016
Expression 'PaAlsaStreamComponent_Initialize( &self->playback,
alsaApi, outParam
s, StreamDirection_Out, NULL !=
callback )' failed in 'src/hostapi/alsa/pa_linux

_alsa.c', line: 1223
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi,
inputParameters, outpu
tParameters, sampleRate,
framesPerBuffer, callback, streamFlags, userData )' fai

led in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1786
mesgs below from my program
inited output audio stream
started output audio stream
Arve Knudsen
2008-01-05 14:55:36 UTC
Permalink
Hi Jagan
Post by S Jagannathan
Hello all,
I use Pa_OpenStream to open an output audio stream. The function
succeeds but I get an internal error as follows and I cannot hear any
audio. Can you please suggest why this happening?
Are you sure the function succeeds? From your error message I would think
that it returns an error code. I'm guessing that it's due to the device
being busy.

Arve
Post by S Jagannathan
Thank you
Jagan.
output from my program >>>
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 877
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir,
&self->pcm )'
failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 1016
Expression 'PaAlsaStreamComponent_Initialize( &self->playback,
alsaApi, outParam
s, StreamDirection_Out, NULL !=
callback )' failed in 'src/hostapi/alsa/pa_linux
_alsa.c', line: 1223
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi,
inputParameters, outpu
tParameters, sampleRate,
framesPerBuffer, callback, streamFlags, userData )' fai
led in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1786
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 877
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir,
&self->pcm )'
failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 1016
Expression 'PaAlsaStreamComponent_Initialize( &self->playback,
alsaApi, outParam
s, StreamDirection_Out, NULL !=
callback )' failed in 'src/hostapi/alsa/pa_linux
_alsa.c', line: 1223
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi,
inputParameters, outpu
tParameters, sampleRate,
framesPerBuffer, callback, streamFlags, userData )' fai
led in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1786
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 877
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir,
&self->pcm )'
failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 1016
Expression 'PaAlsaStreamComponent_Initialize( &self->playback,
alsaApi, outParam
s, StreamDirection_Out, NULL !=
callback )' failed in 'src/hostapi/alsa/pa_linux
_alsa.c', line: 1223
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi,
inputParameters, outpu
tParameters, sampleRate,
framesPerBuffer, callback, streamFlags, userData )' fai
led in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1786
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 877
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir,
&self->pcm )'
failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 1016
Expression 'PaAlsaStreamComponent_Initialize( &self->playback,
alsaApi, outParam
s, StreamDirection_Out, NULL !=
callback )' failed in 'src/hostapi/alsa/pa_linux
_alsa.c', line: 1223
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi,
inputParameters, outpu
tParameters, sampleRate,
framesPerBuffer, callback, streamFlags, userData )' fai
led in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1786
mesgs below from my program
inited output audio stream
started output audio stream
_______________________________________________
Portaudio mailing list
http://music.columbia.edu/mailman/listinfo/portaudio
S Jagannathan
2008-01-06 18:45:12 UTC
Permalink
Post by Arve Knudsen
Are you sure the function succeeds? From your error message I would think
that it returns an error code. I'm guessing that it's due to the device
being busy.
Arve
you are right. when I play an audio file in the background thru
mplayer, the function fails. it succeeds otherwise. but i have
noticed that i can launch two mplayer instances and get it to play two
different audio files. cant i not launch two instances of my program
and output audio?

regards
jagan.
hardware supports stereo @ 48000
number of devices = 6
max output channels = 0
latency = 0
Expression 'ValidateParameters( outputParameters, outputDeviceInfo,
StreamMode_Out )' failed in 'src/hostapi/oss/pa_unix_oss.c', line:
1206
error on device 0 error code = -9998
max output channels = 0
latency = -1
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 776
Expression 'ValidateParameters( outputParameters, hostApi,
StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
line: 1771
error on device 1 error code = -9998
max output channels = 0
latency = -1
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 776
Expression 'ValidateParameters( outputParameters, hostApi,
StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
line: 1771
error on device 2 error code = -9998
max output channels = 0
latency = -1
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 776
Expression 'ValidateParameters( outputParameters, hostApi,
StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
line: 1771
error on device 3 error code = -9998
max output channels = 0
latency = -1
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 776
Expression 'ValidateParameters( outputParameters, hostApi,
StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
line: 1771
error on device 4 error code = -9998
max output channels = 0
latency = -1
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 776
Expression 'ValidateParameters( outputParameters, hostApi,
StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
line: 1771
error on device 5 error code = -9998
Arve Knudsen
2008-01-06 19:06:26 UTC
Permalink
Post by S Jagannathan
Post by Arve Knudsen
Are you sure the function succeeds? From your error message I would think
that it returns an error code. I'm guessing that it's due to the device
being busy.
Arve
you are right. when I play an audio file in the background thru
mplayer, the function fails. it succeeds otherwise. but i have
noticed that i can launch two mplayer instances and get it to play two
different audio files. cant i not launch two instances of my program
and output audio?
The problem is that "by default", ALSA will only let one process at a time
open a device. To work around that, they offer the "dmix" software device,
which mixes output of different processes. MPlayer probably uses dmix,
maybe via OSS. PA should offer the device "default" as the default
playback device, which in turn should use dmix. Which device are you using
through PA? You might also want to use the latest version of PA, if you're
not already doing so.

Arve
Post by S Jagannathan
number of devices = 6
max output channels = 0
latency = 0
Expression 'ValidateParameters( outputParameters, outputDeviceInfo,
1206
error on device 0 error code = -9998
max output channels = 0
latency = -1
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 776
Expression 'ValidateParameters( outputParameters, hostApi,
StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
line: 1771
error on device 1 error code = -9998
max output channels = 0
latency = -1
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 776
Expression 'ValidateParameters( outputParameters, hostApi,
StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
line: 1771
error on device 2 error code = -9998
max output channels = 0
latency = -1
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 776
Expression 'ValidateParameters( outputParameters, hostApi,
StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
line: 1771
error on device 3 error code = -9998
max output channels = 0
latency = -1
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 776
Expression 'ValidateParameters( outputParameters, hostApi,
StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
line: 1771
error on device 4 error code = -9998
max output channels = 0
latency = -1
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 776
Expression 'ValidateParameters( outputParameters, hostApi,
StreamDirection_Out )' failed in 'src/hostapi/alsa/pa_linux_alsa.c',
line: 1771
error on device 5 error code = -9998
S Jagannathan
2008-01-07 07:08:46 UTC
Permalink
Post by Arve Knudsen
The problem is that "by default", ALSA will only let one process at a time
open a device. To work around that, they offer the "dmix" software device,
which mixes output of different processes. MPlayer probably uses dmix,
maybe via OSS. PA should offer the device "default" as the default
playback device, which in turn should use dmix. Which device are you using
through PA? You might also want to use the latest version of PA, if you're
not already doing so.
i used Pa_OpenDefaultStream but that would not let me output audio if
there was already some audio output going on for eg., mplayer playing
an audio file. so i thought i should get the list of available
devices, find a free device and open an output stream on that. this
is what im trying to do now but have run into the same problem again.
how do i find this "default" device you are talking about? i just
use the device number to try and open an output stream on it.
please refer to my program output to see the device numbers.

thank you
jagan.
S Jagannathan
2008-01-07 07:10:07 UTC
Permalink
Post by Arve Knudsen
You might also want to use the latest version of PA, if you're
Post by Arve Knudsen
not already doing so.
i use PA v19.
Arve Knudsen
2008-01-08 01:21:42 UTC
Permalink
Post by S Jagannathan
Post by Arve Knudsen
You might also want to use the latest version of PA, if you're
Post by Arve Knudsen
not already doing so.
i use PA v19.
I meant the latest subversion revision.

Arve

Richard Ash
2008-01-07 23:45:41 UTC
Permalink
Post by S Jagannathan
Post by Arve Knudsen
The problem is that "by default", ALSA will only let one process at a time
open a device. To work around that, they offer the "dmix" software device,
which mixes output of different processes. MPlayer probably uses dmix,
maybe via OSS. PA should offer the device "default" as the default
playback device, which in turn should use dmix. Which device are you using
through PA? You might also want to use the latest version of PA, if you're
not already doing so.
i used Pa_OpenDefaultStream but that would not let me output audio if
there was already some audio output going on for eg., mplayer playing
an audio file. so i thought i should get the list of available
devices, find a free device and open an output stream on that. this
is what im trying to do now but have run into the same problem again.
how do i find this "default" device you are talking about? i just
use the device number to try and open an output stream on it.
please refer to my program output to see the device numbers.
The output device numbers are internal to portaudio, with no fixed
meanings in the outside world. They are also all different - on ALSA
they will be the direct hardware device, the 4.0 surround device, the
5.1 surround device and so on. They are nothing like file numbers or
file descriptors. The concept of "find a free device" is meaningless -
what you need to do is find a device which supports being opened by
multiple users, and then make all your audio applications use it.

To find out what the default devices are, run the pa_devs test from the
portaudio source. This will list all the available devices, and mark
which ones are the default for each API, as well as the global default.

What jagan is saying is that the device "ALSA:default" should be marked
as the default playback device in the output of pa_devs. This is almost
certainly not device number 0, because of the way ALSA devices are
enumerated.

Note that this will be of no value if mplayer is using the direct
hardware device and preventing other applications reaching it (symptom -
you can't play two files in mplayer at the same time). If this is the
case you either need to configure mplayer, or upgrade to a newer version
where the default output device is correct.

Whilst I'm here, can I raise an issue with Portaudio on Linux? Why if
OSS and ALSA devices are available on a system, is the OSS one
(/dev/dsp) the global default device? Surely having the ALSA one
("ALSA:default") makes much more sense, given that the scenario is
almost always caused by having native ALSA drivers and OSS emulation
running (as there is no ALSA emulation for OSS). This also causes the
bizarre situation where if portaudio is built with support for OSS and
ALSA, then run on an ALSA-only machine, there is no default device
(getDefaultDevice returns -1 (PaNoDevice?)).

Richard
Loading...