What would the plan9 way for implementing /dev/dsp be, keeping in mind the different audio formats and ways of buffering? Like getting the number of available audio channels, setting the format to interleaved, changing the sampling rate, etc.
If I recall correctly it is done in linux by using an ioctl system call on a /dev/dsp file handle with constants provided in header files.
Probably something like
open /dev/dsp/new as a directory
in that directory find ctl and data files
echo 8bit unsigned 44khz unbuffered > ctl
echo samples > data
>>43
It's always 16bit stereo interleaved, sample rate is adjustable with a "volume" file. Its not an abstracted interface though, it pretty much assumes a sound blaster 16 compatible. To be honest I couldn't get it to work in virtualbox anyway.