Linux Squeak does squawk!

Lex Spoon lex at cc.gatech.edu
Tue Feb 17 00:49:30 UTC 1998


 > >>  I'm trying to cruft up some sound code for Linux....

We seem to be duplicating a lot of effort!  Last September I announced
a synchronous sound support for Linux, and immediately got an email
from a guy who had done the same thing and solved the same problems,
and pretty much in the same way, but just had not told anyone about
it.  Now I work on asynchronous support, and a few days before I
finish someone posts that they, too, are working on something very
similar!  mutter, mutter....


I have gotten asynchronous playing and recording to work on Linux.
Since Linux doen't have asynchronous IO primitives, I used threads to
read and write in the background.

The old synchronous code is left in as an ifdef option.  The
synchronous code is simpler and more stable, and does not require
pthreads.

While, the async version does support recording, it has a couple of
limitations that might be interesting.

First, insertSamplesFromLeadTime() is not supported at all.  It is
possible on some cards to access the sound card's buffer directly, but
I don't know how difficult this is to code nor how common it is that
a card offers the feature.

Second, simultaneous reading and writing is not supported.  This is
possible on some cards, but not all.  I wanted to get the code working
on the lowest common denominator first, so snd_Start and
snd_startRecording both return errors if the sound device is already
open for the other purpose.


The driver is not specific to just Linux.  It uses the OSS sound system
which, while standard on Linux, is also reputedly available for the
following systems (http://www.4front-tech.com/oss.html):

              Linux (x86, Alpha, PowerPC) 
              VxWorks (Tornado) 
              LynxOS (x86, PowerPC) 
              SCO Open Server 
              SCO UnixWare 
              Solaris (x86, Sparc) 
              IBM AIX  
              FreeBSD  
              BSD/OS

However, it's only been tested on my one Linux computer.


For the curious, I did a quick benchmark: run "26 benchFib" while
playing stereoBachFugue:

no sound demon:             1790, 1596, 1787, 1542, 1555, 1554
sync (1ms poll interval):   1981, 2317, 2273, 2360, 2425, 2411
sync (100ms poll interval): 2001, 1871, 1842, 2142, 2130, 1953, 1879
async:                      1914, 1864, 2198, 1995, 1957, 1931


Interestingly, the asynchronous version does about equally well as the
synchronous version, once the polling interval has been tuned a
little.  Performance doesn't immediately seem to be a reason to use an
asynchronous system, and the asynchronous one is certainly more
complicated to implement.  Oh well, food for thought.  The
asynchronous version has a cleaner design (from the VM side of things)
and requires no tuning.
      


The code described above is currently at:

    http://chaos.resnet.gatech.edu:8000/~lex/squeak/sound/

At 6am tomorrow morning it will appear on this more stable server:

    http://www.cc.gatech.edu/~lex/squeak/sound/

(There is an old version on the stable server now, but it is old and
has known bugs in it!)


Lex





More information about the Squeak-dev mailing list