After some more tries, I've discovered that I have two problems at the same time. The 'clock skew' thing don't seems to cause much trouble. The big problem comes from the initialization function in audio.c
The worst thing is that I already had the same problem when I started the project several month ago, and now I don't remember how did I fixed it...
Here is the function with the problem highlited inside:
Code: Select all
void Audio_Init(void) {
int i;
char filename[32];
SDL_AudioSpec desiredAudioSpec;
if (SDL_WasInit(SDL_INIT_AUDIO) == 0) {
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
fprintf(stderr, "Could not init audio: %s\n", SDL_GetError() );
bSoundWorking = FALSE;
return;
}
}
desiredAudioSpec.freq = SND_FREQ;
desiredAudioSpec.format = AUDIO_S16;
desiredAudioSpec.channels = 2;
desiredAudioSpec.samples = 1024;
desiredAudioSpec.callback = Audio_CallBack;
desiredAudioSpec.userdata = NULL;
if (SDL_OpenAudio(&desiredAudioSpec, NULL)) {
fprintf(stderr, "Can't use audio: %s\n", SDL_GetError());
bSoundWorking = FALSE;
return;
}
SoundBufferSize = desiredAudioSpec.size;
for (i=0; i<MAX_SAMPLES; i++) {
snprintf (filename, sizeof (filename), "sfx/sfx_%02d.wav", i);
// -------------------------------------------
// THE PROBLEM COMES FROM THE SDL_loadWAV LINE
if (SDL_LoadWAV (filename, &desiredAudioSpec, &sfx_buf[i].buf, &sfx_buf[i].buf_len) == NULL) {
printf ("Error loading %s: %s\n", filename, SDL_GetError ());
sfx_buf[i].buf = NULL;
}
check_sample_format (&desiredAudioSpec, &sfx_buf[i].buf, &sfx_buf[i].buf_len, filename);
if (i == 19) sfx_buf[i].loop = SND_FREQ; // loop to about 0.5 sec in
else if (i == 23) sfx_buf[i].loop = 0;
else sfx_buf[i].loop = -1;
}
bSoundWorking = TRUE;
Audio_EnableAudio(TRUE);
}
And the blue screen returns this:
Code: Select all
psp-addr2line -e frontier.elf -f -C 0x8d5ab14 0x408b000 0x8d5aab0
_free_r
../../../../../newlib/libc/stdlib/mallocr.c:2696
??
??:0
_free_r
../../../../../newlib/libc/stdlib/mallocr.c:2632
SOS!