Skip to content
This repository has been archived by the owner on Oct 27, 2023. It is now read-only.

Commit

Permalink
Switch to full-time OpenAL Soft
Browse files Browse the repository at this point in the history
OpenAL mode now requires OpenAL soft 64 bit .dll to be present.

We've already beusing the dll
Fix the bug of the cinematics from 1.3 not stopping sound when you interrupt the cinematic, it keep playing sound even if you demo funmap1 it still plays then when its done playing the audio it throw user back to menu a slight crash, this is understanadble becuase how old the repo we are pulling from.
  • Loading branch information
OmegaMinus1 committed Aug 6, 2020
1 parent 1d2b02f commit 276978a
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 7 deletions.
4 changes: 4 additions & 0 deletions VC/inc/AL/al.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ AL_API void AL_APIENTRY alDistanceModel(ALenum distanceModel);
#define AL_EXPONENT_DISTANCE 0xD005
#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006

/** OpenAL Soft*/
#define AL_SOURCE_SPATIALIZE_SOFT 0x1214
#define AL_AUTO_SOFT 0x0002

/** Renderer State management. */
AL_API void AL_APIENTRY alEnable(ALenum capability);
AL_API void AL_APIENTRY alDisable(ALenum capability);
Expand Down
13 changes: 13 additions & 0 deletions VC/inc/AL/alc.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ typedef void ALCvoid;
*/
#define ALC_ALL_DEVICES_SPECIFIER 0x1013

/**OpenAL Soft */
#define ALC_HRTF_SOFT 0x1992
#define ALC_HRTF_ID_SOFT 0x1996
#define ALC_DONT_CARE_SOFT 0x0002
#define ALC_HRTF_STATUS_SOFT 0x1993
#define ALC_NUM_HRTF_SPECIFIERS_SOFT 0x1994
#define ALC_HRTF_SPECIFIER_SOFT 0x1995
#define ALC_HRTF_DISABLED_SOFT 0x0000
#define ALC_HRTF_ENABLED_SOFT 0x0001
#define ALC_HRTF_DENIED_SOFT 0x0002
#define ALC_HRTF_REQUIRED_SOFT 0x0003
#define ALC_HRTF_HEADPHONES_DETECTED_SOFT 0x0004
#define ALC_HRTF_UNSUPPORTED_FORMAT_SOFT 0x0005

/** Context management. */
ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint* attrlist);
Expand Down
2 changes: 1 addition & 1 deletion src/client/cin.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Called when either the cinematic completes, or it is aborted
void SCR_FinishCinematic(void)
{
SCR_StopCinematic();

AL_UnqueueRawSamples();
// tell the server to advance to the next map / cinematic
CL_ClientCommand(va("nextserver %i\n", cl.servercount));
}
Expand Down
19 changes: 14 additions & 5 deletions src/client/sound/al.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ AL_StreamDie(void)

/* Un-queue any buffers, and delete them */
qalGetSourcei(streamSource, AL_BUFFERS_QUEUED, &numBuffers);
qalSourcei(streamSource, AL_DIRECT_FILTER, 0);
qalSource3i(streamSource, AL_AUXILIARY_SEND_FILTER, 0, 0, AL_FILTER_NULL);

while (numBuffers--)
{
Expand Down Expand Up @@ -119,6 +121,8 @@ AL_StreamUpdate(void)
{
/* Un-queue any already played buffers and delete them */
qalGetSourcei(streamSource, AL_BUFFERS_PROCESSED, &numBuffers);
qalSourcei(streamSource, AL_DIRECT_FILTER, 0);
qalSource3i(streamSource, AL_AUXILIARY_SEND_FILTER, 0, 0, AL_FILTER_NULL);

while (numBuffers--)
{
Expand Down Expand Up @@ -545,6 +549,7 @@ void AL_Shutdown(void)
qalDeleteSources(1, &streamSource);
qalDeleteFilters(1, &underwaterFilter);
qalDeleteEffects(1, &ReverbEffect);
qalDeleteAuxiliaryEffectSlots(1, &ReverbEffectSlot);

if (s_numchannels) {
// delete source names
Expand Down Expand Up @@ -576,13 +581,13 @@ sfxcache_t *AL_UploadSfx(sfx_t *s)
return NULL;
}

#if 0
//#if 0
// specify OpenAL-Soft style loop points
if (s_info.loopstart > 0 && qalIsExtensionPresent("AL_SOFT_loop_points")) {
ALint points[2] = { s_info.loopstart, s_info.samples };
qalBufferiv(name, AL_LOOP_POINTS_SOFT, points);
}
#endif
//#endif

// allocate placeholder sfxcache
sc = s->cache = S_Malloc(sizeof(*sc));
Expand Down Expand Up @@ -685,6 +690,8 @@ void AL_StopChannel(channel_t *ch)
// stop it
qalSourceStop(ch->srcnum);
qalSourcei(ch->srcnum, AL_BUFFER, AL_NONE);
qalSourcei(ch->srcnum, AL_DIRECT_FILTER, 0);
qalSource3i(ch->srcnum, AL_AUXILIARY_SEND_FILTER, 0, 0, AL_FILTER_NULL);
memset(ch, 0, sizeof(*ch));
}

Expand All @@ -707,8 +714,9 @@ void AL_PlayChannel(channel_t *ch)
}
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));
qalSourcef(ch->srcnum, AL_MAX_DISTANCE, 8192); //qalSourcef(ch->srcnum, AL_MAX_DISTANCE, 8192);
qalSourcef(ch->srcnum, AL_ROLLOFF_FACTOR, 0.2); //qalSourcef(ch->srcnum, AL_ROLLOFF_FACTOR, ch->dist_mult * (8192 - SOUND_FULLVOLUME));
qalSourcei(ch->srcnum, AL_SOURCE_SPATIALIZE_SOFT, AL_AUTO_SOFT);

AL_Spatialize(ch);

Expand Down Expand Up @@ -979,7 +987,8 @@ void AL_Update(void)
AL_CopyVector(listener_up, orientation + 3);
qalListenerfv(AL_ORIENTATION, orientation);
qalListenerf(AL_GAIN, S_GetLinearVolume(s_volume->value));
qalDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
//qalDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
qalDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);

if (s_doppler->value) {
CL_GetViewVelocity(listener_velocity);
Expand Down
38 changes: 37 additions & 1 deletion src/client/sound/qal/dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ qboolean QAL_Init(void)
al_driver->flags |= CVAR_SOUND;
al_device->flags |= CVAR_SOUND;

if (qalcIsExtensionPresent(device, "ALC_EXT_EFX")) {
if (qalcIsExtensionPresent(device, "ALC_EXT_EFX") && strstr(qalGetString(AL_RENDERER), "OpenAL Soft")) {
qalGenFilters = qalcGetProcAddress(device, "alGenFilters");
qalFilteri = qalcGetProcAddress(device, "alFilteri");
qalFilterf = qalcGetProcAddress(device, "alFilterf");
Expand Down Expand Up @@ -163,6 +163,42 @@ qboolean QAL_Init(void)
Com_Printf("OpenAL EFX extensions NOT available.\n");
}

if (qalcIsExtensionPresent(device, "ALC_SOFT_HRTF"))
{
ALCint *enabled;
ALCint *status;
qalcGetIntegerv(device, ALC_HRTF_SOFT, 1, &enabled);
qalcGetIntegerv(device, ALC_HRTF_STATUS_SOFT, 1, &status);

Com_Printf("HRTF enabled: %i\n", enabled);

if ((int)status == 0)
{
Com_Printf("HRTF Status: Disabled\n");
}
else if ((int)status == 1)
{
Com_Printf("HRTF Status: Enabled\n");
}
else if ((int)status == 2)
{
Com_Printf("HRTF Status: Denied\n");
}
else if ((int)status == 3)
{
Com_Printf("HRTF Status: Required\n");
}
else if ((int)status == 4)
{
Com_Printf("HRTF Status: Headphones\n");
}
else if ((int)status == 5)
{
Com_Printf("HRTF Status: Unsupported\n");
}

Com_Printf("HRTF preset: %s\n", qalcGetString(device, ALC_HRTF_SPECIFIER_SOFT));
}

return qtrue;

Expand Down

0 comments on commit 276978a

Please sign in to comment.