summaryrefslogtreecommitdiff
path: root/src/openal.c
diff options
context:
space:
mode:
authorSteven Fuller <relnev@icculus.org>2001-08-14 23:36:15 +0000
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 02:22:36 +0200
commit14d3cc45bcf1a9dce1e982fd82b79d7053be4048 (patch)
treea313e704cdc20ab2095ec8f80bb7bebf278af3c6 /src/openal.c
parent48c6088c27bab6ed892fe52df99ca7d5f1803597 (diff)
Fixed sound length and looping. (Setting looping on a source must be done
after setting the buffer)
Diffstat (limited to 'src/openal.c')
-rw-r--r--src/openal.c19
1 files changed, 12 insertions, 7 deletions
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;