[go: up one dir, main page]

File: openal_wrapper.h

package info (click to toggle)
coin3 3.1.3-2.2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 48,368 kB
  • sloc: cpp: 314,329; ansic: 15,927; sh: 13,635; makefile: 8,772; perl: 2,149; lex: 1,302; lisp: 1,247; yacc: 184; xml: 175; sed: 68
file content (185 lines) | stat: -rw-r--r-- 7,253 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#ifndef COIN_OPENALWRAPPER_H
#define COIN_OPENALWRAPPER_H

/**************************************************************************\
 *
 *  This file is part of the Coin 3D visualization library.
 *  Copyright (C) by Kongsberg Oil & Gas Technologies.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  ("GPL") version 2 as published by the Free Software Foundation.
 *  See the file LICENSE.GPL at the root directory of this source
 *  distribution for additional information about the GNU GPL.
 *
 *  For using Coin with software that can not be combined with the GNU
 *  GPL, and for taking advantage of the additional benefits of our
 *  support services, please contact Kongsberg Oil & Gas Technologies
 *  about acquiring a Coin Professional Edition License.
 *
 *  See http://www.coin3d.org/ for more information.
 *
 *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
 *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
 *
\**************************************************************************/

#ifndef COIN_INTERNAL
#error this is a private header file
#endif

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */

#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif /* HAVE_WINDOWS_H */

/* Note: Under Win32, we need to make sure we use the correct calling
   method by using the OPENALWRAPPER_APIENTRY define for the function
   signature types (or else we'll get weird stack errors). The calling
   convention must match the calling convention used in the
   OpenAL32.dll we link against. Both the LGPL version of OpenAL in
   CVS (www.openal.org), Creative Lab's (binary) SDK, and nVidia's
   AudioSDK, uses this calling method, so I think it is quite safe to
   assume that all OpenAL32.dlls use this method.  On other platforms,
   just define OPENALWRAPPER_APIENTRY empty. Stack errors (under Win32)
   can be detected by specifying the /GZ linker option. 
   2003-03-19 thammer. */

#ifdef _WIN32
  #define OPENALWRAPPER_APIENTRY __cdecl
#else
  #define OPENALWRAPPER_APIENTRY
#endif /* _WIN32 */

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* Typedefinitions of function signatures for openal calls we use. We
   need these for casting from the void-pointer return of dlsym().*/

  typedef const unsigned char * (OPENALWRAPPER_APIENTRY *alGetString_t)(int param);
  typedef int (OPENALWRAPPER_APIENTRY *alGetError_t)(void);

  typedef void (OPENALWRAPPER_APIENTRY *alListenerfv_t)(int pname, float *param);
  typedef void (OPENALWRAPPER_APIENTRY *alListenerf_t)(int pname, float param);

  typedef void (OPENALWRAPPER_APIENTRY *alDistanceModel_t)(int distanceModel);

  typedef void (OPENALWRAPPER_APIENTRY *alGenSources_t)(int n, unsigned int *sources);
  typedef void (OPENALWRAPPER_APIENTRY *alDeleteSources_t)(int n, unsigned int *sources);
  typedef void (OPENALWRAPPER_APIENTRY *alSourcePlay_t)(unsigned int source);
  typedef void (OPENALWRAPPER_APIENTRY *alSourceStop_t)(unsigned int source);
  typedef void (OPENALWRAPPER_APIENTRY *alSourceRewind_t)(unsigned int source);
  typedef void (OPENALWRAPPER_APIENTRY *alSourcefv_t)(unsigned int source, int param, 
                                        float *values);
  typedef void (OPENALWRAPPER_APIENTRY *alSourcef_t)(unsigned int source, int param, 
                                       float value);
  typedef void (OPENALWRAPPER_APIENTRY *alSourcei_t)(unsigned int source, int param, 
                                       int value);
  typedef void (OPENALWRAPPER_APIENTRY *alGetSourcei_t)(unsigned int source, int param, 
                                          int *value);
  typedef void (OPENALWRAPPER_APIENTRY *alSourceQueueBuffers_t)(unsigned int source, 
                                                  unsigned int n, 
                                                  unsigned int *buffers);
  typedef void (OPENALWRAPPER_APIENTRY *alSourceUnqueueBuffers_t)(unsigned int source, 
                                                  unsigned int n, 
                                                  unsigned int *buffers);

  typedef void (OPENALWRAPPER_APIENTRY *alBufferData_t)(unsigned int buffer, int format,
                                       void *data, unsigned int size,
                                       unsigned int freq);
  typedef void (OPENALWRAPPER_APIENTRY *alGenBuffers_t)(int n, unsigned int *buffers);
  typedef void (OPENALWRAPPER_APIENTRY *alDeleteBuffers_t)(int n, unsigned int *buffers);

  typedef void * (OPENALWRAPPER_APIENTRY *alcCreateContext_t)(void *device, int *attrlist);
  typedef int (OPENALWRAPPER_APIENTRY *alcMakeContextCurrent_t)(void *context);
  typedef void (OPENALWRAPPER_APIENTRY *alcProcessContext_t)(void *context);
  typedef void (OPENALWRAPPER_APIENTRY *alcSuspendContext_t)(void *context);
  typedef void (OPENALWRAPPER_APIENTRY *alcDestroyContext_t)(void *context);

  typedef void * (OPENALWRAPPER_APIENTRY *alcOpenDevice_t)(unsigned char *deviceName);
  typedef void (OPENALWRAPPER_APIENTRY *alcCloseDevice_t)(void *device);

#if !OPENALWRAPPER_ASSUME_OPENAL
  enum {
    AL_NO_ERROR=0x0000,
    AL_NONE=0x0000,
    AL_PITCH=0x1003,
    AL_POSITION=0x1004,
    AL_VELOCITY=0x1006,
    AL_LOOPING=0x1007,
    AL_GAIN=0x100a,
    AL_MIN_GAIN=0x100d,
    AL_MAX_GAIN=0x100e,
    AL_ORIENTATION=0x100f,
    AL_BUFFER=0x1009,
    AL_SOURCE_STATE=0x1010,
    AL_INITIAL=0x1011,
    AL_PLAYING=0x1012,
    AL_PAUSED=0x1013,
    AL_STOPPED=0x1014,
    AL_BUFFERS_QUEUED=0x1015,
    AL_BUFFERS_PROCESSED=0x1016,
    AL_ROLLOFF_FACTOR=0x1021,
    AL_FORMAT_MONO8=0x1100,
    AL_FORMAT_MONO16=0x1101,
    AL_FORMAT_STEREO8=0x1102,
    AL_FORMAT_STEREO16=0x1103,
    AL_INVALID_NAME=0xa001,
    AL_INVALID_ENUM=0xa002,
    AL_INVALID_VALUE=0xa003,
    AL_INVALID_OPERATION=0xa004,
    AL_OUT_OF_MEMORY=0xa005,
    AL_VENDOR=0xb001,
    AL_VERSION=0xb002,
    AL_RENDERER=0xb003,
    AL_EXTENSIONS=0xb004,
    AL_INVERSE_DISTANCE_CLAMPED=0xd002
  };
#endif /* !OPENALWRAPPER_ASSUME_OPENAL */

  typedef struct {
    int available;
    int runtime;

    alGetString_t alGetString;
    alGetError_t alGetError;
    alListenerfv_t alListenerfv;
    alListenerf_t alListenerf;
    alDistanceModel_t alDistanceModel;
    alGenSources_t alGenSources;
    alDeleteSources_t alDeleteSources;
    alSourcePlay_t alSourcePlay;
    alSourceStop_t alSourceStop;
    alSourceRewind_t alSourceRewind;
    alSourcefv_t alSourcefv;
    alSourcef_t alSourcef;
    alSourcei_t alSourcei;
    alGetSourcei_t alGetSourcei;
    alSourceQueueBuffers_t alSourceQueueBuffers;
    alSourceUnqueueBuffers_t alSourceUnqueueBuffers;
    alBufferData_t alBufferData;
    alGenBuffers_t alGenBuffers;
    alDeleteBuffers_t alDeleteBuffers;

    alcCreateContext_t alcCreateContext;
    alcMakeContextCurrent_t alcMakeContextCurrent;
    alcProcessContext_t alcProcessContext;
    alcSuspendContext_t alcSuspendContext;
    alcDestroyContext_t alcDestroyContext;
    alcOpenDevice_t alcOpenDevice;
    alcCloseDevice_t alcCloseDevice;

  } openal_wrapper_t;

  const openal_wrapper_t * openal_wrapper(void);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* COIN_OPENALWRAPPER_H */