It's hard to do the low-level hardware stuff outside
the kernel.  It's possible, but it's a lot easier inside.
Just keep the inside simple.

I've done audio on a handful of operating systems
and all I ever want to do with the card is set it up
to play X kHz 16-bit little-endian PCM stereo and
then control the volume.  The rest can be done from
user space.  This is exactly what Plan 9's audio
driver already does, and I wish the others were so
simple.

The original post commented that only supporting
PCM was too simplistic, but I argue it's exactly right.
PCM is the native hardware sample format and is
basically the "uncompress bitmap" of the audio world.
Defining a fixed byte order avoids one level of
misconfiguration and complexity; it doesn't matter which
is chosen except that the existing driver is little endian.
Being able to change the sample rate is necessary for quality;
it is too hard to resample other speeds nicely on
the fly, and the hardware will take care of it for you.
The fixed 16-bit and stereo parts are perhaps debatable,
but basically no one has 8-bit audio they care about,
it is trival to convert 8-bit to 16-bit, and it is also trivial
to turn mono into stereo.

If you want a different device file into which you
can write mp3 and other sound file formats, great:
do it in user space, translating into the native hardware
format.

By analogy, Plan 9's kernel gives user space access to the
raw disk bytes.  It doesn't implement the interpretation
of those bytes as 9660, fat, ext2, kfs, venti, or other disk
"file formats".  That can be done better and more easily
in user space.  The same is true of audio.  There's already
a good native hardware format and a well-established and
capable (if simple) kernel interface.  Leave those alone
and put the extra complexity in user space for those who
want to use it.

Russ


P.S. My guess is that Inferno's implementation of mp3 in the
kernel device file was a quick way to make an mp3 decoder
available without writing one in Limbo.  It may have had
something to do with making a snazzy low-bandwidth
import-across-the-network demo too.  But neither of those
applies to Plan 9, since the same can be accomplished
with a C program running in user space.

Reply via email to