make the openal code compile without eax and enable it by default

This commit is contained in:
Jonathan Gray 2013-04-25 15:19:50 +10:00
parent 017bd42a1b
commit e5e1251df8

View file

@ -211,7 +211,7 @@ int s_entityWavVol_back[MAX_GENTITIES];
#define DEFAULT_REF_DISTANCE 300.0f // Default reference distance #define DEFAULT_REF_DISTANCE 300.0f // Default reference distance
#define DEFAULT_VOICE_REF_DISTANCE 1500.0f // Default voice reference distance #define DEFAULT_VOICE_REF_DISTANCE 1500.0f // Default voice reference distance
int s_UseOpenAL = false; // Determines if using Open AL or the default software mixer int s_UseOpenAL = true; // Determines if using Open AL or the default software mixer
ALfloat listener_pos[3]; // Listener Position ALfloat listener_pos[3]; // Listener Position
ALfloat listener_ori[6]; // Listener Orientation ALfloat listener_ori[6]; // Listener Orientation
@ -227,6 +227,7 @@ void S_SetLipSyncs();
// EAX Related // EAX Related
#ifdef HAVE_EAX
typedef struct typedef struct
{ {
ALuint ulNumApertures; ALuint ulNumApertures;
@ -308,6 +309,8 @@ const GUID EAX_PrimaryFXSlotID = { 0xf317866d, 0x924c, 0x450c, { 0x86, 0x1b, 0xe
const GUID EAX_REVERB_EFFECT = { 0xcf95c8f, 0xa3cc, 0x4849, { 0xb0, 0xb6, 0x83, 0x2e, 0xcc, 0x18, 0x22, 0xdf} }; const GUID EAX_REVERB_EFFECT = { 0xcf95c8f, 0xa3cc, 0x4849, { 0xb0, 0xb6, 0x83, 0x2e, 0xcc, 0x18, 0x22, 0xdf} };
#endif // HAVE_EAX
/**************************************************************************************************\ /**************************************************************************************************\
* *
* End of Open AL Specific * End of Open AL Specific
@ -370,10 +373,12 @@ void S_SoundInfo_f(void) {
if (s_UseOpenAL) if (s_UseOpenAL)
{ {
#ifdef HAVE_EAX
Com_Printf("EAX 4.0 %s supported\n",s_bEAX?"is":"not"); Com_Printf("EAX 4.0 %s supported\n",s_bEAX?"is":"not");
Com_Printf("Eal file %s loaded\n",s_bEALFileLoaded?"is":"not"); Com_Printf("Eal file %s loaded\n",s_bEALFileLoaded?"is":"not");
Com_Printf("s_EnvironmentID = %d\n",s_EnvironmentID); Com_Printf("s_EnvironmentID = %d\n",s_EnvironmentID);
Com_Printf("s_bInWater = %s\n",s_bInWater?"true":"false"); Com_Printf("s_bInWater = %s\n",s_bInWater?"true":"false");
#endif
} }
else else
{ {
@ -454,7 +459,7 @@ void S_Init( void ) {
s_CPUType = Cvar_Get("sys_cpuid","",0); s_CPUType = Cvar_Get("sys_cpuid","",0);
#if !(defined __linux__ && defined __i386__) #ifdef _MSC_VER
#if !id386 #if !id386
#else #else
extern unsigned int uiMMXAvailable; extern unsigned int uiMMXAvailable;
@ -478,13 +483,9 @@ void S_Init( void ) {
Cmd_AddCommand("mp3_calcvols", S_MP3_CalcVols_f); Cmd_AddCommand("mp3_calcvols", S_MP3_CalcVols_f);
Cmd_AddCommand("s_dynamic", S_SetDynamicMusic_f); Cmd_AddCommand("s_dynamic", S_SetDynamicMusic_f);
cv = Cvar_Get("s_UseOpenAL" , "0",CVAR_ARCHIVE|CVAR_LATCH);
s_UseOpenAL = !!(cv->integer);
if (s_UseOpenAL) if (s_UseOpenAL)
{ {
ALCDevice = alcOpenDevice((ALubyte*)"DirectSound3D"); ALCDevice = alcOpenDevice(NULL);
if (!ALCDevice) if (!ALCDevice)
return; return;
@ -513,7 +514,9 @@ void S_Init( void ) {
alListenerfv(AL_VELOCITY,listenerVel); alListenerfv(AL_VELOCITY,listenerVel);
alListenerfv(AL_ORIENTATION,listenerOri); alListenerfv(AL_ORIENTATION,listenerOri);
#ifdef HAVE_EAX
InitEAXManager(); InitEAXManager();
#endif
memset(s_channels, 0, sizeof(s_channels)); memset(s_channels, 0, sizeof(s_channels));
@ -537,6 +540,7 @@ void S_Init( void ) {
// Sources / Channels are not sending to any Slots (other than the Listener / Primary FX Slot) // Sources / Channels are not sending to any Slots (other than the Listener / Primary FX Slot)
s_channels[i].lSlotID = -1; s_channels[i].lSlotID = -1;
#ifdef HAVE_EAX
if (s_bEAX) if (s_bEAX)
{ {
// Remove the RoomAuto flag from each Source (to remove Reverb Engine Statistical // Remove the RoomAuto flag from each Source (to remove Reverb Engine Statistical
@ -549,6 +553,7 @@ void S_Init( void ) {
s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_FLAGS, s_eaxSet(&EAXPROPERTYID_EAX40_Source, EAXSOURCE_FLAGS,
s_channels[i].alSource, &ulFlags, sizeof(ulFlags)); s_channels[i].alSource, &ulFlags, sizeof(ulFlags));
} }
#endif
s_numChannels++; s_numChannels++;
} }
@ -596,7 +601,9 @@ void S_Init( void ) {
// for this level // for this level
mapname = Cvar_VariableString( "mapname" ); mapname = Cvar_VariableString( "mapname" );
#ifdef HAVE_EAX
EALFileInit(mapname); EALFileInit(mapname);
#endif
} }
else else
@ -696,7 +703,9 @@ void S_Shutdown( void )
// Close device // Close device
alcCloseDevice(ALCDevice); alcCloseDevice(ALCDevice);
#ifdef HAVE_EAX
ReleaseEAXManager(); ReleaseEAXManager();
#endif
s_numChannels = 0; s_numChannels = 0;
@ -905,6 +914,7 @@ void S_BeginRegistration( void )
s_soundMuted = qfalse; // we can play again s_soundMuted = qfalse; // we can play again
#ifdef HAVE_EAX
// Find name of level so we can load in the appropriate EAL file // Find name of level so we can load in the appropriate EAL file
if (s_UseOpenAL) if (s_UseOpenAL)
{ {
@ -916,6 +926,7 @@ void S_BeginRegistration( void )
s_FXSlotInfo[i].lEnvID = -1; s_FXSlotInfo[i].lEnvID = -1;
} }
} }
#endif
if (s_numSfx == 0) { if (s_numSfx == 0) {
SND_setup(); SND_setup();
@ -934,6 +945,7 @@ void S_BeginRegistration( void )
} }
#ifdef HAVE_EAX
void EALFileInit(char *level) void EALFileInit(char *level)
{ {
long lRoom; long lRoom;
@ -964,7 +976,7 @@ void EALFileInit(char *level)
if (s_bEALFileLoaded) if (s_bEALFileLoaded)
{ {
s_lLastEnvUpdate = timeGetTime(); s_lLastEnvUpdate = Com_Milliseconds();
} }
else else
{ {
@ -980,6 +992,7 @@ void EALFileInit(char *level)
} }
} }
} }
#endif // HAVE_EAX
@ -2310,7 +2323,9 @@ void S_UpdateEntityPosition( int entityNum, const vec3_t origin )
pos[2] = -origin[1]; pos[2] = -origin[1];
alSourcefv(s_channels[i].alSource, AL_POSITION, pos); alSourcefv(s_channels[i].alSource, AL_POSITION, pos);
#ifdef HAVE_EAX
UpdateEAXBuffer(ch); UpdateEAXBuffer(ch);
#endif
} }
/* pos[0] = origin[0]; /* pos[0] = origin[0];
@ -2318,10 +2333,12 @@ void S_UpdateEntityPosition( int entityNum, const vec3_t origin )
pos[2] = -origin[1]; pos[2] = -origin[1];
alSourcefv(s_channels[i].alSource, AL_POSITION, pos); alSourcefv(s_channels[i].alSource, AL_POSITION, pos);
#ifdef HAVE_EAX
if ((s_bEALFileLoaded) && !( ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL ) ) if ((s_bEALFileLoaded) && !( ch->entchannel == CHAN_VOICE || ch->entchannel == CHAN_VOICE_ATTEN || ch->entchannel == CHAN_VOICE_GLOBAL ) )
{ {
UpdateEAXBuffer(ch); UpdateEAXBuffer(ch);
} }
#endif
*/ */
} }
} }
@ -2464,8 +2481,10 @@ Change the volumes of all the playing sounds for changes in their positions
*/ */
void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], int inwater ) void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], int inwater )
{ {
#ifdef HAVE_EAX
EAXOCCLUSIONPROPERTIES eaxOCProp; EAXOCCLUSIONPROPERTIES eaxOCProp;
EAXACTIVEFXSLOTS eaxActiveSlots; EAXACTIVEFXSLOTS eaxActiveSlots;
#endif
unsigned int ulEnvironment; unsigned int ulEnvironment;
int i; int i;
channel_t *ch; channel_t *ch;
@ -2489,7 +2508,7 @@ void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], int inwat
listener_ori[4] = axis[2][2]; listener_ori[4] = axis[2][2];
listener_ori[5] = -axis[2][1]; listener_ori[5] = -axis[2][1];
alListenerfv(AL_ORIENTATION, listener_ori); alListenerfv(AL_ORIENTATION, listener_ori);
#ifdef HAVE_EAX
// Update EAX effects here // Update EAX effects here
if (s_bEALFileLoaded) if (s_bEALFileLoaded)
{ {
@ -2561,6 +2580,7 @@ void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], int inwat
} }
} }
} }
#endif // HAVE_EAX
} }
else else
{ {
@ -2898,8 +2918,10 @@ void S_Update_(void) {
} }
} }
#ifdef HAVE_EAX
if (s_bEALFileLoaded) if (s_bEALFileLoaded)
UpdateEAXBuffer(ch); UpdateEAXBuffer(ch);
#endif
int nBytesDecoded = 0; int nBytesDecoded = 0;
int nTotalBytesDecoded = 0; int nTotalBytesDecoded = 0;
@ -2982,7 +3004,7 @@ void S_Update_(void) {
if (ch->thesfx->lipSyncData) if (ch->thesfx->lipSyncData)
{ {
// Record start time for Lip-syncing // Record start time for Lip-syncing
s_channels[source].iStartTime = timeGetTime(); s_channels[source].iStartTime = Com_Milliseconds();
// Prepare lipsync value(s) // Prepare lipsync value(s)
s_entityWavVol[ ch->entnum ] = ch->thesfx->lipSyncData[0]; s_entityWavVol[ ch->entnum ] = ch->thesfx->lipSyncData[0];
@ -3016,7 +3038,7 @@ void S_Update_(void) {
if (ch->thesfx->lipSyncData) if (ch->thesfx->lipSyncData)
{ {
// Record start time for Lip-syncing // Record start time for Lip-syncing
s_channels[source].iStartTime = timeGetTime(); s_channels[source].iStartTime = Com_Milliseconds();
// Prepare lipsync value(s) // Prepare lipsync value(s)
s_entityWavVol[ ch->entnum ] = ch->thesfx->lipSyncData[0]; s_entityWavVol[ ch->entnum ] = ch->thesfx->lipSyncData[0];
@ -3339,8 +3361,10 @@ void UpdateLoopingSounds()
ch->master_vol = loop->volume; ch->master_vol = loop->volume;
alSourcef(s_channels[i].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.f); alSourcef(s_channels[i].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.f);
#ifdef HAVE_EAX
if (s_bEALFileLoaded) if (s_bEALFileLoaded)
UpdateEAXBuffer(ch); UpdateEAXBuffer(ch);
#endif
ch->bProcessed = true; ch->bProcessed = true;
loop->bProcessed = true; loop->bProcessed = true;
@ -3413,8 +3437,10 @@ void UpdateLoopingSounds()
alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.0f); alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.0f);
alSourcei(s_channels[source].alSource, AL_SOURCE_RELATIVE, ch->fixed_origin ? AL_TRUE : AL_FALSE); alSourcei(s_channels[source].alSource, AL_SOURCE_RELATIVE, ch->fixed_origin ? AL_TRUE : AL_FALSE);
#ifdef HAVE_EAX
if (s_bEALFileLoaded) if (s_bEALFileLoaded)
UpdateEAXBuffer(ch); UpdateEAXBuffer(ch);
#endif
alGetError(); alGetError();
alSourcePlay(s_channels[source].alSource); alSourcePlay(s_channels[source].alSource);
@ -3465,7 +3491,9 @@ void AL_UpdateRawSamples()
size = (s_rawend - s_paintedtime)<<2; size = (s_rawend - s_paintedtime)<<2;
if (size > (MAX_RAW_SAMPLES<<2)) if (size > (MAX_RAW_SAMPLES<<2))
{ {
#ifdef _DEBUG
OutputDebugString("UpdateRawSamples :- Raw Sample buffer has overflowed !!!\n"); OutputDebugString("UpdateRawSamples :- Raw Sample buffer has overflowed !!!\n");
#endif
size = MAX_RAW_SAMPLES<<2; size = MAX_RAW_SAMPLES<<2;
s_paintedtime = s_rawend - MAX_RAW_SAMPLES; s_paintedtime = s_rawend - MAX_RAW_SAMPLES;
} }
@ -3588,7 +3616,7 @@ void S_SetLipSyncs()
char szString[256]; char szString[256];
#endif #endif
currentTime = timeGetTime(); currentTime = Com_Milliseconds();
memset(s_entityWavVol, 0, sizeof(s_entityWavVol)); memset(s_entityWavVol, 0, sizeof(s_entityWavVol));
@ -5279,6 +5307,7 @@ qboolean SND_RegisterAudio_LevelLoadEnd(qboolean bDeleteEverythingNotUsedThisLev
} }
#ifdef HAVE_EAX
/****************************************************************************************************\ /****************************************************************************************************\
* *
* EAX Related * EAX Related
@ -5752,7 +5781,7 @@ void UpdateEAXListener()
if ((!s_lpEAXManager) || (!s_bEAX)) if ((!s_lpEAXManager) || (!s_bEAX))
return; return;
lCurTime = timeGetTime(); lCurTime = Com_Milliseconds();
if ((s_lLastEnvUpdate + ENV_UPDATE_RATE) < lCurTime) if ((s_lLastEnvUpdate + ENV_UPDATE_RATE) < lCurTime)
{ {
@ -6324,3 +6353,4 @@ float CalcDistance(EMPOINT A, EMPOINT B)
{ {
return (float)sqrt(sqr(A.fX - B.fX)+sqr(A.fY - B.fY) + sqr(A.fZ - B.fZ)); return (float)sqrt(sqr(A.fX - B.fX)+sqr(A.fY - B.fY) + sqr(A.fZ - B.fZ));
} }
#endif // HAVE_EAX