sfront w/ CoreAudio I/O support released
sfront w/ CoreAudio I/O support released
- Subject: sfront w/ CoreAudio I/O support released
- From: John Lazzaro <email@hidden>
- Date: Mon, 12 Aug 2002 15:11:36 -0700
Hi everyone,
A new sfront release went out today, with the
CoreAudio audio I/O drivers -- just wanted to thank
everyone who helped out answering API questions during
the driver development. The drivers ended up being
around 1800 lines of C, about the same size as the
Linux real-time drivers that perform roughly the
same function. Those curious to look at the code
can download the distribution at:
http://www.cs.berkeley.edu/~lazzaro/sa/sfrontlite.tar.gz
and look at the driver file:
sfront/src/lib/asys/coreaudio.c
This driver file is included in C files
sfront creates to compile MPEG 4 Structured Audio
programs into executables. A few interesting code
details about the coreaudio.c drivers:
[1] Page warming and locking. When sfront translates
a SAOL program into C, in most cases it unrolls
all of the SAOL stack frames into C global
variables -- malloc() is rarely used. Because
these C programs are created, compiled
(with cc), and executed only once, the Darwin
incremental page-in system doesn't work well.
To compensate, this driver function:
void asysn_coreaudio_page()
warms up and (if the program is run as root or is
setuid root) locks the working set, after checking
if there is enough RAM.
[2] SA engine lives in IOProc. The C programs sfront
creates turned out to be good candidates to run
inside the IOProc, rather than use a separate
thread -- no blocking I/O or malloc()s (a later
sfront revision will detect rare exceptions and
use an alternative implementation). The main
thread of the C program does initialization,
and then does a select() on a pipe to sleep.
The IOProc, or a listener proc monitoring
kAudioDevicePropertyDeviceIsAlive, send a
message into the pipe to reawaken the main
thread and end the program.
[3] SAOL cpuload implementation. The SAOL language
includes the cpuload standard name, which
returns a number between 0.0 and 1.0 to
indicate how much idle CPU remains for SAOL code
to use. Given [2] above, the driver computes
cpuload by measuring the time spent in the
IOProc, relative to the audio time going by.
This is complicated by the fact that the IOProc
can (and actually does) get pre-empted. The
driver has heuristics to check for this case.
Search for the variable asysn_coreaudio_ksync_then
in the driver to see the details.
Next up for sfront is CoreMIDI support, although the
version released today does allow testing of MIDI
control input using the ASCII keyboard (try the
examples/rtime/ascii example).
-------------------------------------------------------------------------
John Lazzaro -- Research Specialist -- CS Division -- EECS -- UC Berkeley
lazzaro [at] cs [dot] berkeley [dot] edu www.cs.berkeley.edu/~lazzaro
-------------------------------------------------------------------------
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.