Thomas Buck 11 лет назад
Родитель
Сommit
9921974bb2
4 измененных файлов: 76 добавлений и 74 удалений
  1. 5
    5
      Makefile
  2. 0
    2
      include/Sound.h
  3. 0
    67
      src/Sound.cpp
  4. 71
    0
      test/Sound.cpp

+ 5
- 5
Makefile Просмотреть файл

@@ -275,7 +275,7 @@ endif
275 275
 #################################################################
276 276
 # Unit Test builds
277 277
 #################################################################
278
-TEST_FLAGS=-Wall -g -O0 -DDEBUG -lstdc++
278
+TEST_FLAGS=-Wall -g -O0 -DDEBUG -lstdc++ -Iinclude
279 279
 
280 280
 TEST_MAP_TR5=~/projects/Data/models/tombraider/tr5/demo.trc
281 281
 TEST_MAP_TR4=~/projects/Data/models/tombraider/tr4/angkor1.tr4
@@ -303,7 +303,7 @@ TombRaider.test:
303 303
 
304 304
 GLString.test:
305 305
 	mkdir -p $(BUILD_TEST_DIR)
306
-	$(CC) -Wall -Iinclude -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
306
+	$(CC) -Wall -Iinclude -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
307 307
 	$(shell sdl-config --cflags) $(shell sdl-config --libs) \
308 308
 	$(GL_LIBS) $(GL_DEFS) -lm -lstdc++ \
309 309
 	src/Texture.cpp src/mtk_tga.cpp \
@@ -360,9 +360,9 @@ Network.test:
360 360
 
361 361
 Sound.test:
362 362
 	mkdir -p $(BUILD_TEST_DIR)
363
-	$(CC) $(TEST_FLAGS) -DUNIT_TEST_SOUND \
364
-		-DUSING_OPENAL $(AUDIO_LIBS) \
365
-		src/Sound.cpp -o $(BUILD_TEST_DIR)/Sound.test
363
+	$(CC) $(TEST_FLAGS) \
364
+		-DUSING_OPENAL $(AUDIO_LIBS) $(AUDIO_DEFS) \
365
+		src/Sound.cpp test/Sound.cpp -o $(BUILD_TEST_DIR)/Sound.test
366 366
 ifeq ($(UNAME),Darwin)
367 367
 	install_name_tool -change libalut.0.1.0.dylib /opt/local/lib/libalut.0.1.0.dylib $(BUILD_TEST_DIR)/Sound.test
368 368
 endif

+ 0
- 2
include/Sound.h Просмотреть файл

@@ -2,8 +2,6 @@
2 2
  * \file Sound.h
3 3
  * \brief This is the audio manager Header
4 4
  *
5
- * Defining UNIT_TEST_SOUND builds Sound class as a console unit test
6
- *
7 5
  * \author Mongoose
8 6
  * \author xythobuz
9 7
  */

+ 0
- 67
src/Sound.cpp Просмотреть файл

@@ -2,8 +2,6 @@
2 2
  * \file Sound.cpp
3 3
  * \brief This is the audio manager Implementation
4 4
  *
5
- * Defining UNIT_TEST_SOUND builds Sound class as a console unit test
6
- *
7 5
  * \author Mongoose
8 6
  * \author xythobuz
9 7
  */
@@ -290,68 +288,3 @@ void Sound::stop(int source)
290 288
 #endif
291 289
 }
292 290
 
293
-
294
-///////////////////////////////////////////////////////
295
-
296
-
297
-#ifdef UNIT_TEST_SOUND
298
-/*!
299
- * \brief Sound Unit Test
300
- * \param argc Number of arguments. Has to be > 1
301
- * \param argv Argument array. argv[1] will be played as wav file
302
- * \returns always zero
303
- */
304
-int main(int argc, char* argv[])
305
-{
306
-	Sound snd;
307
-	FILE *f;
308
-	unsigned int l;
309
-	unsigned char *buf;
310
-   int id, ret;
311
-
312
-
313
-	if (argc > 1)
314
-	{
315
-		snd.init();
316
-		printf("Loading %s\n", argv[1]);
317
-		ret = snd.addFile(argv[1], &id, snd.SoundFlagsNone);
318
-		printf("Load returned %i\n", ret);
319
-		printf("Playing %u::%s\n", id, argv[1]);
320
-		snd.play(id);
321
-
322
-		printf("Waiting...\n");
323
-		sleep(1);
324
-
325
-		f = fopen(argv[1], "rb");
326
-
327
-		if (f)
328
-		{
329
-			fseek(f, 0, SEEK_END);
330
-			l = ftell(f);
331
-			fseek(f, 0, SEEK_SET);
332
-
333
-			buf = new unsigned char[l];
334
-			fread(buf, l, 1, f);
335
-
336
-			fclose(f);
337
-
338
-			printf("Loading buffer of %s\n", argv[1]);
339
-			ret = snd.addWave(buf, l, &id, snd.SoundFlagsNone);
340
-			printf("Load returned %i\n", ret);
341
-			printf("Playing buffer of %u::%s\n", id, argv[1]);
342
-			snd.play(id);
343
-
344
-			delete [] buf;
345
-			printf("Waiting...\n");
346
-			sleep(1);
347
-		}
348
-	}
349
-	else
350
-	{
351
-		printf("%s filename.wav\n", argv[0]);
352
-	}
353
-
354
-	return 0;
355
-}
356
-#endif
357
-

+ 71
- 0
test/Sound.cpp Просмотреть файл

@@ -0,0 +1,71 @@
1
+/*!
2
+ * \file Sound.cpp
3
+ * \brief This is the audio manager Unit Test
4
+ *
5
+ * \author Mongoose
6
+ * \author xythobuz
7
+ */
8
+#include <stdio.h>
9
+#include <unistd.h>
10
+
11
+#include <Sound.h>
12
+
13
+/*!
14
+ * \brief Sound Unit Test
15
+ * \param argc Number of arguments. Has to be > 1
16
+ * \param argv Argument array. argv[1] will be played as wav file
17
+ * \returns always zero
18
+ */
19
+int main(int argc, char* argv[])
20
+{
21
+	Sound snd;
22
+	FILE *f;
23
+	unsigned int l;
24
+	unsigned char *buf;
25
+   int id, ret;
26
+
27
+
28
+	if (argc > 1)
29
+	{
30
+		snd.init();
31
+		printf("Loading %s\n", argv[1]);
32
+		ret = snd.addFile(argv[1], &id, snd.SoundFlagsNone);
33
+		printf("Load returned %i\n", ret);
34
+		printf("Playing %u::%s\n", id, argv[1]);
35
+		snd.play(id);
36
+
37
+		printf("Waiting...\n");
38
+		sleep(1);
39
+
40
+		f = fopen(argv[1], "rb");
41
+
42
+		if (f)
43
+		{
44
+			fseek(f, 0, SEEK_END);
45
+			l = ftell(f);
46
+			fseek(f, 0, SEEK_SET);
47
+
48
+			buf = new unsigned char[l];
49
+			fread(buf, l, 1, f);
50
+
51
+			fclose(f);
52
+
53
+			printf("Loading buffer of %s\n", argv[1]);
54
+			ret = snd.addWave(buf, l, &id, snd.SoundFlagsNone);
55
+			printf("Load returned %i\n", ret);
56
+			printf("Playing buffer of %u::%s\n", id, argv[1]);
57
+			snd.play(id);
58
+
59
+			delete [] buf;
60
+			printf("Waiting...\n");
61
+			sleep(1);
62
+		}
63
+	}
64
+	else
65
+	{
66
+		printf("%s filename.wav\n", argv[0]);
67
+	}
68
+
69
+	return 0;
70
+}
71
+

Загрузка…
Отмена
Сохранить