1 /* |
1 /* |
2 * OpenAL Bridge - a simple portable library for OpenAL interface |
2 * OpenAL Bridge - a simple portable library for OpenAL interface |
3 * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com> |
3 * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com> |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License as published by |
6 * it under the terms of the GNU Lesser General Public License as published by |
7 * the Free Software Foundation; version 2 of the License |
7 * the Free Software Foundation; version 2 of the License |
8 * |
8 * |
9 * This program is distributed in the hope that it will be useful, |
9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. |
12 * GNU Lesser General Public License for more details. |
13 * |
13 * |
14 * You should have received a copy of the GNU General Public License |
14 * You should have received a copy of the GNU Lesser General Public License |
15 * along with this program; if not, write to the Free Software |
15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 */ |
17 */ |
18 |
18 |
19 #include "globals.h" |
19 #include "globals.h" |
30 ALuint *Sources; |
30 ALuint *Sources; |
31 /*Buffers hold sound data*/ |
31 /*Buffers hold sound data*/ |
32 ALuint *Buffers; |
32 ALuint *Buffers; |
33 /*index for Sources and Buffers*/ |
33 /*index for Sources and Buffers*/ |
34 ALuint globalindex, globalsize, increment; |
34 ALuint globalindex, globalsize, increment; |
35 /*Position of the source sound*/ |
|
36 ALfloat SourcePos[] = { 0.0, 0.0, 0.0 }; |
|
37 /*Velocity of the source sound*/ |
|
38 ALfloat SourceVel[] = { 0.0, 0.0, 0.0 }; |
|
39 |
35 |
40 ALint openalReady = AL_FALSE; |
36 ALint openalReady = AL_FALSE; |
41 |
37 |
42 ALint openal_close(void) { |
38 ALint openal_close(void) { |
43 /*Stop all sounds, deallocate all memory and close OpenAL */ |
39 /*Stop all sounds, deallocate all memory and close OpenAL */ |
186 if (AlGetError("ERROR %d: Allocating memory for sources\n") != AL_TRUE) |
184 if (AlGetError("ERROR %d: Allocating memory for sources\n") != AL_TRUE) |
187 return -4; |
185 return -4; |
188 |
186 |
189 |
187 |
190 if (fileformat == 0x5367674F) /*check if ogg*/ |
188 if (fileformat == 0x5367674F) /*check if ogg*/ |
191 error = load_OggVorbis (filename, &format, &data, &bitsize, &freq); |
189 error = load_oggvorbis (filename, &format, &data, &bitsize, &freq); |
192 else { |
190 else { |
193 if (fileformat == 0x46464952) /*check if wav*/ |
191 if (fileformat == 0x46464952) /*check if wav*/ |
194 error = load_WavPcm (filename, &format, &data, &bitsize, &freq); |
192 error = load_wavpcm (filename, &format, &data, &bitsize, &freq); |
195 else { |
193 else { |
196 fprintf(stderr, "ERROR: File format (%08X) not supported!\n", invert_endianness(fileformat)); |
194 fprintf(stderr, "ERROR: File format (%08X) not supported!\n", invert_endianness(fileformat)); |
197 return -5; |
195 return -5; |
198 } |
196 } |
199 } |
197 } |