From: IOhannes m zmoelnig <zmoelnig@iem.at>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: crash with assertion (?)
Date: Wed, 08 Sep 2010 10:41:02 +0200 [thread overview]
Message-ID: <4C874C1E.8040007@iem.at> (raw)
In-Reply-To: <4C8670FD.5020906@ladisch.de>
[-- Attachment #1.1.1: Type: text/plain, Size: 1841 bytes --]
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)
>
>> [...]
>> 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: alsatest.c --]
[-- Type: text/x-csrc; name="alsatest.c", Size: 2834 bytes --]
#include <stdio.h>
#include <alsa/asoundlib.h>
#define ENABLE_SETPARAMS_RATE 1
#define ENABLE_SETPARAMS_PERIOD 2
/* neither set_rate_min() nor set_period_size_near() is ok (but trivial) */
//#define ENABLE_SETPARAMS 0
/* only set_rate_min() is ok */
//#define ENABLE_SETPARAMS ENABLE_SETPARAMS_RATE
/* only set_period_size_near() is ok as well */
//#define ENABLE_SETPARAMS ENABLE_SETPARAMS_PERIOD
/* both set_rate_min() and set_period_size_near() -> CRASH */
#define ENABLE_SETPARAMS ENABLE_SETPARAMS_RATE | ENABLE_SETPARAMS_PERIOD
int pcm_configure(snd_pcm_t *pcm) {
unsigned int rate=44100;
snd_pcm_uframes_t uframes = 64;
snd_pcm_hw_params_t* hw_params;
int err;
snd_pcm_hw_params_alloca(&hw_params);
err = snd_pcm_hw_params_any(pcm, hw_params);
if(err<0){fprintf(stderr, "snd_pcm_hw_params_any failed: %s\n", snd_strerror(err));return err;}
#if ENABLE_SETPARAMS & 1
err = snd_pcm_hw_params_set_rate_min(pcm, hw_params, &rate, 0);
if(err<0){fprintf(stderr, "snd_pcm_hw_params_set_rate_min failed: %s\n", snd_strerror(err));return err;}
#endif
#if ENABLE_SETPARAMS & 2
err = snd_pcm_hw_params_set_period_size_near(pcm, hw_params, &uframes, 0);
if(err<0){fprintf(stderr, "snd_pcm_hw_params_set_period_size failed: %s\n", snd_strerror(err));return err;}
#endif
err = snd_pcm_hw_params(pcm, hw_params);
if(err<0){fprintf(stderr, "snd_pcm_hw_params failed: %s\n", snd_strerror(err));return err;}
printf("configuring device succeeded\n");
return 0;
}
void pcm_open(char*name) {
int err=0;
snd_pcm_t *pcmIn=0, *pcmOut=0;
printf("trying to open '%s' as CAPTURE\n", name);
err = snd_pcm_open(&pcmIn, name, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
if(err<0){fprintf(stderr, "snd_pcm_open(CAPTURE) failed: %s\n", snd_strerror(err));goto closeit;}
err=snd_pcm_nonblock(pcmIn, 1);
if(err<0){fprintf(stderr, "snd_pcm_nonblock failed: %s\n", snd_strerror(err));goto closeit;}
pcm_configure(pcmIn);
fprintf(stderr, "CAPTURE configured\n");
printf("trying to open '%s' as PLAYBACK\n", name);
err = snd_pcm_open(&pcmOut, name, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
if(err<0){fprintf(stderr, "snd_pcm_open(PLAYBACK) failed: %s\n", snd_strerror(err));goto closeit;}
err=snd_pcm_nonblock(pcmOut, 1);
if(err<0){fprintf(stderr, "snd_pcm_nonblock failed: %s\n", snd_strerror(err));goto closeit;}
pcm_configure(pcmOut);
fprintf(stderr, "PLAYBACK configured\n");
closeit:
if(pcmIn)snd_pcm_close(pcmIn);
if(pcmOut)snd_pcm_close(pcmOut);
}
int main(int argc, char**argv) {
int i=0;
if(argc>1) {
for(i=1; i<argc; i++) {
pcm_open(argv[i]);
}
} else {
pcm_open("hw:0");
pcm_open("plughw:0");
}
fprintf(stderr, "bye bye\n");
return 0;
}
[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 3636 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2010-09-08 8:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-07 16:05 crash with assertion (?) IOhannes m zmoelnig
2010-09-07 16:07 ` IOhannes m zmoelnig
2010-09-07 16:32 ` IOhannes m zmoelnig
2010-09-07 17:06 ` Clemens Ladisch
2010-09-08 8:41 ` IOhannes m zmoelnig [this message]
2010-09-09 1:30 ` Raymond Yau
2010-09-09 9:43 ` IOhannes m zmoelnig
2010-09-10 1:53 ` Raymond Yau
2010-09-10 7:06 ` Clemens Ladisch
2010-09-10 23:20 ` Raymond Yau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C874C1E.8040007@iem.at \
--to=zmoelnig@iem.at \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox