gnu: Add teeworlds.
[jackhill/guix/guix.git] / gnu / packages / patches / teeworlds-use-latest-wavpack.patch
1 Downloaded from https://anonscm.debian.org/cgit/pkg-games/teeworlds.git/plain/debian/patches/new-wavpack.patch.
2
3 This patch lets us build teeworlds with wavpack 5.1.0.
4
5 --- a/src/engine/client/sound.cpp
6 +++ b/src/engine/client/sound.cpp
7 @@ -328,17 +328,14 @@ void CSound::RateConvert(int SampleID)
8 pSample->m_NumFrames = NumFrames;
9 }
10
11 -int CSound::ReadData(void *pBuffer, int Size)
12 -{
13 - return io_read(ms_File, pBuffer, Size);
14 -}
15 -
16 int CSound::LoadWV(const char *pFilename)
17 {
18 CSample *pSample;
19 int SampleID = -1;
20 char aError[100];
21 WavpackContext *pContext;
22 + char aWholePath[1024];
23 + IOHANDLE File;
24
25 // don't waste memory on sound when we are stress testing
26 if(g_Config.m_DbgStress)
27 @@ -351,19 +348,23 @@ int CSound::LoadWV(const char *pFilename
28 if(!m_pStorage)
29 return -1;
30
31 - ms_File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
32 - if(!ms_File)
33 + File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL, aWholePath, sizeof(aWholePath));
34 + if(!File)
35 {
36 dbg_msg("sound/wv", "failed to open file. filename='%s'", pFilename);
37 return -1;
38 }
39 + else
40 + {
41 + io_close(File);
42 + }
43
44 SampleID = AllocID();
45 if(SampleID < 0)
46 return -1;
47 pSample = &m_aSamples[SampleID];
48
49 - pContext = WavpackOpenFileInput(ReadData, aError);
50 + pContext = WavpackOpenFileInput(aWholePath, aError, OPEN_2CH_MAX, 0);
51 if (pContext)
52 {
53 int m_aSamples = WavpackGetNumSamples(pContext);
54 @@ -419,9 +420,6 @@ int CSound::LoadWV(const char *pFilename
55 dbg_msg("sound/wv", "failed to open %s: %s", pFilename, aError);
56 }
57
58 - io_close(ms_File);
59 - ms_File = NULL;
60 -
61 if(g_Config.m_Debug)
62 dbg_msg("sound/wv", "loaded %s", pFilename);
63
64 @@ -527,7 +525,5 @@ void CSound::StopAll()
65 lock_unlock(m_SoundLock);
66 }
67
68 -IOHANDLE CSound::ms_File = 0;
69 -
70 IEngineSound *CreateEngineSound() { return new CSound; }
71
72 --- a/src/engine/client/sound.h
73 +++ b/src/engine/client/sound.h
74 @@ -21,10 +21,6 @@ public:
75
76 static void RateConvert(int SampleID);
77
78 - // TODO: Refactor: clean this mess up
79 - static IOHANDLE ms_File;
80 - static int ReadData(void *pBuffer, int Size);
81 -
82 virtual bool IsSoundEnabled() { return m_SoundEnabled != 0; }
83
84 virtual int LoadWV(const char *pFilename);