[audio] Clean up snd_render.h namespace polution

There's no need for the function typedefs and the warts on the member
names were... warty.

Also, group the members logically.
This commit is contained in:
Bill Currie 2021-06-22 15:35:37 +09:00
parent 421421e038
commit db322ce88b
4 changed files with 69 additions and 92 deletions

View file

@ -30,54 +30,37 @@
#include <QF/plugin.h>
#include <QF/qtypes.h>
/*
All sound plugins must export these functions
*/
struct sfx_s;
typedef void (*P_S_Init) (void);
typedef void (*P_S_Shutdown) (void);
typedef void (*P_S_AmbientOff) (void);
typedef void (*P_S_AmbientOn) (void);
typedef void (*P_S_StartSound) (int entnum, int entchannel, struct sfx_s *sfx, const vec3_t origin, float fvol, float attenuation);
typedef void (*P_S_StaticSound) (struct sfx_s *sfx, const vec3_t origin, float vol, float attenuation);
typedef void (*P_S_StopSound) (int entnum, int entchannel);
typedef struct sfx_s * (*P_S_PrecacheSound) (const char *sample);
typedef void (*P_S_Update) (const vec3_t origin, const vec3_t v_forward, const vec3_t v_right, const vec3_t v_up, const byte *ambient_sound_level);
typedef void (*P_S_StopAllSounds) (void);
typedef void (*P_S_ExtraUpdate) (void);
typedef void (*P_S_LocalSound) (const char *s);
typedef void (*P_S_BlockSound) (void);
typedef void (*P_S_UnblockSound) (void);
typedef struct sfx_s *(*P_S_LoadSound) (const char *name);
typedef struct channel_s *(*P_S_AllocChannel) (void);
typedef void (*P_S_ChannelStop) (struct channel_s *chan);
typedef struct snd_render_funcs_s {
P_S_AmbientOff pS_AmbientOff;
P_S_AmbientOn pS_AmbientOn;
P_S_StaticSound pS_StaticSound;
P_S_StartSound pS_StartSound;
P_S_StopSound pS_StopSound;
P_S_PrecacheSound pS_PrecacheSound;
P_S_Update pS_Update;
P_S_StopAllSounds pS_StopAllSounds;
P_S_ExtraUpdate pS_ExtraUpdate;
P_S_LocalSound pS_LocalSound;
P_S_BlockSound pS_BlockSound;
P_S_UnblockSound pS_UnblockSound;
P_S_LoadSound pS_LoadSound;
P_S_AllocChannel pS_AllocChannel;
P_S_ChannelStop pS_ChannelStop;
void (*ambient_off) (void);
void (*ambient_on) (void);
void (*static_sound) (struct sfx_s *sfx, const vec3_t origin, float vol, float attenuation);
void (*start_sound) (int entnum, int entchannel, struct sfx_s *sfx, const vec3_t origin, float fvol, float attenuation);
void (*local_sound) (const char *s);
void (*stop_sound) (int entnum, int entchannel);
struct channel_s *(*alloc_channel) (void);
void (*channel_stop) (struct channel_s *chan);
struct sfx_s *(*precache_sound) (const char *sample);
struct sfx_s *(*load_sound) (const char *name);
void (*update) (const vec3_t origin, const vec3_t v_forward,
const vec3_t v_right, const vec3_t v_up,
const byte *ambient_sound_levels);
void (*stop_all_sounds) (void);
void (*extra_update) (void);
void (*block_sound) (void);
void (*unblock_sound) (void);
} snd_render_funcs_t;
typedef struct snd_render_data_s {
double *host_frametime;
int *viewentity;
double *host_frametime;
int *viewentity;
unsigned int *soundtime;
unsigned int *paintedtime;
unsigned *soundtime;
unsigned *paintedtime;
struct plugin_s *output;
} snd_render_data_t;

View file

@ -362,21 +362,21 @@ static general_funcs_t plugin_info_general_funcs = {
};
static snd_render_funcs_t plugin_info_render_funcs = {
SND_AmbientOff,
SND_AmbientOn,
SND_StaticSound,
SND_StartSound,
SND_StopSound,
SND_PrecacheSound,
s_update,
s_stop_all_sounds,
s_extra_update,
SND_LocalSound,
s_block_sound,
s_unblock_sound,
SND_LoadSound,
SND_AllocChannel,
SND_ChannelStop,
.ambient_off = SND_AmbientOff,
.ambient_on = SND_AmbientOn,
.static_sound = SND_StaticSound,
.start_sound = SND_StartSound,
.stop_sound = SND_StopSound,
.precache_sound = SND_PrecacheSound,
.update = s_update,
.stop_all_sounds = s_stop_all_sounds,
.extra_update = s_extra_update,
.local_sound = SND_LocalSound,
.block_sound = s_block_sound,
.unblock_sound = s_unblock_sound,
.load_sound = SND_LoadSound,
.alloc_channel = SND_AllocChannel,
.channel_stop = SND_ChannelStop,
};
static plugin_funcs_t plugin_info_funcs = {

View file

@ -123,11 +123,6 @@ s_update (const vec3_t origin, const vec3_t forward, const vec3_t right,
SND_SetListener (origin, forward, right, up, ambient_sound_level);
}
static void
s_extra_update (void)
{
}
static void
s_local_sound (const char *sound)
{
@ -378,21 +373,20 @@ static general_funcs_t plugin_info_general_funcs = {
};
static snd_render_funcs_t plugin_info_render_funcs = {
s_ambient_off,
s_ambient_on,
s_static_sound,
s_start_sound,
s_stop_sound,
s_precache_sound,
s_update,
s_stop_all_sounds,
s_extra_update,
s_local_sound,
s_block_sound,
s_unblock_sound,
s_load_sound,
s_alloc_channel,
s_channel_stop,
.ambient_off = s_ambient_off,
.ambient_on = s_ambient_on,
.static_sound = s_static_sound,
.start_sound = s_start_sound,
.stop_sound = s_stop_sound,
.precache_sound = s_precache_sound,
.update = s_update,
.stop_all_sounds = s_stop_all_sounds,
.local_sound = s_local_sound,
.block_sound = s_block_sound,
.unblock_sound = s_unblock_sound,
.load_sound = s_load_sound,
.alloc_channel = s_alloc_channel,
.channel_stop = s_channel_stop,
};
static general_data_t plugin_info_general_data;

View file

@ -125,21 +125,21 @@ VISIBLE void
S_AmbientOff (void)
{
if (snd_render_funcs)
snd_render_funcs->pS_AmbientOff ();
snd_render_funcs->ambient_off ();
}
VISIBLE void
S_AmbientOn (void)
{
if (snd_render_funcs)
snd_render_funcs->pS_AmbientOn ();
snd_render_funcs->ambient_on ();
}
VISIBLE void
S_StaticSound (sfx_t *sfx, const vec3_t origin, float vol, float attenuation)
{
if (snd_render_funcs)
snd_render_funcs->pS_StaticSound (sfx, origin, vol, attenuation);
snd_render_funcs->static_sound (sfx, origin, vol, attenuation);
}
VISIBLE void
@ -147,7 +147,7 @@ S_StartSound (int entnum, int entchannel, sfx_t *sfx, const vec3_t origin,
float fvol, float attenuation)
{
if (snd_render_funcs)
snd_render_funcs->pS_StartSound (entnum, entchannel, sfx, origin, fvol,
snd_render_funcs->start_sound (entnum, entchannel, sfx, origin, fvol,
attenuation);
}
@ -155,14 +155,14 @@ VISIBLE void
S_StopSound (int entnum, int entchannel)
{
if (snd_render_funcs)
snd_render_funcs->pS_StopSound (entnum, entchannel);
snd_render_funcs->stop_sound (entnum, entchannel);
}
VISIBLE sfx_t *
S_PrecacheSound (const char *sample)
{
if (snd_render_funcs)
return snd_render_funcs->pS_PrecacheSound (sample);
return snd_render_funcs->precache_sound (sample);
return NULL;
}
@ -171,7 +171,7 @@ S_Update (const vec3_t origin, const vec3_t v_forward, const vec3_t v_right,
const vec3_t v_up, const byte *ambient_sound_level)
{
if (snd_render_funcs)
snd_render_funcs->pS_Update (origin, v_forward, v_right, v_up,
snd_render_funcs->update (origin, v_forward, v_right, v_up,
ambient_sound_level);
}
@ -179,42 +179,42 @@ VISIBLE void
S_StopAllSounds (void)
{
if (snd_render_funcs)
snd_render_funcs->pS_StopAllSounds ();
snd_render_funcs->stop_all_sounds ();
}
VISIBLE void
S_ExtraUpdate (void)
{
// if (snd_render_funcs)
// snd_render_funcs->pS_ExtraUpdate ();
if (snd_render_funcs && snd_render_funcs->extra_update)
snd_render_funcs->extra_update ();
}
VISIBLE void
S_LocalSound (const char *s)
{
if (snd_render_funcs)
snd_render_funcs->pS_LocalSound (s);
snd_render_funcs->local_sound (s);
}
VISIBLE void
S_BlockSound (void)
{
if (snd_render_funcs)
snd_render_funcs->pS_BlockSound ();
snd_render_funcs->block_sound ();
}
VISIBLE void
S_UnblockSound (void)
{
if (snd_render_funcs)
snd_render_funcs->pS_UnblockSound ();
snd_render_funcs->unblock_sound ();
}
VISIBLE sfx_t *
S_LoadSound (const char *name)
{
if (snd_render_funcs)
return snd_render_funcs->pS_LoadSound (name);
return snd_render_funcs->load_sound (name);
return 0;
}
@ -222,7 +222,7 @@ VISIBLE struct channel_s *
S_AllocChannel (void)
{
if (snd_render_funcs)
return snd_render_funcs->pS_AllocChannel ();
return snd_render_funcs->alloc_channel ();
return 0;
}
@ -230,5 +230,5 @@ VISIBLE void
S_ChannelStop (struct channel_s *chan)
{
if (snd_render_funcs)
snd_render_funcs->pS_ChannelStop (chan);
snd_render_funcs->channel_stop (chan);
}