/* * WARNING: this is an autogenerated file and will be overwritten by * the extension interface script. */ #include "s3eExt.h" #include "IwDebug.h" #include "s3eDevice.h" #include "openalext.h" #ifndef S3E_EXT_SKIP_LOADER_CALL_LOCK // For MIPs (and WP8) platform we do not have asm code for stack switching // implemented. So we make LoaderCallStart call manually to set GlobalLock #if defined __mips || defined S3E_ANDROID_X86 || (defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)) #define LOADER_CALL_LOCK #endif #endif /** * Definitions for functions types passed to/from s3eExt interface */ typedef unsigned int(*_alGetError_t)(); typedef void(*_alSourceQueueBuffers_t)(_ALuint sid, _ALsizei numEntries, const _ALuint* bids); typedef void(*_alSourceUnqueueBuffers_t)(_ALuint sid, _ALsizei numEntries, _ALuint* bids); typedef void(*_alGetSourcei_t)(_ALuint sid, _ALenum param, _ALint* value); typedef void(*_alGetSourcef_t)(_ALuint sid, _ALenum param, _ALfloat* value); typedef void(*_alSourcef_t)(_ALuint sid, _ALenum param, _ALfloat value); typedef void(*_alSourcei_t)(_ALuint sid, _ALenum param, _ALint value); typedef void(*_alSourcePlay_t)(_ALuint sid); typedef void(*_alSourceStop_t)(_ALuint sid); typedef void(*_alSourcePause_t)(_ALuint sid); typedef void(*_alGenSources_t)(_ALsizei n, _ALuint* sources); typedef void(*_alDeleteSources_t)(_ALsizei n, const _ALuint* sources); typedef void(*_alGenBuffers_t)(_ALsizei n, _ALuint* buffers); typedef void(*_alDeleteBuffers_t)(_ALsizei n, const _ALuint* buffers); typedef void(*_alBufferData_t)(_ALuint bid, _ALenum format, const _ALvoid* data, _ALsizei size, _ALsizei freq); typedef _ALCdevice*(*_alcOpenDevice_t)(const char* devicename); typedef void(*_alcCloseDevice_t)(_ALCdevice* device); typedef _ALCcontext *(*_alcCreateContext_t)(_ALCdevice* device, const _ALCint* attrlist); typedef _ALCboolean(*_alcMakeContextCurrent_t)(_ALCcontext* context); typedef void(*_alcProcessContext_t)(_ALCcontext* context); typedef void(*_alcSuspendContext_t)(_ALCcontext* context); typedef void(*_alcDestroyContext_t)(_ALCcontext* context); typedef _ALCcontext *(*_alcGetCurrentContext_t)(); /** * struct that gets filled in by openalextRegister */ typedef struct openalextFuncs { _alGetError_t m__alGetError; _alSourceQueueBuffers_t m__alSourceQueueBuffers; _alSourceUnqueueBuffers_t m__alSourceUnqueueBuffers; _alGetSourcei_t m__alGetSourcei; _alGetSourcef_t m__alGetSourcef; _alSourcef_t m__alSourcef; _alSourcei_t m__alSourcei; _alSourcePlay_t m__alSourcePlay; _alSourceStop_t m__alSourceStop; _alSourcePause_t m__alSourcePause; _alGenSources_t m__alGenSources; _alDeleteSources_t m__alDeleteSources; _alGenBuffers_t m__alGenBuffers; _alDeleteBuffers_t m__alDeleteBuffers; _alBufferData_t m__alBufferData; _alcOpenDevice_t m__alcOpenDevice; _alcCloseDevice_t m__alcCloseDevice; _alcCreateContext_t m__alcCreateContext; _alcMakeContextCurrent_t m__alcMakeContextCurrent; _alcProcessContext_t m__alcProcessContext; _alcSuspendContext_t m__alcSuspendContext; _alcDestroyContext_t m__alcDestroyContext; _alcGetCurrentContext_t m__alcGetCurrentContext; } openalextFuncs; static openalextFuncs g_Ext; static bool g_GotExt = false; static bool g_TriedExt = false; static bool g_TriedNoMsgExt = false; static bool _extLoad() { if (!g_GotExt && !g_TriedExt) { s3eResult res = s3eExtGetHash(0x37485935, &g_Ext, sizeof(g_Ext)); if (res == S3E_RESULT_SUCCESS) g_GotExt = true; else s3eDebugAssertShow(S3E_MESSAGE_CONTINUE_STOP_IGNORE, "error loading extension: openalext"); g_TriedExt = true; g_TriedNoMsgExt = true; } return g_GotExt; } static bool _extLoadNoMsg() { if (!g_GotExt && !g_TriedNoMsgExt) { s3eResult res = s3eExtGetHash(0x37485935, &g_Ext, sizeof(g_Ext)); if (res == S3E_RESULT_SUCCESS) g_GotExt = true; g_TriedNoMsgExt = true; if (g_TriedExt) g_TriedExt = true; } return g_GotExt; } s3eBool openalextAvailable() { _extLoadNoMsg(); return g_GotExt ? S3E_TRUE : S3E_FALSE; } unsigned int _alGetError() { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[0] func: _alGetError")); if (!_extLoad()) return 0; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif unsigned int ret = g_Ext.m__alGetError(); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return ret; } void _alSourceQueueBuffers(_ALuint sid, _ALsizei numEntries, const _ALuint* bids) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[1] func: _alSourceQueueBuffers")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alSourceQueueBuffers(sid, numEntries, bids); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alSourceUnqueueBuffers(_ALuint sid, _ALsizei numEntries, _ALuint* bids) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[2] func: _alSourceUnqueueBuffers")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alSourceUnqueueBuffers(sid, numEntries, bids); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alGetSourcei(_ALuint sid, _ALenum param, _ALint* value) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[3] func: _alGetSourcei")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alGetSourcei(sid, param, value); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alGetSourcef(_ALuint sid, _ALenum param, _ALfloat* value) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[4] func: _alGetSourcef")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alGetSourcef(sid, param, value); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alSourcef(_ALuint sid, _ALenum param, _ALfloat value) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[5] func: _alSourcef")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alSourcef(sid, param, value); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alSourcei(_ALuint sid, _ALenum param, _ALint value) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[6] func: _alSourcei")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alSourcei(sid, param, value); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alSourcePlay(_ALuint sid) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[7] func: _alSourcePlay")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alSourcePlay(sid); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alSourceStop(_ALuint sid) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[8] func: _alSourceStop")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alSourceStop(sid); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alSourcePause(_ALuint sid) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[9] func: _alSourcePause")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alSourcePause(sid); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alGenSources(_ALsizei n, _ALuint* sources) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[10] func: _alGenSources")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alGenSources(n, sources); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alDeleteSources(_ALsizei n, const _ALuint* sources) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[11] func: _alDeleteSources")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alDeleteSources(n, sources); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alGenBuffers(_ALsizei n, _ALuint* buffers) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[12] func: _alGenBuffers")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alGenBuffers(n, buffers); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alDeleteBuffers(_ALsizei n, const _ALuint* buffers) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[13] func: _alDeleteBuffers")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alDeleteBuffers(n, buffers); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alBufferData(_ALuint bid, _ALenum format, const _ALvoid* data, _ALsizei size, _ALsizei freq) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[14] func: _alBufferData")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alBufferData(bid, format, data, size, freq); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } _ALCdevice* _alcOpenDevice(const char* devicename) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[15] func: _alcOpenDevice")); if (!_extLoad()) return 0; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif _ALCdevice* ret = g_Ext.m__alcOpenDevice(devicename); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return ret; } void _alcCloseDevice(_ALCdevice* device) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[16] func: _alcCloseDevice")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alcCloseDevice(device); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } _ALCcontext * _alcCreateContext(_ALCdevice* device, const _ALCint* attrlist) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[17] func: _alcCreateContext")); if (!_extLoad()) return 0; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif _ALCcontext * ret = g_Ext.m__alcCreateContext(device, attrlist); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return ret; } _ALCboolean _alcMakeContextCurrent(_ALCcontext* context) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[18] func: _alcMakeContextCurrent")); if (!_extLoad()) return 0; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif _ALCboolean ret = g_Ext.m__alcMakeContextCurrent(context); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return ret; } void _alcProcessContext(_ALCcontext* context) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[19] func: _alcProcessContext")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alcProcessContext(context); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alcSuspendContext(_ALCcontext* context) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[20] func: _alcSuspendContext")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alcSuspendContext(context); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } void _alcDestroyContext(_ALCcontext* context) { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[21] func: _alcDestroyContext")); if (!_extLoad()) return; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif g_Ext.m__alcDestroyContext(context); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return; } _ALCcontext * _alcGetCurrentContext() { IwTrace(OPENALEXT_VERBOSE, ("calling openalext[22] func: _alcGetCurrentContext")); if (!_extLoad()) return 0; #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallStart(S3E_TRUE, NULL); #endif _ALCcontext * ret = g_Ext.m__alcGetCurrentContext(); #ifdef LOADER_CALL_LOCK s3eDeviceLoaderCallDone(S3E_TRUE, NULL); #endif return ret; }