mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 03:12:00 -04:00
use ALFUNC() in i_pcsound.c, avoid code duplication
This commit is contained in:
parent
5426138de7
commit
db2516e158
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user