From 14d3cc45bcf1a9dce1e982fd82b79d7053be4048 Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Tue, 14 Aug 2001 23:36:15 +0000 Subject: Fixed sound length and looping. (Setting looping on a source must be done after setting the buffer) --- src/openal.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/openal.c') diff --git a/src/openal.c b/src/openal.c index 5c841c8..e073f66 100644 --- a/src/openal.c +++ b/src/openal.c @@ -12,6 +12,7 @@ #include "3dc.h" #include "platform.h" +#include "inline.h" #include "psndplat.h" #include "gamedef.h" #include "avpview.h" @@ -112,14 +113,14 @@ int PlatPlaySound(int activeIndex) if (!PlatSoundHasStopped(activeIndex)) PlatStopSound (activeIndex); -// if (ActiveSounds[activeIndex].loop) -// alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_TRUE); -// else - alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_FALSE); - alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_BUFFER, GameSounds[si].dsBufferP); + if (ActiveSounds[activeIndex].loop) + alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_TRUE); + else + alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_FALSE); + if (ActiveSounds[activeIndex].pitch != GameSounds[si].pitch) { int ok = PlatChangeSoundPitch (activeIndex, ActiveSounds[activeIndex].pitch); @@ -453,13 +454,17 @@ fprintf (stderr, "Loaded %s\n", GameSounds[soundIndex].wavName); } if ((rfmt == AUDIO_S16LSB) || (rfmt == AUDIO_S16MSB)) { + int bps; + if (rchan == 2) { rfmt = AL_FORMAT_STEREO16; - seclen = len / (rfreq * 2 * 2); + bps = rfreq * 2 * 2; } else if (rchan == 1) { rfmt = AL_FORMAT_MONO16; - seclen = len / (rfreq * 2); + bps = rfreq * 2 * 1; } + + seclen = DIV_FIXED(len, bps); } else return (unsigned char *)0; -- cgit v1.3