Improve OpenAL error handling, patch by Ben Millwood. https://bugzilla.icculus.org/show_bug.cgi?id=3776

This commit is contained in:
Thilo Schulz 2009-10-13 15:23:17 +00:00
parent 4ad2955cab
commit fc539dc46a

View file

@ -98,6 +98,22 @@ static const char *S_AL_ErrorMsg(ALenum error)
} }
} }
/*
=================
S_AL_ClearError
=================
*/
static void S_AL_ClearError( qboolean quiet )
{
int error = qalGetError();
if( quiet )
return;
if(error != AL_NO_ERROR)
Com_Printf(S_COLOR_YELLOW "WARNING: unhandled AL error: %s\n",
S_AL_ErrorMsg(error));
}
//=========================================================================== //===========================================================================
@ -218,6 +234,7 @@ static void S_AL_BufferUnload(sfxHandle_t sfx)
return; return;
// Delete it // Delete it
S_AL_ClearError( qfalse );
qalDeleteBuffers(1, &knownSfx[sfx].buffer); qalDeleteBuffers(1, &knownSfx[sfx].buffer);
if((error = qalGetError()) != AL_NO_ERROR) if((error = qalGetError()) != AL_NO_ERROR)
Com_Printf( S_COLOR_RED "ERROR: Can't delete sound buffer for %s\n", Com_Printf( S_COLOR_RED "ERROR: Can't delete sound buffer for %s\n",
@ -296,6 +313,7 @@ static void S_AL_BufferLoad(sfxHandle_t sfx)
format = S_AL_Format(info.width, info.channels); format = S_AL_Format(info.width, info.channels);
// Create a buffer // Create a buffer
S_AL_ClearError( qfalse );
qalGenBuffers(1, &knownSfx[sfx].buffer); qalGenBuffers(1, &knownSfx[sfx].buffer);
if((error = qalGetError()) != AL_NO_ERROR) if((error = qalGetError()) != AL_NO_ERROR)
{ {
@ -614,6 +632,7 @@ qboolean S_AL_SrcInit( void )
else if(limit < 16) else if(limit < 16)
limit = 16; limit = 16;
S_AL_ClearError( qfalse );
// Allocate as many sources as possible // Allocate as many sources as possible
for(i = 0; i < limit; i++) for(i = 0; i < limit; i++)
{ {
@ -1536,6 +1555,8 @@ void S_AL_MusicProcess(ALuint b)
ALuint format; ALuint format;
snd_stream_t *curstream; snd_stream_t *curstream;
S_AL_ClearError( qfalse );
if(intro_stream) if(intro_stream)
curstream = intro_stream; curstream = intro_stream;
else else