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
|
commit 7202b142891ee10771af9f1f3063664d75a38bbc
Author: hasufell <hasufell@gentoo.org>
Date: Thu Sep 5 12:28:30 2013 +0200
Use system wavpack. Based on patch from Gentoo Bugzilla
From: Azamat H. Hackimov <azamat.hackimov@gmail.com>
https://bugs.gentoo.org/show_bug.cgi?id=363395
diff --git a/bam.lua b/bam.lua
index 11ac7b9..35c1d8d 100644
--- a/bam.lua
+++ b/bam.lua
@@ -11,6 +11,7 @@ config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-p
config:Add(OptTestCompileC("minmacosxsdk", "int main(){return 0;}", "-mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk"))
config:Add(OptTestCompileC("macosxppc", "int main(){return 0;}", "-arch ppc"))
config:Add(OptLibrary("zlib", "zlib.h", false))
+config:Add(OptLibrary("wavpack", "wavpack/wavpack.h", false))
config:Add(SDL.OptFind("sdl", true))
config:Add(FreeType.OptFind("freetype", true))
config:Finalize("config.lua")
@@ -187,7 +188,7 @@ function build(settings)
end
-- compile zlib if needed
- if config.zlib.value == 1 then
+ if config.zlib.value == true then
settings.link.libs:Add("z")
if config.zlib.include_path then
settings.cc.includes:Add(config.zlib.include_path)
@@ -198,8 +199,18 @@ function build(settings)
settings.cc.includes:Add("src/engine/external/zlib")
end
+ if config.wavpack.value == true then
+ settings.link.libs:Add("wavpack")
+ if config.wavpack.include_path then
+ settings.cc.includes:Add(config.wavpack.include_path)
+ end
+ wavpack = {}
+ else
+ wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c"))
+ settings.cc.includes:Add("src/engine/external/") --The header is wavpack/wavpack.h so include the external folder
+ end
+
-- build the small libraries
- wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c"))
pnglite = Compile(settings, Collect("src/engine/external/pnglite/*.c"))
-- build game components
diff --git a/src/engine/client/sound.cpp b/src/engine/client/sound.cpp
index 343fa2e..e32cac9 100644
--- a/src/engine/client/sound.cpp
+++ b/src/engine/client/sound.cpp
@@ -13,7 +13,7 @@
#include "sound.h"
extern "C" { // wavpack
- #include <engine/external/wavpack/wavpack.h>
+ #include <wavpack/wavpack.h>
}
#include <math.h>
@@ -351,19 +351,25 @@ int CSound::LoadWV(const char *pFilename)
if(!m_pStorage)
return -1;
+ #ifndef WAVPACK_H
ms_File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
if(!ms_File)
{
dbg_msg("sound/wv", "failed to open file. filename='%s'", pFilename);
return -1;
}
+ #endif
SampleID = AllocID();
if(SampleID < 0)
return -1;
pSample = &m_aSamples[SampleID];
+ #ifndef WAVPACK_H
pContext = WavpackOpenFileInput(ReadData, aError);
+ #else
+ pContext = WavpackOpenFileInput(pFilename, aError, 0, 0);
+ #endif
if (pContext)
{
int m_aSamples = WavpackGetNumSamples(pContext);
@@ -419,8 +425,10 @@ int CSound::LoadWV(const char *pFilename)
dbg_msg("sound/wv", "failed to open %s: %s", pFilename, aError);
}
+ #ifndef WAVPACK_H
io_close(ms_File);
ms_File = NULL;
+ #endif
if(g_Config.m_Debug)
dbg_msg("sound/wv", "loaded %s", pFilename);
|