mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
reduce the heavy pointer dereferencing needed to access the sound plugins
This commit is contained in:
parent
c103d77157
commit
93b767d4e0
2 changed files with 49 additions and 42 deletions
|
@ -92,6 +92,8 @@ static general_funcs_t plugin_info_general_funcs;
|
|||
static snd_render_data_t plugin_info_snd_render_data;
|
||||
static snd_render_funcs_t plugin_info_snd_render_funcs;
|
||||
|
||||
static snd_output_funcs_t *snd_output_funcs;
|
||||
|
||||
|
||||
// User-setable variables =====================================================
|
||||
|
||||
|
@ -142,7 +144,7 @@ SND_Startup (void)
|
|||
return;
|
||||
|
||||
if (!fakedma) {
|
||||
rc = plugin_info_snd_render_data.output->functions->snd_output->pS_O_Init ();
|
||||
rc = snd_output_funcs->pS_O_Init ();
|
||||
|
||||
if (!rc) {
|
||||
Sys_Printf ("S_Startup: S_O_Init failed.\n");
|
||||
|
@ -545,7 +547,7 @@ SND_GetSoundtime (void)
|
|||
|
||||
// it is possible to miscount buffers if it has wrapped twice between
|
||||
// calls to SND_Update. Oh well.
|
||||
samplepos = plugin_info_snd_render_data.output->functions->snd_output->pS_O_GetDMAPos ();
|
||||
samplepos = snd_output_funcs->pS_O_GetDMAPos ();
|
||||
|
||||
if (samplepos < oldsamplepos) {
|
||||
buffers++; // buffer wrapped
|
||||
|
@ -593,7 +595,7 @@ SND_Update_ (void)
|
|||
#endif
|
||||
|
||||
SND_PaintChannels (endtime);
|
||||
plugin_info_snd_render_data.output->functions->snd_output->pS_O_Submit ();
|
||||
snd_output_funcs->pS_O_Submit ();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -817,7 +819,7 @@ void
|
|||
SND_BlockSound (void)
|
||||
{
|
||||
if (++snd_blocked == 1) {
|
||||
plugin_info_snd_render_data.output->functions->snd_output->pS_O_BlockSound ();
|
||||
snd_output_funcs->pS_O_BlockSound ();
|
||||
SND_ClearBuffer ();
|
||||
}
|
||||
}
|
||||
|
@ -829,7 +831,7 @@ SND_UnblockSound (void)
|
|||
return;
|
||||
if (!--snd_blocked) {
|
||||
SND_ClearBuffer ();
|
||||
plugin_info_snd_render_data.output->functions->snd_output->pS_O_UnblockSound ();
|
||||
snd_output_funcs->pS_O_UnblockSound ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -870,6 +872,7 @@ SND_Init_Cvars (void)
|
|||
void
|
||||
SND_Init (void)
|
||||
{
|
||||
snd_output_funcs = plugin_info_snd_render_data.output->functions->snd_output;
|
||||
Sys_Printf ("\nSound Initialization\n");
|
||||
|
||||
Cmd_AddCommand ("play", SND_Play,
|
||||
|
@ -951,7 +954,7 @@ SND_Shutdown (void)
|
|||
sound_started = 0;
|
||||
|
||||
if (!fakedma) {
|
||||
plugin_info_snd_render_data.output->functions->snd_output->pS_O_Shutdown ();
|
||||
snd_output_funcs->pS_O_Shutdown ();
|
||||
}
|
||||
|
||||
shm = 0;
|
||||
|
|
|
@ -54,10 +54,11 @@ cvar_t *bgmvolume;
|
|||
cvar_t *volume;
|
||||
cvar_t *snd_interp;
|
||||
|
||||
cvar_t *snd_output;
|
||||
cvar_t *snd_render;
|
||||
plugin_t *snd_render_module = NULL;
|
||||
plugin_t *snd_output_module = NULL;
|
||||
static cvar_t *snd_output;
|
||||
static cvar_t *snd_render;
|
||||
static plugin_t *snd_render_module = NULL;
|
||||
static plugin_t *snd_output_module = NULL;
|
||||
static snd_render_funcs_t *snd_render_funcs = NULL;
|
||||
|
||||
SND_OUTPUT_PROTOS
|
||||
plugin_list_t snd_output_list[] = {
|
||||
|
@ -105,6 +106,8 @@ S_Init (struct model_s **worldmodel, int *viewentity, double *host_frametime)
|
|||
|
||||
snd_output_module->functions->general->p_Init ();
|
||||
snd_render_module->functions->general->p_Init ();
|
||||
|
||||
snd_render_funcs = snd_render_module->functions->snd_render;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,15 +137,15 @@ S_Init_Cvars (void)
|
|||
void
|
||||
S_AmbientOff (void)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_AmbientOff ();
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_AmbientOff ();
|
||||
}
|
||||
|
||||
void
|
||||
S_AmbientOn (void)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_AmbientOn ();
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_AmbientOn ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -151,6 +154,7 @@ S_Shutdown (void)
|
|||
if (snd_render_module) {
|
||||
PI_UnloadPlugin (snd_render_module);
|
||||
snd_render_module = NULL;
|
||||
snd_render_funcs = NULL;
|
||||
}
|
||||
if (snd_output_module) {
|
||||
PI_UnloadPlugin (snd_output_module);
|
||||
|
@ -161,39 +165,39 @@ S_Shutdown (void)
|
|||
void
|
||||
S_TouchSound (const char *sample)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_TouchSound (sample);
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_TouchSound (sample);
|
||||
}
|
||||
|
||||
void
|
||||
S_StaticSound (sfx_t *sfx, const vec3_t origin, float vol, float attenuation)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_StaticSound (sfx, origin, vol, attenuation);
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_StaticSound (sfx, origin, vol, attenuation);
|
||||
}
|
||||
|
||||
void
|
||||
S_StartSound (int entnum, int entchannel, sfx_t *sfx, const vec3_t origin,
|
||||
float fvol, float attenuation)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_StartSound
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_StartSound
|
||||
(entnum, entchannel, sfx, origin, fvol, attenuation);
|
||||
}
|
||||
|
||||
void
|
||||
S_StopSound (int entnum, int entchannel)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_StopSound
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_StopSound
|
||||
(entnum, entchannel);
|
||||
}
|
||||
|
||||
sfx_t *
|
||||
S_PrecacheSound (const char *sample)
|
||||
{
|
||||
if (snd_render_module)
|
||||
return snd_render_module->functions->snd_render->pS_PrecacheSound
|
||||
if (snd_render_funcs)
|
||||
return snd_render_funcs->pS_PrecacheSound
|
||||
(sample);
|
||||
else
|
||||
return NULL;
|
||||
|
@ -202,64 +206,64 @@ S_PrecacheSound (const char *sample)
|
|||
void
|
||||
S_ClearPrecache (void)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_ClearPrecache ();
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_ClearPrecache ();
|
||||
}
|
||||
|
||||
void
|
||||
S_Update (const vec3_t origin, const vec3_t v_forward, const vec3_t v_right,
|
||||
const vec3_t v_up)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_Update (origin, v_forward,
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_Update (origin, v_forward,
|
||||
v_right, v_up);
|
||||
}
|
||||
|
||||
void
|
||||
S_StopAllSounds (qboolean clear)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_StopAllSounds (clear);
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_StopAllSounds (clear);
|
||||
}
|
||||
|
||||
void
|
||||
S_BeginPrecaching (void)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_BeginPrecaching ();
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_BeginPrecaching ();
|
||||
}
|
||||
|
||||
void
|
||||
S_EndPrecaching (void)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_EndPrecaching ();
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_EndPrecaching ();
|
||||
}
|
||||
|
||||
void
|
||||
S_ExtraUpdate (void)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_ExtraUpdate ();
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_ExtraUpdate ();
|
||||
}
|
||||
|
||||
void
|
||||
S_LocalSound (const char *s)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_LocalSound (s);
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_LocalSound (s);
|
||||
}
|
||||
|
||||
void
|
||||
S_BlockSound (void)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_BlockSound ();
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_BlockSound ();
|
||||
}
|
||||
|
||||
void
|
||||
S_UnblockSound (void)
|
||||
{
|
||||
if (snd_render_module)
|
||||
snd_render_module->functions->snd_render->pS_UnblockSound ();
|
||||
if (snd_render_funcs)
|
||||
snd_render_funcs->pS_UnblockSound ();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue