How to use SDL sound (RE: comparison of OSS vs. SDL code)

I’m at my wits end trying to figure out whats going on the following code.
The code is from Stella, an Atari 2600 emulator.

Right now, the SDL version uses a separate program (called stella-sound),
which is compiled from OSS.c (see below). The emulator makes calls to
SndUnix::set(…) (from SndUnix.cxx), which are then piped to the
external sound server (stella-sound), then sent directly to the sound
card using OSS ioctl calls.

What I want to do is eliminate this sound server and have it go through
SDL, so it is more portable to other systems with SDL. My approach is to
combine the functionality of SndUnix.cxx and OSS.cxx into an SDL specific
class called SndSDL.cxx (also provided below).

Unfortunately, the sound doesn’t ‘sound’ quite right. Sometimes it is
choppy, and at a higher or lower ‘pitch’ than it should be. I tried
changing sample size and frequency, and they change the sound, but not to
what it should be.

I guess my main problem is that I don’t understand all the ioctl’s in
OSS.c, so I can’t figure out their equivalent in SDL.

I’ve included the code so that someone may help me figure out. Please
help me with this. I have little experience with sound coding.

Thanks,
Steve Anthony
-------------- next part --------------
A non-text attachment was scrubbed…
Name: OSS.c
Type: text/x-csrc
Size: 6998 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020428/2903972d/attachment.c
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SndSDL.cxx
Type: text/x-c++src
Size: 4894 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020428/2903972d/attachment.cxx
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SndUnix.cxx
Type: text/x-c++src
Size: 4794 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020428/2903972d/attachment-0001.cxx