From: Clemens Ladisch <clemens@ladisch.de>
To: "Aaron J. Grier" <agrier@poofygoof.com>, alsa-devel@alsa-project.org
Subject: Re: maintaining fixed latency between output and input?
Date: Fri, 26 Sep 2008 08:33:19 +0200 [thread overview]
Message-ID: <48DC822F.2030706@ladisch.de> (raw)
In-Reply-To: <20080926010525.GP1107@arwen.poofy.goof.com>
Aaron J. Grier wrote:
> what's the most straight-forward way to maintain fixed latency between
> output and input without sitting in loop and continuously checking
> snd_pcm_avail_update() for the output and input descriptors?
>
> I was originally going to use callbacks, but I've recently read that is
> not a good idea. poll() seems to be the reccomended method.
Yes.
> I'm visualizing something like this:
>
> for(;;)
> {
> poll()
>
> if (output_is_ready)
> {
> /* write output buffer */
> /* do output-side housekeeping */
> }
>
> if (input_is_ready)
> {
> /* read input buffer */
> /* do input-side housekeeping */
> }
>
> /* communicate with other threads */
> }
This is exactly how a full-duplex application should be structured.
To communicate with other threads, you can use a pipe so that you have
a file descriptor that can be used with the poll().
> combining the output and input snd_pcm_t into a single descriptor list
> for poll() seems straight-forward, but can I pass this superset list to
> snd_pcm_poll_descriptors_revents() without it getting confused?
No, snd_pcm_poll_descriptors_revents() looks at the file descriptors of
a single device and returns the ready status of that device.
HTH
Clemens
next prev parent reply other threads:[~2008-09-26 6:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-26 1:05 maintaining fixed latency between output and input? Aaron J. Grier
2008-09-26 6:33 ` Clemens Ladisch [this message]
2008-09-29 23:34 ` Aaron J. Grier
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=48DC822F.2030706@ladisch.de \
--to=clemens@ladisch.de \
--cc=agrier@poofygoof.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.