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
102
103
|
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
---
bam.lua | 15 +++++++++++++--
src/engine/client/sound.cpp | 10 +++++++++-
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/bam.lua b/bam.lua
index 5699251..ce24cff 100644
--- a/bam.lua
+++ b/bam.lua
@@ -9,6 +9,7 @@ config = NewConfig()
config:Add(OptCCompiler("compiler"))
config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all"))
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")
@@ -165,7 +166,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)
@@ -176,8 +177,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 c2ca91f..f356e34 100644
--- a/src/engine/client/sound.cpp
+++ b/src/engine/client/sound.cpp
@@ -10,7 +10,7 @@
#include "sound.h"
extern "C" { // wavpack
- #include <engine/external/wavpack/wavpack.h>
+ #include <wavpack/wavpack.h>
}
#include <math.h>
@@ -333,19 +333,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);
@@ -401,8 +407,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);
|