mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Convert whitespace indentation to tabs
This commit is contained in:
parent
28c4edfd69
commit
492b7c1a2b
1 changed files with 219 additions and 219 deletions
|
@ -72,7 +72,7 @@ static void AL_InitUnderwaterFilter()
|
|||
// Generate a filter
|
||||
qalGenFilters(1, &underwaterFilter);
|
||||
|
||||
if (qalGetError() != AL_NO_ERROR)
|
||||
if (qalGetError() != AL_NO_ERROR)
|
||||
{
|
||||
Com_Printf("Couldn't generate an OpenAL filter!\n");
|
||||
return;
|
||||
|
@ -81,7 +81,7 @@ static void AL_InitUnderwaterFilter()
|
|||
// Low pass filter for underwater effect
|
||||
qalFilteri(underwaterFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
|
||||
|
||||
if (qalGetError() != AL_NO_ERROR)
|
||||
if (qalGetError() != AL_NO_ERROR)
|
||||
{
|
||||
Com_Printf("Low pass filter is not supported!\n");
|
||||
return;
|
||||
|
@ -93,30 +93,30 @@ static void AL_InitUnderwaterFilter()
|
|||
}
|
||||
|
||||
qboolean AL_Init( void ) {
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if( !QAL_Init() ) {
|
||||
Com_Printf( "ERROR: OpenAL failed to initialize.\n" );
|
||||
return false;
|
||||
}
|
||||
if( !QAL_Init() ) {
|
||||
Com_Printf( "ERROR: OpenAL failed to initialize.\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// check for linear distance extension
|
||||
if( !qalIsExtensionPresent( "AL_EXT_LINEAR_DISTANCE" ) ) {
|
||||
Com_Printf( "ERROR: Required AL_EXT_LINEAR_DISTANCE extension is missing.\n" );
|
||||
goto fail;
|
||||
}
|
||||
// check for linear distance extension
|
||||
if( !qalIsExtensionPresent( "AL_EXT_LINEAR_DISTANCE" ) ) {
|
||||
Com_Printf( "ERROR: Required AL_EXT_LINEAR_DISTANCE extension is missing.\n" );
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// generate source names
|
||||
qalGetError();
|
||||
qalGenSources( 1, &streamSource );
|
||||
if( qalGetError() != AL_NO_ERROR )
|
||||
{
|
||||
Com_Printf( "ERROR: Couldn't get a single Source.\n" );
|
||||
// generate source names
|
||||
qalGetError();
|
||||
qalGenSources( 1, &streamSource );
|
||||
if( qalGetError() != AL_NO_ERROR )
|
||||
{
|
||||
Com_Printf( "ERROR: Couldn't get a single Source.\n" );
|
||||
goto fail;
|
||||
|
||||
} else {
|
||||
// -1 because we already got one channel for streaming
|
||||
for( i = 0; i < MAX_CHANNELS - 1; i++ ) {
|
||||
} else {
|
||||
// -1 because we already got one channel for streaming
|
||||
for( i = 0; i < MAX_CHANNELS - 1; i++ ) {
|
||||
qalGenSources( 1, &s_srcnums[i] );
|
||||
if( qalGetError() != AL_NO_ERROR ) {
|
||||
break;
|
||||
|
@ -127,288 +127,288 @@ qboolean AL_Init( void ) {
|
|||
Com_Printf( "ERROR: Required at least %d sources, but got %d.\n", MIN_CHANNELS, i+1 );
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_numchannels = i;
|
||||
AL_InitStreamSource();
|
||||
s_numchannels = i;
|
||||
AL_InitStreamSource();
|
||||
AL_InitUnderwaterFilter();
|
||||
|
||||
Com_Printf("Number of OpenAL sources: %d\n\n", s_numchannels);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
QAL_Shutdown();
|
||||
return false;
|
||||
QAL_Shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
void AL_Shutdown( void ) {
|
||||
Com_Printf( "Shutting down OpenAL.\n" );
|
||||
Com_Printf( "Shutting down OpenAL.\n" );
|
||||
|
||||
S_AL_StreamDie();
|
||||
S_AL_StreamDie();
|
||||
|
||||
qalDeleteSources(1, &streamSource);
|
||||
qalDeleteFilters(1, &underwaterFilter);
|
||||
|
||||
if( s_numchannels ) {
|
||||
// delete source names
|
||||
qalDeleteSources( s_numchannels, s_srcnums );
|
||||
memset( s_srcnums, 0, sizeof( s_srcnums ) );
|
||||
s_numchannels = 0;
|
||||
}
|
||||
QAL_Shutdown();
|
||||
if( s_numchannels ) {
|
||||
// delete source names
|
||||
qalDeleteSources( s_numchannels, s_srcnums );
|
||||
memset( s_srcnums, 0, sizeof( s_srcnums ) );
|
||||
s_numchannels = 0;
|
||||
}
|
||||
QAL_Shutdown();
|
||||
}
|
||||
|
||||
sfxcache_t *AL_UploadSfx( sfx_t *s, wavinfo_t *s_info, byte *data ) {
|
||||
sfxcache_t *sc;
|
||||
ALsizei size = s_info->samples * s_info->width;
|
||||
ALenum format = s_info->width == 2 ? AL_FORMAT_MONO16 : AL_FORMAT_MONO8;
|
||||
ALuint name;
|
||||
sfxcache_t *sc;
|
||||
ALsizei size = s_info->samples * s_info->width;
|
||||
ALenum format = s_info->width == 2 ? AL_FORMAT_MONO16 : AL_FORMAT_MONO8;
|
||||
ALuint name;
|
||||
|
||||
if( !size ) {
|
||||
return NULL;
|
||||
}
|
||||
if( !size ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
qalGetError();
|
||||
qalGenBuffers( 1, &name );
|
||||
qalBufferData( name, format, data, size, s_info->rate );
|
||||
qalGetError();
|
||||
qalGenBuffers( 1, &name );
|
||||
qalBufferData( name, format, data, size, s_info->rate );
|
||||
active_buffers++;
|
||||
if( qalGetError() != AL_NO_ERROR ) {
|
||||
return NULL;
|
||||
}
|
||||
if( qalGetError() != AL_NO_ERROR ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// allocate placeholder sfxcache
|
||||
sc = s->cache = Z_TagMalloc(sizeof(*sc), 0);
|
||||
sc->length = s_info->samples * 1000 / s_info->rate; // in msec
|
||||
sc->loopstart = s_info->loopstart;
|
||||
sc->width = s_info->width;
|
||||
sc->size = size;
|
||||
sc->bufnum = name;
|
||||
// allocate placeholder sfxcache
|
||||
sc = s->cache = Z_TagMalloc(sizeof(*sc), 0);
|
||||
sc->length = s_info->samples * 1000 / s_info->rate; // in msec
|
||||
sc->loopstart = s_info->loopstart;
|
||||
sc->width = s_info->width;
|
||||
sc->size = size;
|
||||
sc->bufnum = name;
|
||||
|
||||
return sc;
|
||||
return sc;
|
||||
}
|
||||
|
||||
void AL_DeleteSfx( sfx_t *s ) {
|
||||
sfxcache_t *sc;
|
||||
ALuint name;
|
||||
sfxcache_t *sc;
|
||||
ALuint name;
|
||||
|
||||
sc = s->cache;
|
||||
if( !sc ) {
|
||||
return;
|
||||
}
|
||||
sc = s->cache;
|
||||
if( !sc ) {
|
||||
return;
|
||||
}
|
||||
|
||||
name = sc->bufnum;
|
||||
qalDeleteBuffers( 1, &name );
|
||||
name = sc->bufnum;
|
||||
qalDeleteBuffers( 1, &name );
|
||||
active_buffers--;
|
||||
}
|
||||
|
||||
void AL_StopChannel( channel_t *ch ) {
|
||||
|
||||
if (s_show->value > 1)
|
||||
Com_Printf("%s: %s\n", __func__, ch->sfx->name );
|
||||
if (s_show->value > 1)
|
||||
Com_Printf("%s: %s\n", __func__, ch->sfx->name );
|
||||
|
||||
// stop it
|
||||
qalSourceStop( ch->srcnum );
|
||||
qalSourcei( ch->srcnum, AL_BUFFER, AL_NONE );
|
||||
memset (ch, 0, sizeof(*ch));
|
||||
// stop it
|
||||
qalSourceStop( ch->srcnum );
|
||||
qalSourcei( ch->srcnum, AL_BUFFER, AL_NONE );
|
||||
memset (ch, 0, sizeof(*ch));
|
||||
}
|
||||
|
||||
static void AL_Spatialize( channel_t *ch ) {
|
||||
vec3_t origin;
|
||||
vec3_t origin;
|
||||
|
||||
// anything coming from the view entity will always be full volume
|
||||
// no attenuation = no spatialization
|
||||
if( ch->entnum == -1 || ch->entnum == cl.playernum + 1 || !ch->dist_mult ) {
|
||||
VectorCopy( listener_origin, origin );
|
||||
} else if( ch->fixed_origin ) {
|
||||
VectorCopy( ch->origin, origin );
|
||||
} else {
|
||||
CL_GetEntitySoundOrigin( ch->entnum, origin );
|
||||
}
|
||||
// anything coming from the view entity will always be full volume
|
||||
// no attenuation = no spatialization
|
||||
if( ch->entnum == -1 || ch->entnum == cl.playernum + 1 || !ch->dist_mult ) {
|
||||
VectorCopy( listener_origin, origin );
|
||||
} else if( ch->fixed_origin ) {
|
||||
VectorCopy( ch->origin, origin );
|
||||
} else {
|
||||
CL_GetEntitySoundOrigin( ch->entnum, origin );
|
||||
}
|
||||
|
||||
qalSource3f( ch->srcnum, AL_POSITION, AL_UnpackVector( origin ) );
|
||||
qalSource3f( ch->srcnum, AL_POSITION, AL_UnpackVector( origin ) );
|
||||
}
|
||||
|
||||
void AL_PlayChannel( channel_t *ch ) {
|
||||
sfxcache_t *sc = ch->sfx->cache;
|
||||
sfxcache_t *sc = ch->sfx->cache;
|
||||
|
||||
if (s_show->value > 1)
|
||||
Com_Printf("%s: %s\n", __func__, ch->sfx->name );
|
||||
if (s_show->value > 1)
|
||||
Com_Printf("%s: %s\n", __func__, ch->sfx->name );
|
||||
|
||||
ch->srcnum = s_srcnums[ch - channels];
|
||||
qalGetError();
|
||||
qalSourcei( ch->srcnum, AL_BUFFER, sc->bufnum );
|
||||
qalSourcei( ch->srcnum, AL_LOOPING, ch->autosound ? AL_TRUE : AL_FALSE );
|
||||
qalSourcef( ch->srcnum, AL_GAIN, ch->master_vol );
|
||||
qalSourcef( ch->srcnum, AL_REFERENCE_DISTANCE, SOUND_FULLVOLUME );
|
||||
qalSourcef( ch->srcnum, AL_MAX_DISTANCE, 8192 );
|
||||
qalSourcef( ch->srcnum, AL_ROLLOFF_FACTOR, ch->dist_mult * ( 8192 - SOUND_FULLVOLUME ) );
|
||||
ch->srcnum = s_srcnums[ch - channels];
|
||||
qalGetError();
|
||||
qalSourcei( ch->srcnum, AL_BUFFER, sc->bufnum );
|
||||
qalSourcei( ch->srcnum, AL_LOOPING, ch->autosound ? AL_TRUE : AL_FALSE );
|
||||
qalSourcef( ch->srcnum, AL_GAIN, ch->master_vol );
|
||||
qalSourcef( ch->srcnum, AL_REFERENCE_DISTANCE, SOUND_FULLVOLUME );
|
||||
qalSourcef( ch->srcnum, AL_MAX_DISTANCE, 8192 );
|
||||
qalSourcef( ch->srcnum, AL_ROLLOFF_FACTOR, ch->dist_mult * ( 8192 - SOUND_FULLVOLUME ) );
|
||||
|
||||
AL_Spatialize( ch );
|
||||
AL_Spatialize( ch );
|
||||
|
||||
// play it
|
||||
qalSourcePlay( ch->srcnum );
|
||||
if( qalGetError() != AL_NO_ERROR ) {
|
||||
AL_StopChannel( ch );
|
||||
}
|
||||
// play it
|
||||
qalSourcePlay( ch->srcnum );
|
||||
if( qalGetError() != AL_NO_ERROR ) {
|
||||
AL_StopChannel( ch );
|
||||
}
|
||||
}
|
||||
|
||||
void AL_StopAllChannels( void ) {
|
||||
int i;
|
||||
channel_t *ch;
|
||||
int i;
|
||||
channel_t *ch;
|
||||
|
||||
ch = channels;
|
||||
for( i = 0; i < s_numchannels; i++, ch++ ) {
|
||||
if (!ch->sfx)
|
||||
continue;
|
||||
AL_StopChannel( ch );
|
||||
}
|
||||
s_rawend = 0;
|
||||
S_AL_StreamDie();
|
||||
ch = channels;
|
||||
for( i = 0; i < s_numchannels; i++, ch++ ) {
|
||||
if (!ch->sfx)
|
||||
continue;
|
||||
AL_StopChannel( ch );
|
||||
}
|
||||
s_rawend = 0;
|
||||
S_AL_StreamDie();
|
||||
}
|
||||
|
||||
static channel_t *AL_FindLoopingSound( int entnum, sfx_t *sfx ) {
|
||||
int i;
|
||||
channel_t *ch;
|
||||
int i;
|
||||
channel_t *ch;
|
||||
|
||||
ch = channels;
|
||||
for( i = 0; i < s_numchannels; i++, ch++ ) {
|
||||
if( !ch->sfx )
|
||||
continue;
|
||||
if( !ch->autosound )
|
||||
continue;
|
||||
if( ch->entnum != entnum )
|
||||
continue;
|
||||
if( ch->sfx != sfx )
|
||||
continue;
|
||||
return ch;
|
||||
}
|
||||
ch = channels;
|
||||
for( i = 0; i < s_numchannels; i++, ch++ ) {
|
||||
if( !ch->sfx )
|
||||
continue;
|
||||
if( !ch->autosound )
|
||||
continue;
|
||||
if( ch->entnum != entnum )
|
||||
continue;
|
||||
if( ch->sfx != sfx )
|
||||
continue;
|
||||
return ch;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void AL_AddLoopSounds( void ) {
|
||||
int i;
|
||||
int sounds[MAX_EDICTS];
|
||||
channel_t *ch;
|
||||
sfx_t *sfx;
|
||||
sfxcache_t *sc;
|
||||
int num;
|
||||
entity_state_t *ent;
|
||||
int i;
|
||||
int sounds[MAX_EDICTS];
|
||||
channel_t *ch;
|
||||
sfx_t *sfx;
|
||||
sfxcache_t *sc;
|
||||
int num;
|
||||
entity_state_t *ent;
|
||||
|
||||
if( cls.state != ca_active || cl_paused->value || !s_ambient->value ) {
|
||||
return;
|
||||
}
|
||||
if( cls.state != ca_active || cl_paused->value || !s_ambient->value ) {
|
||||
return;
|
||||
}
|
||||
|
||||
S_BuildSoundList( sounds );
|
||||
S_BuildSoundList( sounds );
|
||||
|
||||
for( i = 0; i < cl.frame.num_entities; i++ ) {
|
||||
if (!sounds[i])
|
||||
continue;
|
||||
for( i = 0; i < cl.frame.num_entities; i++ ) {
|
||||
if (!sounds[i])
|
||||
continue;
|
||||
|
||||
sfx = cl.sound_precache[sounds[i]];
|
||||
if (!sfx)
|
||||
continue; // bad sound effect
|
||||
sc = sfx->cache;
|
||||
if (!sc)
|
||||
continue;
|
||||
sfx = cl.sound_precache[sounds[i]];
|
||||
if (!sfx)
|
||||
continue; // bad sound effect
|
||||
sc = sfx->cache;
|
||||
if (!sc)
|
||||
continue;
|
||||
|
||||
num = ( cl.frame.parse_entities + i ) & ( MAX_PARSE_ENTITIES - 1 );
|
||||
num = ( cl.frame.parse_entities + i ) & ( MAX_PARSE_ENTITIES - 1 );
|
||||
ent = &cl_parse_entities [ num ];
|
||||
|
||||
ch = AL_FindLoopingSound( ent->number, sfx );
|
||||
if( ch ) {
|
||||
ch->autoframe = s_framecount;
|
||||
ch->end = paintedtime + sc->length;
|
||||
continue;
|
||||
}
|
||||
ch = AL_FindLoopingSound( ent->number, sfx );
|
||||
if( ch ) {
|
||||
ch->autoframe = s_framecount;
|
||||
ch->end = paintedtime + sc->length;
|
||||
continue;
|
||||
}
|
||||
|
||||
// allocate a channel
|
||||
ch = S_PickChannel(0, 0);
|
||||
if (!ch)
|
||||
continue;
|
||||
// allocate a channel
|
||||
ch = S_PickChannel(0, 0);
|
||||
if (!ch)
|
||||
continue;
|
||||
|
||||
ch->autosound = true; // remove next frame
|
||||
ch->autoframe = s_framecount;
|
||||
ch->sfx = sfx;
|
||||
ch->entnum = ent->number;
|
||||
ch->master_vol = 1;
|
||||
ch->dist_mult = SOUND_LOOPATTENUATE;
|
||||
ch->end = paintedtime + sc->length;
|
||||
ch->autosound = true; // remove next frame
|
||||
ch->autoframe = s_framecount;
|
||||
ch->sfx = sfx;
|
||||
ch->entnum = ent->number;
|
||||
ch->master_vol = 1;
|
||||
ch->dist_mult = SOUND_LOOPATTENUATE;
|
||||
ch->end = paintedtime + sc->length;
|
||||
|
||||
AL_PlayChannel( ch );
|
||||
}
|
||||
AL_PlayChannel( ch );
|
||||
}
|
||||
}
|
||||
|
||||
static void AL_IssuePlaysounds( void ) {
|
||||
playsound_t *ps;
|
||||
playsound_t *ps;
|
||||
|
||||
// start any playsounds
|
||||
while (1) {
|
||||
ps = s_pendingplays.next;
|
||||
if (ps == &s_pendingplays)
|
||||
break; // no more pending sounds
|
||||
if (ps->begin > paintedtime)
|
||||
break;
|
||||
S_IssuePlaysound (ps);
|
||||
}
|
||||
// start any playsounds
|
||||
while (1) {
|
||||
ps = s_pendingplays.next;
|
||||
if (ps == &s_pendingplays)
|
||||
break; // no more pending sounds
|
||||
if (ps->begin > paintedtime)
|
||||
break;
|
||||
S_IssuePlaysound (ps);
|
||||
}
|
||||
}
|
||||
|
||||
void AL_Update( void ) {
|
||||
int i;
|
||||
channel_t *ch;
|
||||
vec_t orientation[6];
|
||||
int i;
|
||||
channel_t *ch;
|
||||
vec_t orientation[6];
|
||||
|
||||
paintedtime = cl.time;
|
||||
paintedtime = cl.time;
|
||||
|
||||
// set listener parameters
|
||||
qalListener3f( AL_POSITION, AL_UnpackVector( listener_origin ) );
|
||||
AL_CopyVector( listener_forward, orientation );
|
||||
AL_CopyVector( listener_up, orientation + 3 );
|
||||
qalListenerfv( AL_ORIENTATION, orientation );
|
||||
qalListenerf( AL_GAIN, s_volume->value );
|
||||
qalDistanceModel( AL_LINEAR_DISTANCE_CLAMPED );
|
||||
// set listener parameters
|
||||
qalListener3f( AL_POSITION, AL_UnpackVector( listener_origin ) );
|
||||
AL_CopyVector( listener_forward, orientation );
|
||||
AL_CopyVector( listener_up, orientation + 3 );
|
||||
qalListenerfv( AL_ORIENTATION, orientation );
|
||||
qalListenerf( AL_GAIN, s_volume->value );
|
||||
qalDistanceModel( AL_LINEAR_DISTANCE_CLAMPED );
|
||||
|
||||
// update spatialization for dynamic sounds
|
||||
ch = channels;
|
||||
for( i = 0; i < s_numchannels; i++, ch++ ) {
|
||||
if( !ch->sfx )
|
||||
continue;
|
||||
// update spatialization for dynamic sounds
|
||||
ch = channels;
|
||||
for( i = 0; i < s_numchannels; i++, ch++ ) {
|
||||
if( !ch->sfx )
|
||||
continue;
|
||||
|
||||
if( ch->autosound ) {
|
||||
// autosounds are regenerated fresh each frame
|
||||
if( ch->autoframe != s_framecount ) {
|
||||
AL_StopChannel( ch );
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
ALenum state;
|
||||
if( ch->autosound ) {
|
||||
// autosounds are regenerated fresh each frame
|
||||
if( ch->autoframe != s_framecount ) {
|
||||
AL_StopChannel( ch );
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
ALenum state;
|
||||
|
||||
qalGetError();
|
||||
qalGetSourcei( ch->srcnum, AL_SOURCE_STATE, &state );
|
||||
if( qalGetError() != AL_NO_ERROR || state == AL_STOPPED ) {
|
||||
AL_StopChannel( ch );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
qalGetError();
|
||||
qalGetSourcei( ch->srcnum, AL_SOURCE_STATE, &state );
|
||||
if( qalGetError() != AL_NO_ERROR || state == AL_STOPPED ) {
|
||||
AL_StopChannel( ch );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_show->value) {
|
||||
Com_Printf ("%3i %s\n", ch->master_vol, ch->sfx->name);
|
||||
}
|
||||
if (s_show->value) {
|
||||
Com_Printf ("%3i %s\n", ch->master_vol, ch->sfx->name);
|
||||
}
|
||||
|
||||
AL_Spatialize(ch); // respatialize channel
|
||||
}
|
||||
AL_Spatialize(ch); // respatialize channel
|
||||
}
|
||||
|
||||
s_framecount++;
|
||||
s_framecount++;
|
||||
|
||||
// add loopsounds
|
||||
AL_AddLoopSounds ();
|
||||
// add loopsounds
|
||||
AL_AddLoopSounds ();
|
||||
|
||||
// add music
|
||||
OGG_Stream();
|
||||
S_AL_StreamUpdate();
|
||||
// add music
|
||||
OGG_Stream();
|
||||
S_AL_StreamUpdate();
|
||||
|
||||
AL_IssuePlaysounds();
|
||||
AL_IssuePlaysounds();
|
||||
}
|
||||
|
||||
void AL_Underwater()
|
||||
|
@ -421,7 +421,7 @@ void AL_Underwater()
|
|||
// Apply to all sources
|
||||
for (i = 0; i < s_numchannels; i++)
|
||||
{
|
||||
qalSourcei(s_srcnums[i], AL_DIRECT_FILTER, underwaterFilter);
|
||||
qalSourcei(s_srcnums[i], AL_DIRECT_FILTER, underwaterFilter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -432,7 +432,7 @@ void AL_Overwater()
|
|||
// Apply to all sources
|
||||
for (i = 0; i < s_numchannels; i++)
|
||||
{
|
||||
qalSourcei(s_srcnums[i], AL_DIRECT_FILTER, 0);
|
||||
qalSourcei(s_srcnums[i], AL_DIRECT_FILTER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue