use ALFUNC() in i_pcsound.c, avoid code duplication

This commit is contained in:
Fabian Greffrath 2024-09-23 11:52:28 +02:00
parent 5426138de7
commit db2516e158

View File

@ -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"
@ -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;
@ -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);