The worlds simplest SDL audio program

I feel like a real idiot, but any thoughts where I can find the SDL audio
equivalent of a Hello World app? I have just finished (I think)
integrating my XBOX audio port into the SDL audio hierarchy and want to
test it. However, when I look for simple examples on the web, they all
show me how to use the Mix_xxx functions. I am sure my code is not going
to work first time, so I only want to debug one thing at a time. I
currently have something like the following (I have removed error checking
in this post for brevity’s sake). Have I missed something? Sorry for the
dumb question… thanks a lot.

Uint8 *wavData;
void mixaudio(void *unused, Uint8 *stream, int len)
{
memcpy(stream, wavData, len); wavData += len;
}

void XBoxStartup()
{
SDL_AudioSpec *desired, *obtained;

desired  = malloc(sizeof(SDL_AudioSpec));
obtained = malloc(sizeof(SDL_AudioSpec));

desired->freq = 44100;
desired->format = AUDIO_S16LSB;
desired->channels = 2;
desired->samples = 512;
desired->callback = mixaudio;
desired->userdata = NULL;

SDL_OpenAudio(desired, obtained);
free(desired);

unsigned int length;
SDL_LoadWAV("c:/blah.wav", obtained, &wavData, &length);

SDL_PauseAudio(0);

// sleep for 10 seconds and reboot
XSleep(10000);
XReboot();

}–
Craig Edwards

You never called SDL_Init(SDL_INIT_AUDIO) at least
that should probably be the first thing you do…before any other SDL_function

-LIM-

Aargh!! I do actually call it using:

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);

Sorry… in removing the error handling, my fat fingers also inadvertantly
removed this line. My apologies for the confusion!On Tue, 02 Nov 2004 01:44:22 -0500, Jonathan Atkins wrote:

You never called SDL_Init(SDL_INIT_AUDIO) at least
that should probably be the first thing you do…before any other
SDL_function


Craig Edwards

Craig Edwards wrote:> On Tue, 02 Nov 2004 01:44:22 -0500, Jonathan Atkins <@Jonathan_Atkins> wrote:

You never called SDL_Init(SDL_INIT_AUDIO) at least
that should probably be the first thing you do…before any other
SDL_function

Aargh!! I do actually call it using:

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);

Sorry… in removing the error handling, my fat fingers also
inadvertantly removed this line. My apologies for the confusion!

perhaps you should paste the code you are testing, with everything…

-LIM-

http://www.libsdl.org/intro/usingsound.html

http://www.ioplex.com/~miallen/tcpsound/dl/src/play.c

ChrisOn Tue, 02 Nov 2004 16:40:33 +1100, Craig Edwards wrote:

I feel like a real idiot, but any thoughts where I can find the SDL audio
equivalent of a Hello World app? I have just finished (I think)
integrating my XBOX audio port into the SDL audio hierarchy and want to
test it. However, when I look for simple examples on the web, they all
show me how to use the Mix_xxx functions.


Chris Nystrom
http://www.newio.org/~ccn
AIM: nystromchris