Problem with SDL_mixer

Hello!

When I run the following test program, it hangs the second time
Mix_OpenAudio(…) is called. Any ideas?

I am running SuSE Linux 6.3 (Kernel 2.2.13) with SDL 1.1.3, SDL_mixer 1.0.6 and
SMPEG 0.4.0.---------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>

#include “SDL.h”
#include “SDL_mixer.h”

static int audio_open = 0;
static Mix_Music *music = NULL;

void mixTest()
{
int audio_rate;
Uint16 audio_format;
int audio_channels;
int audio_buffers;
int looping = 0;

audio_rate = 22050;
audio_format = AUDIO_S16;
audio_channels = 2;
audio_buffers = 4096;

if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {
	fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
	exit(255);
}

printf("about to open the audio device...\n");

/* some kind of problem here... */
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
	fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
	exit(2);
}
audio_open = 1;

music = Mix_LoadMUS("SomeMusicFile.mp3");

/* play for a couple of seconds... */
Mix_FadeInMusic(music,0,2000);
SDL_Delay(5000);

Mix_HaltMusic();

if ( music ) {
	Mix_FreeMusic(music);
	music = NULL;
}

if ( audio_open ) {
	Mix_CloseAudio();
	audio_open = 0;
}

SDL_Quit();

}

int main(int argc, char *argv[])
{
mixTest();
mixTest();
return(0);
}

David Banz

http://darkstar.tabu.uni-bonn.de/~neo/

“I fight for justice and the occasional stolen treasure.” – Lina Inverse