Try not being so lame with the sound initialization.

This commit is contained in:
Steven Fuller 2008-06-09 00:12:33 -07:00 committed by Patryk Obara
parent fc69f56b9a
commit c11821b898

View file

@ -169,6 +169,7 @@ openal.c TODO:
*/ */
int PlatStartSoundSys() int PlatStartSoundSys()
{ {
int initSources;
int i; int i;
char buf[42]; char buf[42];
ALfloat pos[] = { 0.0, 0.0, 0.0 }, ALfloat pos[] = { 0.0, 0.0, 0.0 },
@ -244,17 +245,22 @@ int PlatStartSoundSys()
PlatSetEnviroment(EAX_ENVIRONMENT_DEFAULT, EAX_REVERBMIX_USEDISTANCE); PlatSetEnviroment(EAX_ENVIRONMENT_DEFAULT, EAX_REVERBMIX_USEDISTANCE);
#endif #endif
memset( ActiveSounds, 0, sizeof(ActiveSounds) ); initSources = 1;
for (i = 0; i < SOUND_MAXACTIVE; i++) { for (i = 0; i < SOUND_MAXACTIVE; i++) {
ALuint p; ALuint p;
alGenSources (1, &p); if( initSources ) {
if (alGetError () != AL_NO_ERROR) { alGenSources (1, &p);
// TODO - need to figure out how many sources we are allowed to make if (alGetError () != AL_NO_ERROR) {
//fprintf (stderr, "alGenSources () error = ..."); // TODO - need to figure out how many sources we are allowed to make
//return -1; //fprintf (stderr, "alGenSources () error = ...");
break; //return -1;
initSources = 0;
p = 0;
}
} else {
p = 0;
} }
// TODO: remove the incorrectly named PropSetP variables // TODO: remove the incorrectly named PropSetP variables
@ -268,13 +274,15 @@ int PlatStartSoundSys()
ActiveSounds[i].PropSetP_vel[1] = 0.0; ActiveSounds[i].PropSetP_vel[1] = 0.0;
ActiveSounds[i].PropSetP_vel[2] = 0.0; ActiveSounds[i].PropSetP_vel[2] = 0.0;
alSourcef(p, AL_PITCH, 1.0f); if( initSources ) {
alSourcef(p, AL_GAIN, 1.0f); alSourcef(p, AL_PITCH, 1.0f);
alSourcefv(p, AL_POSITION, ActiveSounds[i].PropSetP_pos); alSourcef(p, AL_GAIN, 1.0f);
alSourcefv(p, AL_VELOCITY, ActiveSounds[i].PropSetP_vel); 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_ROLLOFF_FACTOR, 0.01f);
alSourcef(p, AL_REFERENCE_DISTANCE, 1.0f); alSourcef(p, AL_REFERENCE_DISTANCE, 1.0f);
}
} }
SoundActivated = 1; SoundActivated = 1;