summaryrefslogtreecommitdiff
path: root/src/openal.c
diff options
context:
space:
mode:
authorSteven Fuller <relnev@icculus.org>2008-06-09 00:12:33 -0700
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 02:22:37 +0200
commitc11821b898be9593e8fa5dd337a60fb9224b3d81 (patch)
treed231aec84637a705ea8019712db3734c02e6291a /src/openal.c
parentfc69f56b9af0392fa10375696ea1e1292c3a2aa7 (diff)
Try not being so lame with the sound initialization.
Diffstat (limited to 'src/openal.c')
-rw-r--r--src/openal.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/openal.c b/src/openal.c
index b259abb..948a5bc 100644
--- a/src/openal.c
+++ b/src/openal.c
@@ -169,6 +169,7 @@ openal.c TODO:
*/
int PlatStartSoundSys()
{
+ int initSources;
int i;
char buf[42];
ALfloat pos[] = { 0.0, 0.0, 0.0 },
@@ -244,17 +245,22 @@ int PlatStartSoundSys()
PlatSetEnviroment(EAX_ENVIRONMENT_DEFAULT, EAX_REVERBMIX_USEDISTANCE);
#endif
- memset( ActiveSounds, 0, sizeof(ActiveSounds) );
-
+ initSources = 1;
+
for (i = 0; i < SOUND_MAXACTIVE; i++) {
ALuint p;
- alGenSources (1, &p);
- if (alGetError () != AL_NO_ERROR) {
- // TODO - need to figure out how many sources we are allowed to make
- //fprintf (stderr, "alGenSources () error = ...");
- //return -1;
- break;
+ if( initSources ) {
+ alGenSources (1, &p);
+ if (alGetError () != AL_NO_ERROR) {
+ // TODO - need to figure out how many sources we are allowed to make
+ //fprintf (stderr, "alGenSources () error = ...");
+ //return -1;
+ initSources = 0;
+ p = 0;
+ }
+ } else {
+ p = 0;
}
// TODO: remove the incorrectly named PropSetP variables
@@ -268,13 +274,15 @@ int PlatStartSoundSys()
ActiveSounds[i].PropSetP_vel[1] = 0.0;
ActiveSounds[i].PropSetP_vel[2] = 0.0;
- alSourcef(p, AL_PITCH, 1.0f);
- alSourcef(p, AL_GAIN, 1.0f);
- alSourcefv(p, AL_POSITION, ActiveSounds[i].PropSetP_pos);
- alSourcefv(p, AL_VELOCITY, ActiveSounds[i].PropSetP_vel);
+ if( initSources ) {
+ alSourcef(p, AL_PITCH, 1.0f);
+ alSourcef(p, AL_GAIN, 1.0f);
+ alSourcefv(p, AL_POSITION, ActiveSounds[i].PropSetP_pos);
+ alSourcefv(p, AL_VELOCITY, ActiveSounds[i].PropSetP_vel);
- alSourcef(p, AL_ROLLOFF_FACTOR, 0.01f);
- alSourcef(p, AL_REFERENCE_DISTANCE, 1.0f);
+ alSourcef(p, AL_ROLLOFF_FACTOR, 0.01f);
+ alSourcef(p, AL_REFERENCE_DISTANCE, 1.0f);
+ }
}
SoundActivated = 1;