summaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2007-11-13 18:02:18 -0800
committerChris Robinson <[email protected]>2007-11-13 18:02:18 -0800
commitae5f4e9a742b07e004b330c04a72fac4457c9b58 (patch)
treed1d5c9fadd918d9346fb871033f60e8c91600a63 /OpenAL32/Include
Initial import
Diffstat (limited to 'OpenAL32/Include')
-rw-r--r--OpenAL32/Include/alBuffer.h32
-rw-r--r--OpenAL32/Include/alError.h16
-rw-r--r--OpenAL32/Include/alExtension.h33
-rw-r--r--OpenAL32/Include/alListener.h23
-rw-r--r--OpenAL32/Include/alMain.h170
-rw-r--r--OpenAL32/Include/alSource.h71
-rw-r--r--OpenAL32/Include/alState.h14
-rw-r--r--OpenAL32/Include/alThunk.h42
-rw-r--r--OpenAL32/Include/alu.h26
9 files changed, 427 insertions, 0 deletions
diff --git a/OpenAL32/Include/alBuffer.h b/OpenAL32/Include/alBuffer.h
new file mode 100644
index 00000000..06ffdea0
--- /dev/null
+++ b/OpenAL32/Include/alBuffer.h
@@ -0,0 +1,32 @@
+#ifndef _AL_BUFFER_H_
+#define _AL_BUFFER_H_
+
+#include "AL/al.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define UNUSED 0
+#define PENDING 1
+#define PROCESSED 2
+
+typedef struct ALbuffer_struct
+{
+ ALenum format;
+ ALenum eOriginalFormat;
+ ALshort *data;
+ ALsizei size;
+ ALsizei frequency;
+ ALenum state;
+ ALuint refcount; // Number of sources using this buffer (deletion can only occur when this is 0)
+ struct ALbuffer_struct *next;
+} ALbuffer;
+
+ALvoid ReleaseALBuffers(ALvoid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/OpenAL32/Include/alError.h b/OpenAL32/Include/alError.h
new file mode 100644
index 00000000..5cee8db8
--- /dev/null
+++ b/OpenAL32/Include/alError.h
@@ -0,0 +1,16 @@
+#ifndef _AL_ERROR_H_
+#define _AL_ERROR_H_
+
+#include "AL/al.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ALvoid alSetError(ALenum errorCode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/OpenAL32/Include/alExtension.h b/OpenAL32/Include/alExtension.h
new file mode 100644
index 00000000..1f33f9af
--- /dev/null
+++ b/OpenAL32/Include/alExtension.h
@@ -0,0 +1,33 @@
+#ifndef _AL_EXTENSION_H_
+#define _AL_EXTENSION_H_
+
+#include "AL/al.h"
+#include "AL/alc.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct ALextension_struct
+{
+ ALchar *extName;
+ ALvoid *address;
+} ALextension;
+
+typedef struct ALfunction_struct
+{
+ ALchar *funcName;
+ ALvoid *address;
+} ALfunction;
+
+typedef struct ALenum_struct
+{
+ ALchar *enumName;
+ ALenum value;
+} ALenums;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/OpenAL32/Include/alListener.h b/OpenAL32/Include/alListener.h
new file mode 100644
index 00000000..2075e612
--- /dev/null
+++ b/OpenAL32/Include/alListener.h
@@ -0,0 +1,23 @@
+#ifndef _AL_LISTENER_H_
+#define _AL_LISTENER_H_
+
+#include "AL/al.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct ALlistener_struct
+{
+ ALfloat Position[3];
+ ALfloat Velocity[3];
+ ALfloat Forward[3];
+ ALfloat Up[3];
+ ALfloat Gain;
+} ALlistener;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
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
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
new file mode 100644
index 00000000..499ddcf4
--- /dev/null
+++ b/OpenAL32/Include/alSource.h
@@ -0,0 +1,71 @@
+#ifndef _AL_SOURCE_H_
+#define _AL_SOURCE_H_
+
+#define AL_NUM_SOURCE_PARAMS 128
+
+#include "AL/al.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct ALbufferlistitem
+{
+ ALuint buffer;
+ ALuint bufferstate;
+ ALuint flag;
+ struct ALbufferlistitem *next;
+} ALbufferlistitem;
+
+typedef struct ALsource_struct
+{
+ ALfloat flPitch;
+ ALfloat flGain;
+ ALfloat flOuterGain;
+ ALfloat flMinGain;
+ ALfloat flMaxGain;
+ ALfloat flInnerAngle;
+ ALfloat flOuterAngle;
+ ALfloat flRefDistance;
+ ALfloat flMaxDistance;
+ ALfloat flRollOffFactor;
+ ALfloat vPosition[3];
+ ALfloat vVelocity[3];
+ ALfloat vOrientation[3];
+ ALboolean bHeadRelative;
+ ALboolean bLooping;
+
+ ALuint ulBufferID;
+
+ ALboolean inuse;
+ ALboolean play;
+ ALenum state;
+ ALuint position;
+ ALuint position_fraction;
+ struct ALbufferlistitem *queue; // Linked list of buffers in queue
+ ALuint BuffersInQueue; // Number of buffers in queue
+ ALuint BuffersProcessed; // Number of buffers already processed (played)
+
+ ALuint TotalBufferDataSize; // Total amount of data contained in the buffers queued for this source
+ ALuint BuffersPlayed; // Number of buffers played on this loop
+ ALuint BufferPosition; // Read position in audio data of current buffer
+
+ // Index to itself
+ ALuint source;
+
+ ALint lBytesPlayed;
+
+ ALint lOffset;
+ ALint lOffsetType;
+
+ // Source Type (Static, Streaming, or Undetermined)
+ ALint lSourceType;
+
+ struct ALsource_struct *next;
+} ALsource;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/OpenAL32/Include/alState.h b/OpenAL32/Include/alState.h
new file mode 100644
index 00000000..332176b0
--- /dev/null
+++ b/OpenAL32/Include/alState.h
@@ -0,0 +1,14 @@
+#ifndef _AL_STATE_H_
+#define _AL_STATE_H_
+
+#include "AL/al.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/OpenAL32/Include/alThunk.h b/OpenAL32/Include/alThunk.h
new file mode 100644
index 00000000..2ed32871
--- /dev/null
+++ b/OpenAL32/Include/alThunk.h
@@ -0,0 +1,42 @@
+#ifndef _AL_THUNK_H_
+#define _AL_THUNK_H_
+
+#include "config.h"
+
+#include "AL/al.h"
+#include "AL/alc.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if (SIZEOF_VOIDP > SIZEOF_UINT)
+
+void alThunkInit(void);
+void alThunkExit(void);
+ALuint alThunkAddEntry(ALvoid * ptr);
+void alThunkRemoveEntry(ALuint index);
+ALvoid *alThunkLookupEntry(ALuint index);
+
+#define ALTHUNK_INIT() alThunkInit()
+#define ALTHUNK_EXIT() alThunkExit()
+#define ALTHUNK_ADDENTRY(p) alThunkAddEntry(p)
+#define ALTHUNK_REMOVEENTRY(i) alThunkRemoveEntry(i)
+#define ALTHUNK_LOOKUPENTRY(i) alThunkLookupEntry(i)
+
+#else
+
+#define ALTHUNK_INIT()
+#define ALTHUNK_EXIT()
+#define ALTHUNK_ADDENTRY(p) ((ALuint)p)
+#define ALTHUNK_REMOVEENTRY(i)
+#define ALTHUNK_LOOKUPENTRY(i) ((ALvoid*)(i))
+
+#endif // (SIZEOF_VOIDP > SIZEOF_INT)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_AL_THUNK_H_
+
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
new file mode 100644
index 00000000..e4fe0dc3
--- /dev/null
+++ b/OpenAL32/Include/alu.h
@@ -0,0 +1,26 @@
+#ifndef _ALU_H_
+#define _ALU_H_
+
+#define BUFFERSIZE 48000
+#define FRACTIONBITS 14
+#define FRACTIONMASK ((1L<<FRACTIONBITS)-1)
+#define MAX_PITCH 4
+#define OUTPUTCHANNELS 4
+
+#include "AL/al.h"
+#include "AL/alc.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+__inline ALuint aluBytesFromFormat(ALenum format);
+__inline ALuint aluChannelsFromFormat(ALenum format);
+ALvoid aluMixData(ALCcontext *context,ALvoid *buffer,ALsizei size,ALenum format);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+