From: Andrew Eikum <aeikum@codeweavers.com>
To: alsa-devel@alsa-project.org
Subject: Infinite loop in snd_pcm_hw_htimestamp() for capture PCMs?
Date: Fri, 21 Sep 2012 10:53:43 -0500 [thread overview]
Message-ID: <20120921155343.GH4615@foghorn.codeweavers.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 453 bytes --]
Hi folks,
I've found some unexpected behavior in alsa-lib. The attached program
uses 100% CPU in an infinite loop, when I'd expect it to return either
an error or a valid htimestamp. I believe the loop occurs in
<src/pcm/pcm_hw.c:snd_pcm_hw_htimestamp()>. Am I not supposed to call
htimestamp() on this type of PCM? Is the PCM still in an invalid state
when htimestamp() is called?
Card: HDA ATI SB
Chip: Realtek ALC889
Happy for any insight.
Andrew
[-- Attachment #2: capture_inf_loop.c --]
[-- Type: text/x-csrc, Size: 2094 bytes --]
/* Causes an infinite loop in alsa-lib's snd_pcm_hw_htimestamp() in the
* capture direction
*
* Build with:
* $ gcc -o test -Wall capture_inf_loop.c -lasound
*/
#include <alsa/asoundlib.h>
int main(int argc, char **argv)
{
snd_pcm_t *pcm;
snd_pcm_uframes_t avail;
snd_pcm_hw_params_t *hw_params;
int err;
struct timespec ts;
unsigned int rate = 44100;
err = snd_pcm_open(&pcm, "default", SND_PCM_STREAM_CAPTURE,
SND_PCM_NONBLOCK);
if(err < 0){
fprintf(stderr, "snd_pcm_open: %s\n", snd_strerror(err));
return 1;
}
snd_pcm_hw_params_malloc(&hw_params);
err = snd_pcm_hw_params_any(pcm, hw_params);
if(err < 0){
fprintf(stderr, "snd_pcm_hw_params_any: %s\n", snd_strerror(err));
return 1;
}
err = snd_pcm_hw_params_set_access(pcm, hw_params,
SND_PCM_ACCESS_RW_INTERLEAVED);
if(err < 0){
fprintf(stderr, "snd_pcm_hw_params_set_access: %s\n",
snd_strerror(err));
return 1;
}
err = snd_pcm_hw_params_set_format(pcm, hw_params,
SND_PCM_FORMAT_S16_LE);
if(err < 0){
fprintf(stderr, "snd_pcm_hw_params_set_access: %s\n",
snd_strerror(err));
return 1;
}
err = snd_pcm_hw_params_set_rate_near(pcm, hw_params, &rate, NULL);
if(err < 0){
fprintf(stderr, "snd_pcm_hw_params_set_rate_near: %s\n",
snd_strerror(err));
return 1;
}
err = snd_pcm_hw_params_set_channels(pcm, hw_params, 2);
if(err < 0){
fprintf(stderr, "snd_pcm_hw_params_set_rate_near: %s\n",
snd_strerror(err));
return 1;
}
err = snd_pcm_hw_params(pcm, hw_params);
if(err < 0){
fprintf(stderr, "snd_pcm_hw_params: %s\n", snd_strerror(err));
return 1;
}
fprintf(stderr, "avail_update\n");
snd_pcm_avail_update(pcm);
fprintf(stderr, "entering htimestamp...\n");
snd_pcm_htimestamp(pcm, &avail, &ts);
fprintf(stderr, "done with htimestamp\n");
snd_pcm_close(pcm);
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
next reply other threads:[~2012-09-21 15:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-21 15:53 Andrew Eikum [this message]
2012-09-21 16:02 ` Infinite loop in snd_pcm_hw_htimestamp() for capture PCMs? Takashi Iwai
2012-09-21 16:15 ` Andrew Eikum
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=20120921155343.GH4615@foghorn.codeweavers.com \
--to=aeikum@codeweavers.com \
--cc=alsa-devel@alsa-project.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.