Welcome! Log In Create A New Profile

Advanced

SDL AudioThread error

Posted by TheDrev 
SDL AudioThread error
May 01, 2010 09:26PM
I got a crash while playing a mp3 with SDL_Audio

Line 93 of "src/audio/wii/SDL_wiiaudio.c"
starts at address 0x801879d4
and ends at 0x801879e0 .

I init Audio like that :

Mix_OpenAudio(44100, AUDIO_S16, 2, 1024);

Any ideas ?
Re: SDL AudioThread error
May 01, 2010 11:03PM
I'm not sure that mp3 has been tested with SDL. However I'd try this setup first, this is what I've used for ogg playback before.

Mix_OpenAudio(48000, AUDIO_S16MSB, 2, 512);
Re: SDL AudioThread error
May 01, 2010 11:59PM
I'll try this out;

The code in the SDL wii source is

/****************************************************************************
 * Audio Threading
 ***************************************************************************/
static void *
AudioThread (void *arg)
{
	while (1)
	{
		if(stopaudio)
			break;

		whichab ^= 1;
		memset(dma_buffers[whichab], 0, sizeof(dma_buffers[0]));

		// Is the device ready?
		if (current_audio && (!current_audio->paused))
		{
			// Is conversion required?
			if (current_audio->convert.needed)
			{
				SDL_mutexP(current_audio->mixer_lock);
				// Get the client to produce audio
				current_audio->spec.callback(
					current_audio->spec.userdata,
					current_audio->convert.buf,
					current_audio->convert.len);
				SDL_mutexV(current_audio->mixer_lock);

				// Convert the audio
				SDL_ConvertAudio(¤t_audio->convert);

				// Copy from SDL buffer to DMA buffer
				memcpy(dma_buffers[whichab], current_audio->convert.buf, current_audio->convert.len_cvt);
			}
			else
			{
				SDL_mutexP(current_audio->mixer_lock);
				current_audio->spec.callback(
					current_audio->spec.userdata,
					(Uint8 *)dma_buffers[whichab],
					SAMPLES_PER_DMA_BUFFER*4);
				SDL_mutexV(current_audio->mixer_lock);
			}
		}
		LWP_ThreadSleep (audioqueue);
	}
	return NULL;
}
On line SDL_mutexV(current_audio->mixer_lock);
This mean that the thread may crash if the audio need a conversion
Re: SDL AudioThread error
May 02, 2010 12:08AM
I know the conversion works for oggs. Test an ogg with your code to verify.
Re: SDL AudioThread error
May 02, 2010 10:17AM
Thanks a lot, it worked with both ogg and mp3.
Sorry, only registered users may post in this forum.

Click here to login