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

This commit is contained in:
Jonathan Gray 2013-04-23 21:56:22 +10:00
parent 0833f632ad
commit f2f8459cb8

View file

@ -208,7 +208,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
@ -224,6 +224,7 @@ void S_SetLipSyncs();
// EAX Related // EAX Related
#ifdef HAVE_EAX
typedef struct typedef struct
{ {
ALuint ulNumApertures; ALuint ulNumApertures;
@ -305,6 +306,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
@ -364,10 +367,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
{ {
@ -448,7 +453,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;
@ -472,13 +477,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;
@ -507,7 +508,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));
@ -531,6 +534,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
@ -544,6 +548,7 @@ void S_Init( void ) {
s_channels[i].alSource, &ulFlags, sizeof(ulFlags))!=AL_NO_ERROR) s_channels[i].alSource, &ulFlags, sizeof(ulFlags))!=AL_NO_ERROR)
OutputDebugString("Failed to to remove Source flags\n"); OutputDebugString("Failed to to remove Source flags\n");
} }
#endif
s_numChannels++; s_numChannels++;
} }
@ -591,7 +596,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
@ -690,7 +697,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;
@ -899,6 +908,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)
{ {
@ -910,6 +920,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();
@ -927,7 +938,7 @@ void S_BeginRegistration( void )
} }
} }
#ifdef HAVE_EAX
static void EALFileInit(char *level) static void EALFileInit(char *level)
{ {
long lRoom; long lRoom;
@ -958,7 +969,7 @@ static void EALFileInit(char *level)
if (s_bEALFileLoaded) if (s_bEALFileLoaded)
{ {
s_lLastEnvUpdate = timeGetTime(); s_lLastEnvUpdate = Com_Milliseconds();
} }
else else
{ {
@ -974,6 +985,7 @@ static void EALFileInit(char *level)
} }
} }
} }
#endif // HAVE_EAX
@ -2260,7 +2272,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];
@ -2268,10 +2282,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
*/ */
} }
} }
@ -2414,8 +2430,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], qboolean inwater ) void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], qboolean 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;
@ -2438,7 +2456,7 @@ void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], qboolean
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)
{ {
@ -2510,6 +2528,7 @@ void S_Respatialize( int entityNum, const vec3_t head, vec3_t axis[3], qboolean
} }
} }
} }
#endif // HAVE_EAX
} }
else else
{ {
@ -2605,7 +2624,7 @@ qboolean S_ScanChannelStarts( void ) {
// this is now called AFTER the DMA painting, since it's only the painter calls that cause the MP3s to be unpacked, // this is now called AFTER the DMA painting, since it's only the painter calls that cause the MP3s to be unpacked,
// and therefore to have data readable by the lip-sync volume calc code. // and therefore to have data readable by the lip-sync volume calc code.
// //
void S_DoLipSynchs( const s_oldpaintedtime ) void S_DoLipSynchs( const int s_oldpaintedtime )
{ {
channel_t *ch; channel_t *ch;
int i; int i;
@ -2847,8 +2866,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;
@ -2931,7 +2952,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];
@ -2965,7 +2986,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];
@ -3288,8 +3309,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;
@ -3368,8 +3391,10 @@ void UpdateLoopingSounds()
{ {
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, DEFAULT_REF_DISTANCE); alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, DEFAULT_REF_DISTANCE);
} }
#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);
@ -3420,7 +3445,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;
} }
@ -3543,7 +3570,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));
@ -5230,6 +5257,7 @@ qboolean SND_RegisterAudio_LevelLoadEnd(qboolean bDeleteEverythingNotUsedThisLev
} }
#ifdef HAVE_EAX
/****************************************************************************************************\ /****************************************************************************************************\
* *
* EAX Related * EAX Related
@ -5705,7 +5733,7 @@ static 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)
{ {
@ -6278,3 +6306,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