mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
combine some of OpenAL dynamic loading code
This commit is contained in:
parent
ab007f8147
commit
e22cb847fe
59
src/Audio.c
59
src/Audio.c
@ -1,6 +1,5 @@
|
|||||||
#include "Audio.h"
|
#include "Audio.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Platform.h"
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "Block.h"
|
#include "Block.h"
|
||||||
#include "ExtMath.h"
|
#include "ExtMath.h"
|
||||||
@ -80,25 +79,26 @@ typedef unsigned int ALuint;
|
|||||||
typedef int ALsizei;
|
typedef int ALsizei;
|
||||||
typedef int ALenum;
|
typedef int ALenum;
|
||||||
|
|
||||||
typedef ALenum (APIENTRY *FP_alGetError)(void);
|
/* Apologies for the ugly dynamic symbol definitions here */
|
||||||
typedef void (APIENTRY *FP_alGenSources)(ALsizei n, ALuint* sources);
|
typedef ALenum (APIENTRY *FP_alGetError)(void); static FP_alGetError _alGetError;
|
||||||
typedef void (APIENTRY *FP_alDeleteSources)(ALsizei n, const ALuint* sources);
|
typedef void (APIENTRY *FP_alGenSources)(ALsizei n, ALuint* sources); static FP_alGenSources _alGenSources;
|
||||||
typedef void (APIENTRY *FP_alGetSourcei)(ALuint source, ALenum param, ALint* value);
|
typedef void (APIENTRY *FP_alDeleteSources)(ALsizei n, const ALuint* sources); static FP_alDeleteSources _alDeleteSources;
|
||||||
typedef void (APIENTRY *FP_alSourcePlay)(ALuint source);
|
typedef void (APIENTRY *FP_alGetSourcei)(ALuint source, ALenum param, ALint* value); static FP_alGetSourcei _alGetSourcei;
|
||||||
typedef void (APIENTRY *FP_alSourceStop)(ALuint source);
|
typedef void (APIENTRY *FP_alSourcePlay)(ALuint source); static FP_alSourcePlay _alSourcePlay;
|
||||||
typedef void (APIENTRY *FP_alSourceQueueBuffers)(ALuint source, ALsizei nb, const ALuint* buffers);
|
typedef void (APIENTRY *FP_alSourceStop)(ALuint source); static FP_alSourceStop _alSourceStop;
|
||||||
typedef void (APIENTRY *FP_alSourceUnqueueBuffers)(ALuint source, ALsizei nb, ALuint* buffers);
|
typedef void (APIENTRY *FP_alSourceQueueBuffers)(ALuint source, ALsizei nb, const ALuint* buffers); static FP_alSourceQueueBuffers _alSourceQueueBuffers;
|
||||||
typedef void (APIENTRY *FP_alGenBuffers)(ALsizei n, ALuint* buffers);
|
typedef void (APIENTRY *FP_alSourceUnqueueBuffers)(ALuint source, ALsizei nb, ALuint* buffers); static FP_alSourceUnqueueBuffers _alSourceUnqueueBuffers;
|
||||||
typedef void (APIENTRY *FP_alDeleteBuffers)(ALsizei n, const ALuint* buffers);
|
typedef void (APIENTRY *FP_alGenBuffers)(ALsizei n, ALuint* buffers); static FP_alGenBuffers _alGenBuffers;
|
||||||
typedef void (APIENTRY *FP_alBufferData)(ALuint buffer, ALenum format, const void* data, ALsizei size, ALsizei freq);
|
typedef void (APIENTRY *FP_alDeleteBuffers)(ALsizei n, const ALuint* buffers); static FP_alDeleteBuffers _alDeleteBuffers;
|
||||||
typedef void (APIENTRY *FP_alDistanceModel)(ALenum distanceModel);
|
typedef void (APIENTRY *FP_alBufferData)(ALuint buffer, ALenum format, const void* data, ALsizei size, ALsizei freq); static FP_alBufferData _alBufferData;
|
||||||
typedef void* (APIENTRY *FP_alcCreateContext)(void* device, const ALint* attrlist);
|
typedef void (APIENTRY *FP_alDistanceModel)(ALenum distanceModel); static FP_alDistanceModel _alDistanceModel;
|
||||||
typedef ALboolean (APIENTRY *FP_alcMakeContextCurrent)(void* context);
|
typedef void* (APIENTRY *FP_alcCreateContext)(void* device, const ALint* attrlist); static FP_alcCreateContext _alcCreateContext;
|
||||||
typedef void (APIENTRY *FP_alcDestroyContext)(void* context);
|
typedef ALboolean (APIENTRY *FP_alcMakeContextCurrent)(void* context); static FP_alcMakeContextCurrent _alcMakeContextCurrent;
|
||||||
typedef void* (APIENTRY *FP_alcOpenDevice)(const char* devicename);
|
typedef void (APIENTRY *FP_alcDestroyContext)(void* context); static FP_alcDestroyContext _alcDestroyContext;
|
||||||
typedef ALboolean (APIENTRY *FP_alcCloseDevice)(void* device);
|
typedef void* (APIENTRY *FP_alcOpenDevice)(const char* devicename); static FP_alcOpenDevice _alcOpenDevice;
|
||||||
typedef ALenum (APIENTRY *FP_alcGetError)(void* device);
|
typedef ALboolean (APIENTRY *FP_alcCloseDevice)(void* device); static FP_alcCloseDevice _alcCloseDevice;
|
||||||
/* === End of OpenAL headers === */
|
typedef ALenum (APIENTRY *FP_alcGetError)(void* device); static FP_alcGetError _alcGetError;
|
||||||
|
/* End of OpenAL headers */
|
||||||
|
|
||||||
struct AudioContext {
|
struct AudioContext {
|
||||||
ALuint source;
|
ALuint source;
|
||||||
@ -124,25 +124,6 @@ static const String alLib = String_FromConst("libopenal.so.3.0");
|
|||||||
static const String alLib = String_FromConst("libopenal.so.1");
|
static const String alLib = String_FromConst("libopenal.so.1");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static FP_alGetError _alGetError;
|
|
||||||
static FP_alGenSources _alGenSources;
|
|
||||||
static FP_alDeleteSources _alDeleteSources;
|
|
||||||
static FP_alGetSourcei _alGetSourcei;
|
|
||||||
static FP_alSourcePlay _alSourcePlay;
|
|
||||||
static FP_alSourceStop _alSourceStop;
|
|
||||||
static FP_alSourceQueueBuffers _alSourceQueueBuffers;
|
|
||||||
static FP_alSourceUnqueueBuffers _alSourceUnqueueBuffers;
|
|
||||||
static FP_alGenBuffers _alGenBuffers;
|
|
||||||
static FP_alDeleteBuffers _alDeleteBuffers;
|
|
||||||
static FP_alBufferData _alBufferData;
|
|
||||||
static FP_alDistanceModel _alDistanceModel;
|
|
||||||
static FP_alcCreateContext _alcCreateContext;
|
|
||||||
static FP_alcMakeContextCurrent _alcMakeContextCurrent;
|
|
||||||
static FP_alcDestroyContext _alcDestroyContext;
|
|
||||||
static FP_alcOpenDevice _alcOpenDevice;
|
|
||||||
static FP_alcCloseDevice _alcCloseDevice;
|
|
||||||
static FP_alcGetError _alcGetError;
|
|
||||||
|
|
||||||
#define QUOTE(x) #x
|
#define QUOTE(x) #x
|
||||||
#define LoadALFunc(sym) (_ ## sym = (FP_ ## sym)DynamicLib_Get2(lib, QUOTE(sym)))
|
#define LoadALFunc(sym) (_ ## sym = (FP_ ## sym)DynamicLib_Get2(lib, QUOTE(sym)))
|
||||||
static cc_bool LoadALFuncs(void) {
|
static cc_bool LoadALFuncs(void) {
|
||||||
|
@ -1853,6 +1853,7 @@ static void InitRawMouse(void) {
|
|||||||
/* (i.e. if you press mouse button, no more raw mouse movement events) */
|
/* (i.e. if you press mouse button, no more raw mouse movement events) */
|
||||||
/* http://wine.1045685.n8.nabble.com/PATCH-0-9-Implement-DInput8-mouse-using-RawInput-and-XInput2-RawEvents-only-td6016923.html */
|
/* http://wine.1045685.n8.nabble.com/PATCH-0-9-Implement-DInput8-mouse-using-RawInput-and-XInput2-RawEvents-only-td6016923.html */
|
||||||
/* Thankfully XInput >= 2.1 corrects this behaviour */
|
/* Thankfully XInput >= 2.1 corrects this behaviour */
|
||||||
|
/* http://who-t.blogspot.com/2011/09/whats-new-in-xi-21-raw-events.html */
|
||||||
major = 2; minor = 2;
|
major = 2; minor = 2;
|
||||||
if (XIQueryVersion(win_display, &major, &minor) != Success) {
|
if (XIQueryVersion(win_display, &major, &minor) != Success) {
|
||||||
Platform_Log2("Only XInput %i.%i supported", &major, &minor);
|
Platform_Log2("Only XInput %i.%i supported", &major, &minor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user