|
@@ -1,23 +1,12 @@
|
1
|
|
-/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
|
2
|
|
-/*================================================================
|
|
1
|
+/*!
|
|
2
|
+ * \file Sound.cpp
|
|
3
|
+ * \brief This is the audio manager Implementation
|
3
|
4
|
*
|
4
|
|
- * Project : OpenRaider
|
5
|
|
- * Author : Mongoose
|
6
|
|
- * Website : http://www.westga.edu/~stu7440/
|
7
|
|
- * Email : stu7440@westga.edu
|
8
|
|
- * Object : Sound
|
9
|
|
- * License : No use w/o permission (C) 2001 Mongoose
|
10
|
|
- * Comments: This is the audio manager for OpenRaider
|
|
5
|
+ * Defining UNIT_TEST_SOUND builds Sound class as a console unit test
|
11
|
6
|
*
|
12
|
|
- *
|
13
|
|
- * This file was generated using Mongoose's C++
|
14
|
|
- * template generator script. <stu7440@westga.edu>
|
15
|
|
- *
|
16
|
|
- *-- History -------------------------------------------------
|
17
|
|
- *
|
18
|
|
- * 2001.05.23:
|
19
|
|
- * Mongoose - Created
|
20
|
|
- =================================================================*/
|
|
7
|
+ * \author Mongoose
|
|
8
|
+ * \author xythobuz
|
|
9
|
+ */
|
21
|
10
|
|
22
|
11
|
#ifdef HAVE_OPENAL
|
23
|
12
|
#ifdef __APPLE__
|
|
@@ -25,10 +14,10 @@
|
25
|
14
|
#include <OpenAL/alc.h>
|
26
|
15
|
#include <AL/alut.h>
|
27
|
16
|
#else
|
28
|
|
-# include <AL/al.h>
|
29
|
|
-# include <AL/alc.h>
|
30
|
|
-# include <AL/alut.h>
|
31
|
|
-# include <AL/alext.h>
|
|
17
|
+#include <AL/al.h>
|
|
18
|
+#include <AL/alc.h>
|
|
19
|
+#include <AL/alut.h>
|
|
20
|
+#include <AL/alext.h>
|
32
|
21
|
#endif
|
33
|
22
|
#endif
|
34
|
23
|
|
|
@@ -43,7 +32,7 @@
|
43
|
32
|
#include "Sound.h"
|
44
|
33
|
|
45
|
34
|
#ifdef DEBUG_MEMEORY
|
46
|
|
-# include "memeory_test.h"
|
|
35
|
+#include "memeory_test.h"
|
47
|
36
|
#endif
|
48
|
37
|
|
49
|
38
|
|
|
@@ -191,7 +180,9 @@ int Sound::addFile(char *filename, int *source, unsigned int flags)
|
191
|
180
|
#endif
|
192
|
181
|
}
|
193
|
182
|
|
194
|
|
-
|
|
183
|
+/*!
|
|
184
|
+ * \todo Reimplement, not using deprecated FORMAT specifier
|
|
185
|
+ */
|
195
|
186
|
int Sound::addWave(unsigned char *wav, int *source, unsigned int flags)
|
196
|
187
|
{
|
197
|
188
|
#ifdef HAVE_OPENAL
|
|
@@ -230,8 +221,7 @@ int Sound::addWave(unsigned char *wav, int *source, unsigned int flags)
|
230
|
221
|
return -2;
|
231
|
222
|
}
|
232
|
223
|
|
233
|
|
-// This method isn't used yet...
|
234
|
|
-//#warning "AL_FORMAT_WAVE_EXT does not exist on Mac!"
|
|
224
|
+#warning "AL_FORMAT_WAVE_EXT does not exist on Mac!"
|
235
|
225
|
// alBufferData(mBuffer[mNextBuffer], AL_FORMAT_WAVE_EXT, data, size, freq);
|
236
|
226
|
alBufferData(mBuffer[mNextBuffer], 0x10002, data, size, freq);
|
237
|
227
|
|
|
@@ -292,6 +282,12 @@ void Sound::stop(int source)
|
292
|
282
|
|
293
|
283
|
|
294
|
284
|
#ifdef UNIT_TEST_SOUND
|
|
285
|
+/*!
|
|
286
|
+ * \brief Sound Unit Test
|
|
287
|
+ * \param argc Number of arguments. Has to be > 1
|
|
288
|
+ * \param argv Argument array. argv[1] will be played as wav file
|
|
289
|
+ * \returns always zero
|
|
290
|
+ */
|
295
|
291
|
int main(int argc, char* argv[])
|
296
|
292
|
{
|
297
|
293
|
Sound snd;
|
|
@@ -305,7 +301,7 @@ int main(int argc, char* argv[])
|
305
|
301
|
{
|
306
|
302
|
snd.init();
|
307
|
303
|
printf("Loading %s\n", argv[1]);
|
308
|
|
- ret = snd.add(argv[1], &id, SoundFlagsNone);
|
|
304
|
+ ret = snd.addFile(argv[1], &id, SoundFlagsNone);
|
309
|
305
|
printf("Load returned %i\n", ret);
|
310
|
306
|
printf("Playing %u::%s\n", id, argv[1]);
|
311
|
307
|
snd.play(id);
|
|
@@ -327,7 +323,7 @@ int main(int argc, char* argv[])
|
327
|
323
|
fclose(f);
|
328
|
324
|
|
329
|
325
|
printf("Loading buffer of %s\n", argv[1]);
|
330
|
|
- ret = snd.add(buf, &id, SoundFlagsNone);
|
|
326
|
+ ret = snd.addFile(buf, &id, SoundFlagsNone);
|
331
|
327
|
printf("Load returned %i\n", ret);
|
332
|
328
|
printf("Playing buffer of %u::%s\n", id, argv[1]);
|
333
|
329
|
snd.play(id);
|