Remove unmaintained packages - #557728 @bgo
[moonrise.git] / games-action / teeworlds / files / teeworlds-0.6.0-002-fixed-wavpack-sound-loading.patch
blob206bc6a6e7ba24a513c9b737d4005c3087c38567
1 From 5a5322491704c14f5aed72148db6b134484cedec Mon Sep 17 00:00:00 2001
2 From: xalduin <xalduin@gmail.com>
3 Date: Sat, 12 Feb 2011 23:58:55 -0500
4 Subject: [PATCH 2/3] Fixed wavpack sound loading
6 ---
7 src/engine/client/sound.cpp | 56 ++++++++++++++++++++++++++++++++++++++----
8 1 files changed, 50 insertions(+), 6 deletions(-)
10 diff --git a/src/engine/client/sound.cpp b/src/engine/client/sound.cpp
11 index e38ad32..6101602 100644
12 --- a/src/engine/client/sound.cpp
13 +++ b/src/engine/client/sound.cpp
14 @@ -49,6 +49,54 @@ struct CVoice
15 int m_X, m_Y;
16 } ;
18 +#ifdef WAVPACK_H
19 +static int32_t ReadBytes(void *pFile, void *pBuffer, int32_t Size)
21 + return (int32_t)io_read((IOHANDLE)pFile, pBuffer, Size);
23 +static uint32_t GetPos(void *pFile)
25 + return (uint32_t)io_tell((IOHANDLE)pFile);
27 +static int SetPosAbs(void *pFile, uint32_t Offset)
29 + return io_seek((IOHANDLE)pFile, Offset, IOSEEK_START);
31 +static int SetPosRel(void *pFile, int32_t Offset, int Mode)
33 + switch(Mode)
34 + {
35 + case SEEK_SET:
36 + Mode = IOSEEK_START;
37 + break;
38 + case SEEK_CUR:
39 + Mode = IOSEEK_CUR;
40 + break;
41 + case SEEK_END:
42 + Mode = IOSEEK_END;
43 + }
44 + return io_seek((IOHANDLE)pFile, Offset, Mode);
47 +//TODO: Fix if 'real' functionality is needed by the wavpack header
48 +static int PushBackByte(void *pFile, int Char)
50 + return io_seek((IOHANDLE)pFile, -1, IOSEEK_CUR);
52 +static uint32_t GetLength(void *pFile)
54 + return (uint32_t)io_length((IOHANDLE)pFile);
56 +// Essentially assuming this to always be true, should fix if this isn't the case
57 +static int CanSeek(void *pFile)
59 + return pFile != NULL;
61 +static WavpackStreamReader CWavpackReader = {
62 + ReadBytes, GetPos, SetPosAbs, SetPosRel, PushBackByte, GetLength, CanSeek, 0
63 +};
64 +#endif
66 static CSample m_aSamples[NUM_SAMPLES] = { {0} };
67 static CVoice m_aVoices[NUM_VOICES] = { {0} };
68 static CChannel m_aChannels[NUM_CHANNELS] = { {255, 0} };
69 @@ -328,14 +376,12 @@ int CSound::LoadWV(const char *pFilename)
70 if(!m_pStorage)
71 return -1;
73 - #ifndef WAVPACK_H
74 ms_File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
75 if(!ms_File)
77 dbg_msg("sound/wv", "failed to open file. filename='%s'", pFilename);
78 return -1;
80 - #endif
82 SampleID = AllocID();
83 if(SampleID < 0)
84 @@ -345,7 +391,7 @@ int CSound::LoadWV(const char *pFilename)
85 #ifndef WAVPACK_H
86 pContext = WavpackOpenFileInput(ReadData, aError);
87 #else
88 - pContext = WavpackOpenFileInput(pFilename, aError, 0, 0);
89 + pContext = WavpackOpenFileInputEx(&CWavpackReader, ms_File, 0, aError, 0, 0);
90 #endif
91 if (pContext)
93 @@ -398,13 +444,11 @@ int CSound::LoadWV(const char *pFilename)
95 else
97 - dbg_msg("sound/wv", "failed to open %s: %s", pFilename, aError);
98 + dbg_msg("sound/wv", "failed to open '%s': %s", pFilename, aError);
101 - #ifndef WAVPACK_H
102 io_close(ms_File);
103 ms_File = NULL;
104 - #endif
106 if(g_Config.m_Debug)
107 dbg_msg("sound/wv", "loaded %s", pFilename);
109 1.7.3.4