Skip to content

Commit

Permalink
use ALFUNC() in i_pcsound.c, avoid code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiangreffrath committed Sep 23, 2024
1 parent 5426138 commit db2516e
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/i_pcsound.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "doomstat.h"
#include "doomtype.h"
#include "i_oalcommon.h"
#include "i_oalsound.h"
#include "i_printf.h"
#include "i_sound.h"
Expand All @@ -31,16 +32,6 @@
#include "w_wad.h"
#include "z_zone.h"

// C doesn't allow casting between function and non-function pointer types, so
// with C99 we need to use a union to reinterpret the pointer type. Pre-C99
// still needs to use a normal cast and live with the warning (C++ is fine with
// a regular reinterpret_cast).
#if __STDC_VERSION__ >= 199901L
# define FUNCTION_CAST(T, ptr) (union{void *p; T f;}){ptr}.f
#else
# define FUNCTION_CAST(T, ptr) (T)(ptr)
#endif

static LPALBUFFERCALLBACKSOFT alBufferCallbackSOFT;
static ALuint callback_buffer;
static ALuint callback_source;
Expand Down Expand Up @@ -288,8 +279,7 @@ static void RegisterCallback(void)
"RegisterCallback: AL_SOFT_callback_buffer not found.");
return;
}
alBufferCallbackSOFT = FUNCTION_CAST(
LPALBUFFERCALLBACKSOFT, alGetProcAddress("alBufferCallbackSOFT"));
ALFUNC(LPALBUFFERCALLBACKSOFT, alBufferCallbackSOFT);

alGenBuffers(1, &callback_buffer);
alGenSources(1, &callback_source);
Expand Down

0 comments on commit db2516e

Please sign in to comment.