From: Raymond Yau <superquad.vortex2@gmail.com>
To: alsa-devel@alsa-project.org
Subject: Re: Warning/error from ALSA’s pcm_min.c example. Possible problem?
Date: Sun, 31 Jan 2010 12:43:48 +0800 [thread overview]
Message-ID: <4f3252891001302043n3a404f1awdd8a7bef9769eb5a@mail.gmail.com> (raw)
In-Reply-To: <30c82f5f1001301151r6de4761fh9453829c1af85e15@mail.gmail.com>
2010/1/31 Louise Hoffman <louise.hoffman@gmail.com>
> Dear ALSA developers,
>
> When I compile ALSA's pcm_min.c[0] example with
>
> gcc -Wall -lasound pcm_min.c -o pcm_min
>
> Everything is fine, but running it, I get the white noise as expected,
> but I also get this warning/error:
>
> Short write (expected 16384, wrote 7616)
>
> Which comes from the last if-statement.
>
> One bug is in this line
>
> frames = snd_pcm_writei(handle, buffer, sizeof(buffer));
>
> where "sizeof(buffer)" should be "number of frames in the buffer".
>
> But there are still some strange things going on. I still get those
> errors, and if I remove the for-loop, nothing is played.
>
> Here is my code. [1]
>
> Can someone see what's wrong?
>
> Hugs,
> Louise
>
>
> [0]
> http://www.google.com/codesearch/p?hl=en&sa=N&cd=1&ct=rc#4FSOSMZ6Pxc/distfiles/alsa-lib-1.0.14rc2.tar.bz2|ZScnKi-LryE/alsa-lib-1.0.14rc2/test/pcm_min.c&q=pcm_min.c<http://www.google.com/codesearch/p?hl=en&sa=N&cd=1&ct=rc#4FSOSMZ6Pxc/distfiles/alsa-lib-1.0.14rc2.tar.bz2%7CZScnKi-LryE/alsa-lib-1.0.14rc2/test/pcm_min.c&q=pcm_min.c>
>
> [1] http://pastebin.com/m2f28b578
>
> The correct way is to use snd_pcm_get_params() to get buffer_size and
period_size
*snd_pcm_set_params() has limitation
The most common sound card (e.g. HDA ) has the following constraints
on period bytes and buffer bytes
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
128);
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
128);
*
you cannot get exactly 0.5 second period time when rate is multiple of 3 (
e.g. 48000 Hz )
next prev parent reply other threads:[~2010-01-31 4:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-30 19:51 Warning/error from ALSA’s pcm_min.c example. Possible problem? Louise Hoffman
2010-01-31 4:43 ` Raymond Yau [this message]
2010-01-31 20:53 ` Louise Hoffman
2010-01-31 8:46 ` Jaroslav Kysela
2010-01-31 20:41 ` Louise Hoffman
-- strict thread matches above, loose matches on Subject: below --
2010-10-29 3:49 Raymond Yau
2010-10-29 7:19 ` Jaroslav Kysela
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=4f3252891001302043n3a404f1awdd8a7bef9769eb5a@mail.gmail.com \
--to=superquad.vortex2@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).