[alsa-devel] crash with assertion (?)

Raymond Yau superquad.vortex2 at gmail.com
Thu Sep 9 03:30:02 CEST 2010


2010/9/8 IOhannes m zmoelnig <zmoelnig at iem.at>

> On 2010-09-07 19:06, Clemens Ladisch wrote:
> > IOhannes m zmoelnig wrote:
> >> i'm requesting my "plughw" device with 44100Hz
> >> the request is done with something like:
> >>  rate=44100;
> >>  err = snd_pcm_hw_params_set_rate_min(handle, params, &rate, 0);
> >
> > This requests a sample rate of at least 44100 Hz.
>
> yes. this is good enough for me.
> (it shouldn't crash though)
>
>
http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m___h_w___params.htm

Restrict a configuration space with a minimum rate.

val approximate minimum rate ( on return filled with actul minimum )
dir sub unit direction (on return filled with actual direction)

Return 0 otherwise a negative error code if configuration space would become
empty



what is the minimum rate returned by snd_pcm_hw_params_get_rate_min() when
using hw:0,0 ?

>
> >> [...]
> >>  err = snd_pcm_hw_params(handle, params);
> >>
> >> what happens:
> >> in the snd_pcm_hw_params(), my program exits with:
> >> "interval_inline.h:52: snd_interval_single: Assertion
> >> `!snd_interval_empty(i)' failed."
> >
> > You called snd_pcm_hw_params with an invalid params structure.
> > I'd guess that snd_pcm_hw_params_set_rate_min (or some other
> > snd_pcm_hw_params_set_*) returned an error.
>
> i wish you were right.
> however, it seems like i am blindfolded.
>
> i noticed however, that i need to set both the rate (i use
> snd_pcm_hw_params_set_rate_min()) and the period size (i use
> snd_pcm_hw_params_set_period_size_near()), in order to make it crash.
>
> attached is an example code that triggers the crash.
> please someone shed some light...
>
> gmasdr
> IOhannes
>
>
> PS: that's how i use the sample program:
> $ gcc -o alsatest alsatest.c $(pkg-config --cflags --libs alsa)
> $ ./alsatest
> trying to open 'hw:0' as CAPTURE
> configuring device succeeded
> CAPTURE configured
> trying to open 'hw:0' as PLAYBACK
> configuring device succeeded
> PLAYBACK configured
> trying to open 'plughw:0' as CAPTURE
> configuring device succeeded
> CAPTURE configured
> trying to open 'plughw:0' as PLAYBACK
> alsatest: interval_inline.h:55: snd_interval_single: Assertion
> `!snd_interval_empty(i)' failed.
> Aborted
>
> so it seems to work fine with "hw:0" but not with "plughw:0".
>
> you can specify the device to be opened on the cmdline:
> $ ./alsatest hw:2
>
>

To debug , you will need to enable RULES_DEBUG In pcm_params.c

add snd_pcm_dump() after snd_pcm_hw_params in your program

export LIBASOUND_DEBUG=1

and post the output of your program


More information about the Alsa-devel mailing list