From: Clemens Ladisch <clemens@ladisch.de>
To: "Paul D. DeRocco" <pderocco@ix.netcom.com>
Cc: Alsa-devel <alsa-devel@alsa-project.org>
Subject: Re: Playback underrun recovery
Date: Tue, 24 Apr 2012 16:04:51 +0200 [thread overview]
Message-ID: <4F96B303.2090008@ladisch.de> (raw)
In-Reply-To: <FB1A4815959E42EF9F7B4F3A48E8E129@PAULD>
Paul D. DeRocco wrote:
> I've got a synth program outputting directly to the main hw PCM device, with
> no intervening plugins. It uses about 75-80% of the time on one core, so it
> normally doesn't underrun. Once in a while, other burdens on the system
> trigger an underrun, and my program never recovers. My buffer contains two
> periods of 256 stereo frames (with 32-bit samples), which at 96KHz comes out
> to a little over 5.3ms total. When it fails, its CPU usage goes up to 100%
> on that core, and it spits out bursts of 5.3ms of audio (two full periods,
> not one), with about 4ms of silence between them.
When a PCM device is (re)started, the buffer is initially empty, so you
need more CPU to fill it.
What is your start threshold?
> My top level code consists of a loop that generates one period at a time:
>
> while (true) {
> generate_samples(buf, 256); // generate 256 stereo frames
> if (snd_pcm_writei(h, buf, 256) < 0)
> snd_pcm_prepare(h);
> }
Is this the actual code? You should check if snd_pcm_writei() returns
that less than 256 frames have been written, and you should use
snd_pcm_recover(), and you should that one's return value, too.
Regards,
Clemens
prev parent reply other threads:[~2012-04-24 14:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-21 21:12 Playback underrun recovery Paul D. DeRocco
2012-04-24 14:04 ` Clemens Ladisch [this message]
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=4F96B303.2090008@ladisch.de \
--to=clemens@ladisch.de \
--cc=alsa-devel@alsa-project.org \
--cc=pderocco@ix.netcom.com \
/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.