author | smxx |
Fri, 28 May 2010 20:05:22 +0000 | |
changeset 3485 | ab91c56a9050 |
parent 3364 | e5403e2bf02c |
child 3513 | f589230fa21b |
permissions | -rw-r--r-- |
3353 | 1 |
/* |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
2 |
* OpenAL Bridge - a simple portable library for OpenAL interface |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
3 |
* Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com> |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
4 |
* |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
6 |
* it under the terms of the GNU Lesser General Public License as published by |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
8 |
* |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
12 |
* GNU Lesser General Public License for more details. |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
13 |
* |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
14 |
* You should have received a copy of the GNU Lesser General Public License |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
17 |
*/ |
3353 | 18 |
|
19 |
#include "openalbridge.h" |
|
20 |
#include "globals.h" |
|
3364 | 21 |
#include "al.h" |
22 |
#include "alc.h" |
|
3353 | 23 |
#include "wrappers.h" |
24 |
#include "loaders.h" |
|
25 |
||
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
26 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
27 |
/*Sources are points emitting sound*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
28 |
ALuint *Sources; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
29 |
/*Buffers hold sound data*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
30 |
ALuint *Buffers; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
31 |
/*index for Sources and Buffers*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
32 |
ALuint globalindex, globalsize, increment; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
33 |
|
3364 | 34 |
ALboolean isBridgeReady = AL_FALSE; |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
35 |
ALfloat old_gain; |
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
36 |
|
3364 | 37 |
int openal_init (int memorysize) { |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
38 |
/*Initialize an OpenAL contex and allocate memory space for data and buffers*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
39 |
ALCcontext *context; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
40 |
ALCdevice *device; |
3364 | 41 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
42 |
// set the memory dimentsion and the increment width when reallocating |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
43 |
if (memorysize <= 0) |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
44 |
globalsize = 50; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
45 |
else |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
46 |
globalsize = memorysize; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
47 |
increment = globalsize; |
3364 | 48 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
49 |
// reuse old context but keep the new value for increment |
3364 | 50 |
if (isBridgeReady == AL_TRUE) { |
51 |
fprintf(stderr,"(Bridge Warning) - already initialized"); |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
52 |
return 0; |
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
53 |
} |
3364 | 54 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
55 |
// open hardware device if present |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
56 |
device = alcOpenDevice(NULL); |
3364 | 57 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
58 |
if (device == NULL) { |
3364 | 59 |
fprintf(stderr,"(Bridge Warning) - failed to open sound device, using software renderer"); |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
60 |
device = alcOpenDevice("Generic Software"); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
61 |
if (device == NULL) { |
3364 | 62 |
fprintf(stderr,"(Bridge Error) - failed to open sound software device, sound will be disabled"); |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
63 |
return -1; |
3353 | 64 |
} |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
65 |
} |
3364 | 66 |
|
67 |
fprintf(stderr,"(Bridge Info) - Output device: %s", alcGetString(device, ALC_DEVICE_SPECIFIER)); |
|
68 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
69 |
context = alcCreateContext(device, NULL); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
70 |
alcMakeContextCurrent(context); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
71 |
alcProcessContext(context); |
3364 | 72 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
73 |
if (AL_NO_ERROR != alGetError()) { |
3364 | 74 |
fprintf(stderr,"(Bridge Error) - Failed to create a new contex"); |
3353 | 75 |
alcMakeContextCurrent(NULL); |
76 |
alcDestroyContext(context); |
|
77 |
alcCloseDevice(device); |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
78 |
return -2; |
3353 | 79 |
} |
3364 | 80 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
81 |
// allocate memory space for buffers and sources |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
82 |
Buffers = (ALuint*) Malloc(sizeof(ALuint)*globalsize); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
83 |
Sources = (ALuint*) Malloc(sizeof(ALuint)*globalsize); |
3364 | 84 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
85 |
// set the listener gain, position (on xyz axes), velocity (one value for each axe) and orientation |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
86 |
// Position, Velocity and Orientation of the listener |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
87 |
ALfloat ListenerPos[] = {0.0, 0.0, 0.0}; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
88 |
ALfloat ListenerVel[] = {0.0, 0.0, 0.0}; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
89 |
ALfloat ListenerOri[] = {0.0, 0.0, -1.0, 0.0, 1.0, 0.0}; |
3364 | 90 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
91 |
alListenerf (AL_GAIN, 1.0f ); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
92 |
alListenerfv(AL_POSITION, ListenerPos); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
93 |
alListenerfv(AL_VELOCITY, ListenerVel); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
94 |
alListenerfv(AL_ORIENTATION, ListenerOri); |
3364 | 95 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
96 |
if (AL_NO_ERROR != alGetError()) { |
3364 | 97 |
fprintf(stderr,"(Bridge Error) - Failed to set Listener properties"); |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
98 |
return -3; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
99 |
} |
3364 | 100 |
isBridgeReady = AL_TRUE; |
101 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
102 |
alGetError(); // clear any AL errors beforehand |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
103 |
return AL_TRUE; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
104 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
105 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
106 |
void openal_close (void) { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
107 |
/*Stop all sounds, deallocate all memory and close OpenAL */ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
108 |
ALCcontext *context; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
109 |
ALCdevice *device; |
3364 | 110 |
|
111 |
if (isBridgeReady == AL_FALSE) { |
|
112 |
fprintf(stderr,"(Bridge Warning) - OpenAL not initialized"); |
|
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
113 |
return; |
3353 | 114 |
} |
3364 | 115 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
116 |
alSourceStopv (globalsize, Sources); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
117 |
alDeleteSources (globalsize, Sources); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
118 |
alDeleteBuffers (globalsize, Buffers); |
3364 | 119 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
120 |
free(Sources); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
121 |
free(Buffers); |
3364 | 122 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
123 |
context = alcGetCurrentContext(); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
124 |
device = alcGetContextsDevice(context); |
3364 | 125 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
126 |
alcMakeContextCurrent(NULL); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
127 |
alcDestroyContext(context); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
128 |
alcCloseDevice(device); |
3364 | 129 |
|
130 |
isBridgeReady = AL_FALSE; |
|
131 |
||
132 |
fprintf(stderr,"(Bridge Info) - closed"); |
|
133 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
134 |
return; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
135 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
136 |
|
3364 | 137 |
ALboolean openal_ready (void) { |
138 |
return isBridgeReady; |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
139 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
140 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
141 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
142 |
void helper_realloc (void) { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
143 |
/*expands allocated memory when loading more sound files than expected*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
144 |
int oldsize = globalsize; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
145 |
globalsize += increment; |
3364 | 146 |
|
147 |
fprintf(stderr,"(Bridge Info) - Realloc in process from %d to %d\n", oldsize, globalsize); |
|
148 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
149 |
Buffers = (ALuint*) Realloc(Buffers, sizeof(ALuint)*globalsize); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
150 |
Sources = (ALuint*) Realloc(Sources, sizeof(ALuint)*globalsize); |
3364 | 151 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
152 |
return; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
153 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
154 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
155 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
156 |
int openal_loadfile (const char *filename){ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
157 |
/*Open a file, load into memory and allocate the Source buffer for playing*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
158 |
ALfloat SourcePos[] = { 0.0, 0.0, 0.0 }; /*Position of the source sound*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
159 |
ALfloat SourceVel[] = { 0.0, 0.0, 0.0 }; /*Velocity of the source sound*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
160 |
ALenum format; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
161 |
ALsizei bitsize, freq; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
162 |
char *data; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
163 |
uint32_t fileformat; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
164 |
ALenum error; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
165 |
FILE *fp; |
3364 | 166 |
|
167 |
if (isBridgeReady == AL_FALSE) { |
|
168 |
fprintf(stderr,"(Bridge Warning) - not initialized"); |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
169 |
return -1; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
170 |
} |
3364 | 171 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
172 |
/*when the buffers are all used, we can expand memory to accept new files*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
173 |
if (globalindex == globalsize) |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
174 |
helper_realloc(); |
3364 | 175 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
176 |
/*detect the file format, as written in the first 4 bytes of the header*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
177 |
fp = Fopen (filename, "rb"); |
3364 | 178 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
179 |
if (fp == NULL) |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
180 |
return -2; |
3364 | 181 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
182 |
error = fread (&fileformat, sizeof(uint32_t), 1, fp); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
183 |
fclose (fp); |
3364 | 184 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
185 |
if (error < 0) { |
3364 | 186 |
fprintf(stderr,"(Bridge Error) - File %s is too short", filename); |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
187 |
return -3; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
188 |
} |
3364 | 189 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
190 |
/*prepare the buffer to receive data*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
191 |
alGenBuffers(1, &Buffers[globalindex]); |
3364 | 192 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
193 |
if (AL_NO_ERROR != alGetError()) { |
3364 | 194 |
fprintf(stderr,"(Bridge Error) - Failed to allocate memory for buffers"); |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
195 |
return -4; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
196 |
} |
3364 | 197 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
198 |
/*prepare the source to emit sound*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
199 |
alGenSources(1, &Sources[globalindex]); |
3364 | 200 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
201 |
if (AL_NO_ERROR != alGetError()) { |
3364 | 202 |
fprintf(stderr,"(Bridge Error) - Failed to allocate memory for sources"); |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
203 |
return -5; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
204 |
} |
3364 | 205 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
206 |
switch (ENDIAN_BIG_32(fileformat)) { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
207 |
case OGG_FILE_FORMAT: |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
208 |
error = load_oggvorbis (filename, &format, &data, &bitsize, &freq); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
209 |
break; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
210 |
case WAV_FILE_FORMAT: |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
211 |
error = load_wavpcm (filename, &format, &data, &bitsize, &freq); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
212 |
break; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
213 |
default: |
3364 | 214 |
fprintf(stderr,"(Bridge Error) - File format (%08X) not supported", ENDIAN_BIG_32(fileformat)); |
3353 | 215 |
return -6; |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
216 |
break; |
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
217 |
} |
3364 | 218 |
|
219 |
if (error != 0) { |
|
220 |
fprintf(stderr,"(Bridge Error) - error loading file %s", filename); |
|
221 |
free(data); |
|
222 |
return -7; |
|
223 |
} |
|
224 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
225 |
//copy pcm data in one buffer and free it |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
226 |
alBufferData(Buffers[globalindex], format, data, bitsize, freq); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
227 |
free(data); |
3364 | 228 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
229 |
if (AL_NO_ERROR != alGetError()) { |
3364 | 230 |
fprintf(stderr,"(Bridge Error) - Failed to write data to buffers"); |
231 |
return -8; |
|
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
232 |
} |
3364 | 233 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
234 |
/*set source properties that it will use when it's in playback*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
235 |
alSourcei (Sources[globalindex], AL_BUFFER, Buffers[globalindex] ); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
236 |
alSourcef (Sources[globalindex], AL_PITCH, 1.0f ); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
237 |
alSourcef (Sources[globalindex], AL_GAIN, 1.0f ); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
238 |
alSourcefv(Sources[globalindex], AL_POSITION, SourcePos ); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
239 |
alSourcefv(Sources[globalindex], AL_VELOCITY, SourceVel ); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
240 |
alSourcei (Sources[globalindex], AL_LOOPING, 0 ); |
3364 | 241 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
242 |
if (AL_NO_ERROR != alGetError()) { |
3364 | 243 |
fprintf(stderr,"(Bridge Error) - Failed to set Source properties"); |
244 |
return -9; |
|
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
245 |
} |
3364 | 246 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
247 |
alGetError(); /* clear any AL errors beforehand */ |
3364 | 248 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
249 |
/*returns the index of the source you just loaded, increments it and exits*/ |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
250 |
return globalindex++; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
251 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
252 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
253 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
254 |
void openal_playsound (uint32_t index) { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
255 |
openal_playsound_loop (index, 0); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
256 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
257 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
258 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
259 |
void openal_pausesound (uint32_t index) { |
3364 | 260 |
if (isBridgeReady == AL_TRUE && index < globalsize) |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
261 |
alSourcePause(Sources[index]); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
262 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
263 |
|
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
264 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
265 |
void openal_stopsound (uint32_t index) { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
266 |
openal_stopsound_free(index, 0); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
267 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
268 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
269 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
270 |
void openal_freesound (uint32_t index){ |
3364 | 271 |
if (isBridgeReady == AL_TRUE && index < globalsize) |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
272 |
alSourceStop(Sources[index]); |
3364 | 273 |
// STUB |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
274 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
275 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
276 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
277 |
void openal_playsound_loop (unsigned int index, char loops) { |
3364 | 278 |
if (isBridgeReady == AL_TRUE && index < globalsize) { |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
279 |
alSourcePlay(Sources[index]); |
3364 | 280 |
if (loops != 0) |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
281 |
openal_toggleloop(index); |
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
282 |
} |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
283 |
} |
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
284 |
|
3364 | 285 |
void openal_stopsound_free (unsigned int index, char freesource) { |
286 |
if (isBridgeReady == AL_TRUE && index < globalsize) { |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
287 |
alSourceStop(Sources[index]); |
3364 | 288 |
if (freesource != 0) |
289 |
openal_freesound(index); |
|
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
290 |
} |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
291 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
292 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
293 |
void openal_toggleloop (uint32_t index) { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
294 |
ALint loop; |
3364 | 295 |
|
296 |
if (isBridgeReady == AL_TRUE && index < globalsize) { |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
297 |
alGetSourcei (Sources[index], AL_LOOPING, &loop); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
298 |
alSourcei (Sources[index], AL_LOOPING, !((uint8_t) loop) & 0x00000001); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
299 |
} |
3364 | 300 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
301 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
302 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
303 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
304 |
void openal_setvolume (uint32_t index, float gain) { |
3364 | 305 |
if (isBridgeReady == AL_TRUE && index < globalsize) |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
306 |
alSourcef (Sources[index], AL_GAIN, gain); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
307 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
308 |
|
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
309 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
310 |
void openal_setglobalvolume (float gain) { |
3364 | 311 |
if (isBridgeReady == AL_TRUE) |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
312 |
alListenerf (AL_GAIN, gain); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
313 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
314 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
315 |
void openal_togglemute () { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
316 |
ALfloat gain; |
3364 | 317 |
|
318 |
if (isBridgeReady == AL_TRUE) { |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
319 |
alGetListenerf (AL_GAIN, &gain); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
320 |
if (gain > 0) { |
3364 | 321 |
old_gain = gain; |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
322 |
gain = 0; |
3364 | 323 |
} else |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
324 |
gain = old_gain; |
3364 | 325 |
|
326 |
alListenerf (AL_GAIN, gain); |
|
327 |
} |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
328 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
329 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
330 |
// Fade in or out by calling a helper thread |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
331 |
void openal_fade (uint32_t index, uint16_t quantity, al_fade_t direction) { |
3353 | 332 |
#ifndef _WIN32 |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
333 |
pthread_t thread; |
3353 | 334 |
#else |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
335 |
HANDLE Thread; |
3353 | 336 |
#endif |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
337 |
fade_t *fade; |
3364 | 338 |
|
339 |
if (isBridgeReady == AL_TRUE && index < globalsize) { |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
340 |
fade = (fade_t*) Malloc(sizeof(fade_t)); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
341 |
fade->index = index; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
342 |
fade->quantity = quantity; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
343 |
fade->type = direction; |
3364 | 344 |
|
3353 | 345 |
#ifndef _WIN32 |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
346 |
pthread_create(&thread, NULL, (void *)helper_fade, (void *)fade); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
347 |
pthread_detach(thread); |
3353 | 348 |
#else |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
349 |
Thread = (HANDLE) _beginthread((void *)helper_fade, 0, (void *)fade); |
3353 | 350 |
#endif |
351 |
} |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
352 |
} |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
353 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
354 |
void openal_fadein (uint32_t index, uint16_t quantity) { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
355 |
openal_fade(index, quantity, AL_FADE_IN); |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
356 |
} |
3360
717b4e46e855
updates to openalbridge (modified api and simplified some sections)
koda
parents:
3356
diff
changeset
|
357 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
358 |
void openal_fadeout (uint32_t index, uint16_t quantity) { |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
359 |
openal_fade(index, quantity, AL_FADE_OUT); |
3353 | 360 |
} |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
361 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
362 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
363 |
void openal_setposition (uint32_t index, float x, float y, float z) { |
3364 | 364 |
if (isBridgeReady == AL_TRUE && index < globalsize) |
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
365 |
alSource3f(Sources[index], AL_POSITION, x, y, z);; |
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3361
diff
changeset
|
366 |
} |