diff options
author | Simon Howard | 2010-11-24 08:09:48 +0000 |
---|---|---|
committer | Simon Howard | 2010-11-24 08:09:48 +0000 |
commit | cf82ce9d7bb8d71ae583753aab642c5ba4ee8d06 (patch) | |
tree | be50cebd6f8c5e3ca5d1a1f32164183050677c64 | |
parent | b03de59700f80c75308849ac5f89310d010af066 (diff) | |
download | chocolate-doom-cf82ce9d7bb8d71ae583753aab642c5ba4ee8d06.tar.gz chocolate-doom-cf82ce9d7bb8d71ae583753aab642c5ba4ee8d06.tar.bz2 chocolate-doom-cf82ce9d7bb8d71ae583753aab642c5ba4ee8d06.zip |
Add workaround to stop freezeups with old versions of SDL_mixer.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2165
-rw-r--r-- | src/i_sdlsound.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c index a758289a..a26a81dd 100644 --- a/src/i_sdlsound.c +++ b/src/i_sdlsound.c @@ -53,6 +53,8 @@ #define MAX_SOUND_SLICE_TIME 70 /* ms */ #define NUM_CHANNELS 16 +static boolean setpanning_workaround = false; + static boolean sound_initialized = false; static Mix_Chunk sound_chunks[NUMSFX]; @@ -620,10 +622,19 @@ static void I_SDL_UpdateSoundParams(int handle, int vol, int sep) left = ((254 - sep) * vol) / 127; right = ((sep) * vol) / 127; + // SDL_mixer version 1.2.8 and earlier has a bug in the Mix_SetPanning + // function. A workaround is to call Mix_UnregisterAllEffects for + // the channel before calling it. This is undesirable as it may lead + // to the channel volumes resetting briefly. + + if (setpanning_workaround) + { + Mix_UnregisterAllEffects(handle); + } + Mix_SetPanning(handle, left, right); } - // // Starting a sound means adding it // to the current list of active sounds @@ -811,8 +822,34 @@ static boolean I_SDL_InitSound(void) } #endif + // SDL_mixer version 1.2.8 and earlier has a bug in the Mix_SetPanning + // function that can cause the game to lock up. If we're using an old + // version, we need to apply a workaround. But the workaround has its + // own drawbacks ... + + { + const SDL_version *mixer_version; + int v; + + mixer_version = Mix_Linked_Version(); + v = SDL_VERSIONNUM(mixer_version->major, + mixer_version->minor, + mixer_version->patch); + + if (v <= SDL_VERSIONNUM(1, 2, 8)) + { + setpanning_workaround = true; + fprintf(stderr, "\n" + "ATTENTION: You are using an old version of SDL_mixer!\n" + " This version has a bug that may cause " + "your sound to stutter.\n" + " Please upgrade to a newer version!\n" + "\n"); + } + } + Mix_AllocateChannels(NUM_CHANNELS); - + SDL_PauseAudio(0); sound_initialized = true; |