From: "Ryan Cassidy" <rcassidy@stanford.edu>
To: 'Jaroslav Kysela' <perex@suse.cz>
Cc: 'Paul Davis' <paul@linuxaudiosystems.com>,
alsa-devel@lists.sourceforge.net
Subject: RE: Interrupt-driven (or callback/handler?), Full-duplex (simultaneous capture/playback) without using JACK
Date: Mon, 29 Dec 2003 17:57:21 -0800 [thread overview]
Message-ID: <000701c3ce78$43939a50$264440ab@roboserv1> (raw)
In-Reply-To: <Pine.LNX.4.53.0311090927040.3073@pnote.perex-int.cz>
> On Sat, 8 Nov 2003, Ryan Cassidy wrote:
>
> > > Paul Davis wrote:
**************************************************
> > > the ALSA PCM API doesn't have "handlers". it doesn't provide any
kind
> > > of callback mechanism. what it does do is to provide a poll(2)
> > > interface, allowing callback-like mechanisms to be built around it
> > > (like JACK).
> > >
> > Ryan J. Cassidy replies:
*********************************************
> > Will snd_async_add_pcm_handler() not do the trick? It says
> > "asynchronous," which doesn't sound like what I want, but the
"handler"
> > part sounds promising :).
> >
> > If that doesn't work, it's sort of a bummer that ALSA doesn't offer
a
> > callback-mechanism for simultaneous audio i/o, non? This means that
to
> > get "what I want" (i.e. allowing my program to do useful work while
> > waiting for new audio samples), I need to use snd_pcm_wait() and
fork
> > off an extra process to do the "useful work," right?
> Jaroslav replies:
******************************************************
> Yes, snd_async_add_pcm_handler() might help you and it works. It's
> originated in the interrupt handler. But please note that the handler
is
> in the unix style signal callback thus there are many restrictions
(you
> should avoid to do most of syscalls in this code etc.).
>
> But for mmaped access and the standard ALSA transfer mechanism (use
only
> snd_pcm_avail_update() to get the right position) it is the fast way
to
> create an interrupt based handlers in the applications.
>
> For the synchronization: You must do it in your application. We work
with
> two diferrent streams and although the streams are hardware
synchronized,
> there might be some buffering issues (FIFOs) so the playback and
capture
> pointers do not match exactly. So the best way is to obtain the
current
> pointer using snd_pcm_avail_update() and compute how many frames you
can
> process for the duplex operation (I mean for both streams).
Just to be sure here: it is possible, then, to add a single PCM handler
(via snd_async_add_pcm_handler()) to a LINKED pair of streams (one for
playback, one for capture)? Moreover, this handler will be called only
once each period/buffer-time to signal the need for BOTH capture and
playback frames (since the streams are linked)?
(Note to Paul: I realize that no system calls are allowed within the
handler, but I think I could work around this via message-passing to the
main application. Perhaps this is naïve/incorrect?)
Since the streams are hardware synchronized, is there any way to disable
the FIFOs that Jaroslav mentions above? Why are the FIFOs needed in the
first place?
Cheers, rjc.
--
Ryan J. Cassidy
Electrical Engineering Graduate Student, CCRMA Researcher
Stanford University
E-mail: ryanc@ieee.org
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
prev parent reply other threads:[~2003-12-30 1:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-09 0:18 Interrupt-driven (or callback/handler?), Full-duplex (simultaneous capture/playback) without using JACK Ryan Cassidy
2003-11-09 3:42 ` Paul Davis
2003-11-09 4:33 ` Ryan Cassidy
2003-11-09 8:37 ` Jaroslav Kysela
2003-11-10 10:57 ` Ryan Cassidy
2003-11-10 11:05 ` Jaroslav Kysela
2003-11-10 12:26 ` Paul Davis
2003-12-30 1:57 ` Ryan Cassidy [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='000701c3ce78$43939a50$264440ab@roboserv1' \
--to=rcassidy@stanford.edu \
--cc=alsa-devel@lists.sourceforge.net \
--cc=paul@linuxaudiosystems.com \
--cc=perex@suse.cz \
/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.