[SDL] Converting OSS sound code to SDL ...
linux_dr at yahoo.com
Wed Aug 14 11:58:01 PDT 2002
--- Stephen Anthony <stephena at roadrunner.nf.net>
> On August 14, 2002 03:18 pm, Loren Osborn wrote:
> > For me anyway, it is much easier to to think of
> > mutex being "locked" or "unlocked" rather than 1
> > 0...
> That's why I called it a mutex of sorts. It isn't
> really a mutex at all.
> > The point is the callback isn't called in sync
> > any part of your program, so you should probably
> > a mutex-protected ring buffer... The callback can
> > out of it, and the rest of your sound code can
> > it... When it becomes empty, the callback should
> > the silence value.
> Yes, this is what Sam mentioned, but I wasn't sure
> what he meant. Now I
> know :) Quite a bit more complicated than an
> ordinary write(). I was
> still thinking in terms of one write for one sound.
> I forgot about the
> threading part, where the sound thread isn't
> necessarily in sync with the
> other code. Going from single-threaded to
> multi-threaded can be
> difficult sometimes.
> BTW, how do you know how much data you can write on
> each call to the
The callback prototype looks like:
void (*callback)(void *userdata, Uint8 *stream, int
so, the buffer length is passed in to you, you
probably need to divide it by the number of channels
(1 or 2) and the number of bytes per sample (1 or
Best of luck,
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
More information about the SDL