diff options
author | Chris Robinson <[email protected]> | 2007-11-13 18:02:18 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2007-11-13 18:02:18 -0800 |
commit | ae5f4e9a742b07e004b330c04a72fac4457c9b58 (patch) | |
tree | d1d5c9fadd918d9346fb871033f60e8c91600a63 /OpenAL32/Include/alMain.h |
Initial import
Diffstat (limited to 'OpenAL32/Include/alMain.h')
-rw-r--r-- | OpenAL32/Include/alMain.h | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h new file mode 100644 index 00000000..3d34cf38 --- /dev/null +++ b/OpenAL32/Include/alMain.h @@ -0,0 +1,170 @@ +#ifndef AL_MAIN_H +#define AL_MAIN_H + +#define AL_MAX_CHANNELS 4 +#define AL_MAX_SOURCES 32 + +#include <string.h> + +#include "alu.h" + +#ifdef _WIN32 +#include <windows.h> +//#define strcasecmp _stricmp + +#else + +#include <assert.h> +#include <pthread.h> + +#define IsBadWritePtr(a,b) (0) + +typedef pthread_mutex_t CRITICAL_SECTION; +static inline void EnterCriticalSection(CRITICAL_SECTION *cs) +{ + assert(pthread_mutex_lock(cs) == 0); +} +static inline void LeaveCriticalSection(CRITICAL_SECTION *cs) +{ + assert(pthread_mutex_unlock(cs) == 0); +} +static inline void InitializeCriticalSection(CRITICAL_SECTION *cs) +{ + pthread_mutexattr_t attrib; + + assert(pthread_mutexattr_init(&attrib) == 0); + + assert(pthread_mutexattr_settype(&attrib, PTHREAD_MUTEX_RECURSIVE) == 0); + assert(pthread_mutex_init(cs, &attrib) == 0); + + pthread_mutexattr_destroy(&attrib); +} + +static inline void DeleteCriticalSection(CRITICAL_SECTION *cs) +{ + assert(pthread_mutex_destroy(cs) == 0); +} + +#define min(x,y) (((x)<(y))?(x):(y)) +#define max(x,y) (((x)>(y))?(x):(y)) +#endif + +#include "alBuffer.h" +#include "alError.h" +#include "alExtension.h" +#include "alListener.h" +#include "alSource.h" +#include "alState.h" +#include "alThunk.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define AL_FORMAT_MONO_IMA4 0x1300 +#define AL_FORMAT_STEREO_IMA4 0x1301 +// These are from AL_EXT_MCFORMATS, which we don't support yet but the mixer +// can use 4-channel formats +#define AL_FORMAT_QUAD8 0x1204 +#define AL_FORMAT_QUAD16 0x1205 + +#define SWMIXER_OUTPUT_RATE 44100 +//#define OUTPUT_BUFFER_SIZE (32768*SWMIXER_OUTPUT_RATE/22050) + +#define SPEEDOFSOUNDMETRESPERSEC (343.3f) + +typedef struct { + ALCboolean (*OpenPlayback)(ALCdevice*, const ALCchar*); + void (*ClosePlayback)(ALCdevice*); + + ALCboolean (*OpenCapture)(ALCdevice*, const ALCchar*, ALCuint, ALCenum, ALCsizei); + void (*CloseCapture)(ALCdevice*); + void (*StartCapture)(ALCdevice*); + void (*StopCapture)(ALCdevice*); + void (*CaptureSamples)(ALCdevice*, void*, ALCuint); + ALCuint (*AvailableSamples)(ALCdevice*); +} BackendFuncs; + +struct ALCdevice_struct +{ + ALboolean InUse; + ALboolean IsCaptureDevice; + + ALuint Frequency; + ALuint UpdateFreq; + ALuint FrameSize; + ALuint Channels; + ALenum Format; + + ALCchar szDeviceName[256]; + + // Maximum number of sources that can be created + ALuint MaxNoOfSources; + + // Context created on this device + ALCcontext *Context; + + BackendFuncs *Funcs; + void *ExtraData; // For the backend's use +}; + +#define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b))) +#define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a))) +#define ALCdevice_OpenCapture(a,b,c,d,e) ((a)->Funcs->OpenCapture((a), (b), (c), (d), (e))) +#define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a))) +#define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a))) +#define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a))) +#define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c))) +#define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a))) + +struct ALCcontext_struct +{ + ALlistener Listener; + + ALsource *Source; + ALuint SourceCount; + + ALenum LastError; + ALboolean InUse; + + ALuint Frequency; + + ALenum DistanceModel; + + ALfloat DopplerFactor; + ALfloat DopplerVelocity; + ALfloat flSpeedOfSound; + + ALint lNumMonoSources; + ALint lNumStereoSources; + + ALCdevice *Device; + ALCchar ExtensionList[1024]; + + ALCcontext *next; +}; + +ALCchar *AppendDeviceList(char *name); +ALCchar *AppendAllDeviceList(char *name); +ALCchar *AppendCaptureDeviceList(char *name); + +ALCvoid SetALCError(ALenum errorCode); + +ALCvoid SuspendContext(ALCcontext *context); +ALCvoid ProcessContext(ALCcontext *context); + +ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr); +ALuint StopThread(ALvoid *thread); + +void ReadALConfig(void); +void FreeALConfig(void); +const char *GetConfigValue(const char *blockName, const char *keyName, const char *def); +int GetConfigValueInt(const char *blockName, const char *keyName, int def); +float GetConfigValueFloat(const char *blockName, const char *keyName, float def); + +#ifdef __cplusplus +} +#endif + +#endif |