zenilib: zenilib/jni/external/zenilib/zeni_audio/Zeni/Sound_Renderer_AL.h Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Sound_Renderer_AL.h
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2 * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3 *
4 * zenilib is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * zenilib is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef ZENI_SOUND_RENDERER_AL_H
19 #define ZENI_SOUND_RENDERER_AL_H
20
21 #include <Zeni/Sound_Renderer.h>
22
23 #ifndef DISABLE_AL
24
25 #ifdef _MACOSX
26 #include <OpenAL/alc.h>
27 #else
28 #include <AL/alc.h>
29 #endif
30
31 #define OV_EXCLUDE_STATIC_CALLBACKS
32 #include <vorbis/vorbisfile.h>
33 #undef OV_EXCLUDE_STATIC_CALLBACKS
34
35 #ifdef _WINDOWS
36 #include <Windows.h>
37 #endif
38
39 namespace Zeni {
40
41 class ZENI_AUDIO_DLL Sound_Renderer_AL : public Sound_Renderer {
42 friend class Sound;
43
44 Sound_Renderer_AL();
45 ~Sound_Renderer_AL();
46
47 // Undefined
48 Sound_Renderer_AL(const Sound_Renderer_AL &);
49 Sound_Renderer_AL & operator=(const Sound_Renderer_AL &);
50
51 public:
52 typedef void (AL_APIENTRY *alBufferData_fcn)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
53 typedef ALCboolean (ALC_APIENTRY *alcCloseDevice_fcn)( ALCdevice *device );
54 typedef ALCcontext * (ALC_APIENTRY *alcCreateContext_fcn)( ALCdevice *device, const ALCint* attrlist );
55 typedef void (ALC_APIENTRY *alcDestroyContext_fcn)( ALCcontext *context );
56 typedef ALboolean (AL_APIENTRY *alIsExtensionPresent_fcn)( const ALchar* extname );
57 typedef ALCboolean (ALC_APIENTRY *alcMakeContextCurrent_fcn)( ALCcontext *context );
58 typedef ALCdevice * (ALC_APIENTRY *alcOpenDevice_fcn)( const ALCchar *devicename );
59 typedef void (AL_APIENTRY *alDeleteBuffers_fcn)( ALsizei n, const ALuint* buffers );
60 typedef void (AL_APIENTRY *alDeleteSources_fcn)( ALsizei n, const ALuint* sources );
61 typedef void (AL_APIENTRY *alGenBuffers_fcn)( ALsizei n, ALuint* buffers );
62 typedef ALenum (AL_APIENTRY *alGetError_fcn)( void );
63 typedef void (AL_APIENTRY *alGetListenerf_fcn)( ALenum param, ALfloat* value );
64 typedef void (AL_APIENTRY *alGetListenerfv_fcn)( ALenum param, ALfloat* values );
65 typedef void (AL_APIENTRY *alGetSourcef_fcn)( ALuint sid, ALenum param, ALfloat* value );
66 typedef void (AL_APIENTRY *alGetSourcefv_fcn)( ALuint sid, ALenum param, ALfloat* values );
67 typedef void (AL_APIENTRY *alGetSourcei_fcn)( ALuint sid, ALenum param, ALint* value );
68 typedef void (AL_APIENTRY *alGenSources_fcn)( ALsizei n, ALuint* sources );
69 typedef void (AL_APIENTRY *alListenerf_fcn)( ALenum param, ALfloat value );
70 typedef void (AL_APIENTRY *alListenerfv_fcn)( ALenum param, const ALfloat* values );
71 typedef void (AL_APIENTRY *alSourcef_fcn)( ALuint sid, ALenum param, ALfloat value );
72 typedef void (AL_APIENTRY *alSourcefv_fcn)( ALuint sid, ALenum param, const ALfloat* values );
73 typedef void (AL_APIENTRY *alSourcei_fcn)( ALuint sid, ALenum param, ALint value );
74 typedef void (AL_APIENTRY *alSourcePause_fcn)( ALuint sid );
75 typedef void (AL_APIENTRY *alSourcePlay_fcn)( ALuint sid );
76 typedef void (AL_APIENTRY *alSourceStop_fcn)( ALuint sid );
77 typedef void (AL_APIENTRY *alSourceQueueBuffers_fcn)( ALuint sid, ALsizei numEntries, const ALuint *bids );
78 typedef void (AL_APIENTRY *alSourceUnqueueBuffers_fcn)( ALuint sid, ALsizei numEntries, ALuint *bids );
79
80 // DLL Functions
81 static alBufferData_fcn alBufferData() {return g_alBufferData;}
82 static alcCloseDevice_fcn alcCloseDevice() {return g_alcCloseDevice;}
83 static alcCreateContext_fcn alcCreateContext() {return g_alcCreateContext;}
84 static alcDestroyContext_fcn alcDestroyContext() {return g_alcDestroyContext;}
85 static alIsExtensionPresent_fcn alIsExtensionPresent() {return g_alIsExtensionPresent;}
86 static alcMakeContextCurrent_fcn alcMakeContextCurrent() {return g_alcMakeContextCurrent;}
87 static alcOpenDevice_fcn alcOpenDevice() {return g_alcOpenDevice;}
88 static alDeleteBuffers_fcn alDeleteBuffers() {return g_alDeleteBuffers;}
89 static alDeleteSources_fcn alDeleteSources() {return g_alDeleteSources;}
90 static alGenBuffers_fcn alGenBuffers() {return g_alGenBuffers;}
91 static alGetError_fcn alGetError() {return g_alGetError;}
92 static alGetListenerf_fcn alGetListenerf() {return g_alGetListenerf;}
93 static alGetListenerfv_fcn alGetListenerfv() {return g_alGetListenerfv;}
94 static alGetSourcef_fcn alGetSourcef() {return g_alGetSourcef;}
95 static alGetSourcefv_fcn alGetSourcefv() {return g_alGetSourcefv;}
96 static alGetSourcei_fcn alGetSourcei() {return g_alGetSourcei;}
97 static alGenSources_fcn alGenSources() {return g_alGenSources;}
98 static alListenerf_fcn alListenerf() {return g_alListenerf;}
99 static alListenerfv_fcn alListenerfv() {return g_alListenerfv;}
100 static alSourcef_fcn alSourcef() {return g_alSourcef;}
101 static alSourcefv_fcn alSourcefv() {return g_alSourcefv;}
102 static alSourcei_fcn alSourcei() {return g_alSourcei;}
103 static alSourcePause_fcn alSourcePause() {return g_alSourcePause;}
104 static alSourcePlay_fcn alSourcePlay() {return g_alSourcePlay;}
105 static alSourceStop_fcn alSourceStop() {return g_alSourceStop;}
106 static alSourceQueueBuffers_fcn alSourceQueueBuffers() {return g_alSourceQueueBuffers;}
107 static alSourceUnqueueBuffers_fcn alSourceUnqueueBuffers() {return g_alSourceUnqueueBuffers;}
108
109 static String errorString(const ALenum &err);
110 static String errorString();
111
112 // Listener Functions
113 void set_listener_position(const Point3f &position);
114 void set_listener_velocity(const Vector3f &velocity);
115 void set_listener_forward_and_up(const Vector3f &forward, const Vector3f &up);
116 void set_listener_gain(const float &gain);
117
118 std::pair<Vector3f, Vector3f> get_listener_forward_and_up() const;
119
120 private:
121 void zero_handles();
122
123 #ifndef _WINDOWS
124 typedef void * HMODULE;
125 #endif
126
127 HMODULE m_openal32;
128 static alBufferData_fcn g_alBufferData;
129 static alcCloseDevice_fcn g_alcCloseDevice;
130 static alcCreateContext_fcn g_alcCreateContext;
131 static alcDestroyContext_fcn g_alcDestroyContext;
132 static alIsExtensionPresent_fcn g_alIsExtensionPresent;
133 static alcMakeContextCurrent_fcn g_alcMakeContextCurrent;
134 static alcOpenDevice_fcn g_alcOpenDevice;
135 static alDeleteBuffers_fcn g_alDeleteBuffers;
136 static alDeleteSources_fcn g_alDeleteSources;
137 static alGenBuffers_fcn g_alGenBuffers;
138 static alGetError_fcn g_alGetError;
139 static alGetListenerf_fcn g_alGetListenerf;
140 static alGetListenerfv_fcn g_alGetListenerfv;
141 static alGetSourcef_fcn g_alGetSourcef;
142 static alGetSourcefv_fcn g_alGetSourcefv;
143 static alGetSourcei_fcn g_alGetSourcei;
144 static alGenSources_fcn g_alGenSources;
145 static alListenerf_fcn g_alListenerf;
146 static alListenerfv_fcn g_alListenerfv;
147 static alSourcef_fcn g_alSourcef;
148 static alSourcefv_fcn g_alSourcefv;
149 static alSourcei_fcn g_alSourcei;
150 static alSourcePause_fcn g_alSourcePause;
151 static alSourcePlay_fcn g_alSourcePlay;
152 static alSourceStop_fcn g_alSourceStop;
153 static alSourceQueueBuffers_fcn g_alSourceQueueBuffers;
154 static alSourceUnqueueBuffers_fcn g_alSourceUnqueueBuffers;
155
156 ALCdevice *m_device;
157 ALCcontext *m_context;
158
159 String m_bgmusic;
160 Sound_Buffer *m_bgm;
161 Sound_Source *m_bgm_source;
162 };
163
164 }
165
166 #endif
167
168 #endif
Zeni::Sound_Renderer_AL::alGetSourcefv
static alGetSourcefv_fcn alGetSourcefv()
Definition: Sound_Renderer_AL.h:95
AL_APIENTRY
#define AL_APIENTRY
Definition: al.h:21
ALvoid
void ALvoid
Definition: al.h:74
param
GLenum GLint param
Definition: gl2ext.h:1491
Zeni::Sound_Renderer_AL::alListenerf
static alListenerf_fcn alListenerf()
Definition: Sound_Renderer_AL.h:98
Zeni::Sound_Renderer_AL::alcMakeContextCurrent
static alcMakeContextCurrent_fcn alcMakeContextCurrent()
Definition: Sound_Renderer_AL.h:86
void
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1824
Zeni::Sound_Renderer_AL::alcDestroyContext
static alcDestroyContext_fcn alcDestroyContext()
Definition: Sound_Renderer_AL.h:84
ALchar
char ALchar
Definition: al.h:41
Zeni::Sound_Renderer_AL::alGetListenerf
static alGetListenerf_fcn alGetListenerf()
Definition: Sound_Renderer_AL.h:92
Zeni::Sound_Renderer_AL::alSourceStop
static alSourceStop_fcn alSourceStop()
Definition: Sound_Renderer_AL.h:105
Zeni::Sound_Renderer_AL::alDeleteSources
static alDeleteSources_fcn alDeleteSources()
Definition: Sound_Renderer_AL.h:89
Zeni::Sound_Renderer_AL::alGetSourcei
static alGetSourcei_fcn alGetSourcei()
Definition: Sound_Renderer_AL.h:96
sources
GLsizei GLenum * sources
Definition: glew.h:3769
n
GLclampd n
Definition: glew.h:7287
Zeni::Sound_Renderer
Definition: Sound_Renderer.h:44
ALsizei
int ALsizei
Definition: al.h:62
sid
FT_UInt sid
Definition: cffcmap.c:128
Zeni::Sound_Renderer_AL::alcOpenDevice_fcn
ALCdevice *(ALC_APIENTRY * alcOpenDevice_fcn)(const ALCchar *devicename)
Definition: Sound_Renderer_AL.h:58
ALCdevice_struct
Definition: alMain.h:560
ALint
int ALint
Definition: al.h:56
Zeni::Sound_Renderer_AL::alSourcei
static alSourcei_fcn alSourcei()
Definition: Sound_Renderer_AL.h:102
Zeni::Sound_Renderer_AL::alGetListenerfv
static alGetListenerfv_fcn alGetListenerfv()
Definition: Sound_Renderer_AL.h:93
ALC_APIENTRY
#define ALC_APIENTRY
Definition: alc.h:21
Zeni::Sound_Renderer_AL::alGetSourcef
static alGetSourcef_fcn alGetSourcef()
Definition: Sound_Renderer_AL.h:94
Zeni::Sound_Renderer_AL::alcCreateContext
static alcCreateContext_fcn alcCreateContext()
Definition: Sound_Renderer_AL.h:83
ALfloat
float ALfloat
Definition: al.h:68
ALCchar
char ALCchar
Definition: alc.h:42
Zeni::Sound_Renderer_AL::alSourcef
static alSourcef_fcn alSourcef()
Definition: Sound_Renderer_AL.h:100
Zeni::String
Definition: String.h:29
Zeni::Point3f
A 3D Point represented with floats.
Definition: Coordinate.h:133
buffers
const GLuint * buffers
Definition: glew.h:1669
Zeni::Sound_Source
Plays Sound Data.
Definition: Sound_Source.h:147
Zeni::Vector3f
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
Zeni::Sound_Renderer_AL::alSourceQueueBuffers
static alSourceQueueBuffers_fcn alSourceQueueBuffers()
Definition: Sound_Renderer_AL.h:106
Zeni::Sound_Renderer_AL::alcOpenDevice
static alcOpenDevice_fcn alcOpenDevice()
Definition: Sound_Renderer_AL.h:87
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl2ext.h:848
Zeni::Sound_Renderer_AL
Definition: Sound_Renderer_AL.h:41
Zeni::Sound_Renderer_AL::alBufferData
static alBufferData_fcn alBufferData()
Definition: Sound_Renderer_AL.h:81
ALenum
int ALenum
Definition: al.h:65
format
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl2ext.h:845
ALuint
unsigned int ALuint
Definition: al.h:59
Zeni::Sound_Renderer_AL::alcCreateContext_fcn
ALCcontext *(ALC_APIENTRY * alcCreateContext_fcn)(ALCdevice *device, const ALCint *attrlist)
Definition: Sound_Renderer_AL.h:54
Zeni::Sound_Buffer
Stores Sound Data.
Definition: Sound_Buffer.h:83
Zeni::Sound_Renderer_AL::alIsExtensionPresent
static alIsExtensionPresent_fcn alIsExtensionPresent()
Definition: Sound_Renderer_AL.h:85
Zeni::Sound_Renderer_AL::alDeleteBuffers
static alDeleteBuffers_fcn alDeleteBuffers()
Definition: Sound_Renderer_AL.h:88
Zeni::Sound_Renderer_AL::alSourcefv
static alSourcefv_fcn alSourcefv()
Definition: Sound_Renderer_AL.h:101
Zeni::Sound_Renderer_AL::alGetError
static alGetError_fcn alGetError()
Definition: Sound_Renderer_AL.h:91
Zeni::Sound_Renderer_AL::alSourcePlay
static alSourcePlay_fcn alSourcePlay()
Definition: Sound_Renderer_AL.h:104
Sound_Renderer.h
value
EGLSurface EGLint void ** value
Definition: eglext.h:301
ALCboolean
char ALCboolean
Definition: alc.h:39
ALCcontext_struct
Definition: alMain.h:675
Zeni::Sound
The Sound Singleton.
Definition: Sound.h:53
ALCint
int ALCint
Definition: alc.h:57
ALboolean
char ALboolean
Definition: al.h:38
Zeni::Sound_Renderer_AL::alSourceUnqueueBuffers
static alSourceUnqueueBuffers_fcn alSourceUnqueueBuffers()
Definition: Sound_Renderer_AL.h:107
Zeni::Sound_Renderer_AL::alSourcePause
static alSourcePause_fcn alSourcePause()
Definition: Sound_Renderer_AL.h:103
Zeni::Sound_Renderer_AL::alListenerfv
static alListenerfv_fcn alListenerfv()
Definition: Sound_Renderer_AL.h:99
Zeni::Sound_Renderer_AL::alcCloseDevice
static alcCloseDevice_fcn alcCloseDevice()
Definition: Sound_Renderer_AL.h:82
vorbisfile.h
context
TParseContext * context
Definition: glslang_tab.cpp:1907
Zeni::Sound_Renderer_AL::alGenSources
static alGenSources_fcn alGenSources()
Definition: Sound_Renderer_AL.h:97
values
GLint GLsizei const GLuint64 * values
Definition: glew.h:3473
Zeni::Sound_Renderer_AL::alGenBuffers
static alGenBuffers_fcn alGenBuffers()
Definition: Sound_Renderer_AL.h:90
size
GLsizei size
Definition: gl2ext.h:1467