2018-11-11 18:42:25 +00:00
|
|
|
Downloaded from https://salsa.debian.org/games-team/teeworlds/raw/master/debian/patches/new-wavpack.patch.
|
2017-04-12 20:27:16 +00:00
|
|
|
|
2018-11-11 18:42:25 +00:00
|
|
|
From: Markus Koschany <apo@debian.org>
|
|
|
|
Date: Thu, 25 Oct 2018 20:52:27 +0200
|
|
|
|
Subject: new-wavpack
|
2017-04-12 20:27:16 +00:00
|
|
|
|
2018-11-11 18:42:25 +00:00
|
|
|
Make wavpack compatible with Debian's version.
|
|
|
|
---
|
|
|
|
src/engine/client/sound.cpp | 33 +++++++++++++++------------------
|
|
|
|
src/engine/client/sound.h | 4 ----
|
|
|
|
2 files changed, 15 insertions(+), 22 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/src/engine/client/sound.cpp b/src/engine/client/sound.cpp
|
|
|
|
index 048ec24..80de3c5 100644
|
2017-04-12 20:27:16 +00:00
|
|
|
--- a/src/engine/client/sound.cpp
|
|
|
|
+++ b/src/engine/client/sound.cpp
|
2018-11-11 18:42:25 +00:00
|
|
|
@@ -325,10 +325,6 @@ void CSound::RateConvert(int SampleID)
|
2017-04-12 20:27:16 +00:00
|
|
|
pSample->m_NumFrames = NumFrames;
|
|
|
|
}
|
|
|
|
|
|
|
|
-int CSound::ReadData(void *pBuffer, int Size)
|
|
|
|
-{
|
|
|
|
- return io_read(ms_File, pBuffer, Size);
|
|
|
|
-}
|
2018-11-11 18:42:25 +00:00
|
|
|
|
|
|
|
ISound::CSampleHandle CSound::LoadWV(const char *pFilename)
|
2017-04-12 20:27:16 +00:00
|
|
|
{
|
2018-11-11 18:42:25 +00:00
|
|
|
@@ -336,6 +332,8 @@ ISound::CSampleHandle CSound::LoadWV(const char *pFilename)
|
2017-04-12 20:27:16 +00:00
|
|
|
int SampleID = -1;
|
|
|
|
char aError[100];
|
|
|
|
WavpackContext *pContext;
|
|
|
|
+ char aWholePath[1024];
|
|
|
|
+ IOHANDLE File;
|
|
|
|
|
|
|
|
// don't waste memory on sound when we are stress testing
|
|
|
|
if(g_Config.m_DbgStress)
|
2018-11-11 18:42:25 +00:00
|
|
|
@@ -349,25 +347,29 @@ ISound::CSampleHandle CSound::LoadWV(const char *pFilename)
|
|
|
|
return CSampleHandle();
|
2017-04-12 20:27:16 +00:00
|
|
|
|
2018-11-11 18:42:25 +00:00
|
|
|
lock_wait(m_SoundLock);
|
2017-04-12 20:27:16 +00:00
|
|
|
- ms_File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
|
|
|
|
- if(!ms_File)
|
|
|
|
+ File = m_pStorage->OpenFile(pFilename, IOFLAG_READ, IStorage::TYPE_ALL, aWholePath, sizeof(aWholePath));
|
|
|
|
+ if(!File)
|
|
|
|
{
|
|
|
|
dbg_msg("sound/wv", "failed to open file. filename='%s'", pFilename);
|
2018-11-11 18:42:25 +00:00
|
|
|
lock_unlock(m_SoundLock);
|
|
|
|
return CSampleHandle();
|
2017-04-12 20:27:16 +00:00
|
|
|
}
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ io_close(File);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
SampleID = AllocID();
|
|
|
|
if(SampleID < 0)
|
2018-11-11 18:42:25 +00:00
|
|
|
{
|
|
|
|
- io_close(ms_File);
|
|
|
|
- ms_File = 0;
|
|
|
|
+ io_close(File);
|
|
|
|
+ File = 0;
|
|
|
|
lock_unlock(m_SoundLock);
|
|
|
|
return CSampleHandle();
|
|
|
|
}
|
2017-04-12 20:27:16 +00:00
|
|
|
pSample = &m_aSamples[SampleID];
|
|
|
|
|
|
|
|
- pContext = WavpackOpenFileInput(ReadData, aError);
|
|
|
|
+ pContext = WavpackOpenFileInput(aWholePath, aError, OPEN_2CH_MAX, 0);
|
|
|
|
if (pContext)
|
|
|
|
{
|
|
|
|
int m_aSamples = WavpackGetNumSamples(pContext);
|
2018-11-11 18:42:25 +00:00
|
|
|
@@ -385,8 +387,8 @@ ISound::CSampleHandle CSound::LoadWV(const char *pFilename)
|
|
|
|
if(pSample->m_Channels > 2)
|
|
|
|
{
|
|
|
|
dbg_msg("sound/wv", "file is not mono or stereo. filename='%s'", pFilename);
|
|
|
|
- io_close(ms_File);
|
|
|
|
- ms_File = 0;
|
|
|
|
+ io_close(File);
|
|
|
|
+ File = 0;
|
|
|
|
lock_unlock(m_SoundLock);
|
|
|
|
return CSampleHandle();
|
|
|
|
}
|
|
|
|
@@ -401,8 +403,8 @@ ISound::CSampleHandle CSound::LoadWV(const char *pFilename)
|
|
|
|
if(BitsPerSample != 16)
|
|
|
|
{
|
|
|
|
dbg_msg("sound/wv", "bps is %d, not 16, filname='%s'", BitsPerSample, pFilename);
|
|
|
|
- io_close(ms_File);
|
|
|
|
- ms_File = 0;
|
|
|
|
+ io_close(File);
|
|
|
|
+ File = 0;
|
|
|
|
lock_unlock(m_SoundLock);
|
|
|
|
return CSampleHandle();
|
|
|
|
}
|
|
|
|
@@ -429,9 +431,6 @@ ISound::CSampleHandle CSound::LoadWV(const char *pFilename)
|
2017-04-12 20:27:16 +00:00
|
|
|
dbg_msg("sound/wv", "failed to open %s: %s", pFilename, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
- io_close(ms_File);
|
|
|
|
- ms_File = NULL;
|
|
|
|
-
|
|
|
|
if(g_Config.m_Debug)
|
|
|
|
dbg_msg("sound/wv", "loaded %s", pFilename);
|
|
|
|
|
2018-11-11 18:42:25 +00:00
|
|
|
@@ -560,7 +559,5 @@ bool CSound::IsPlaying(CSampleHandle SampleID)
|
|
|
|
return Ret;
|
2017-04-12 20:27:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-IOHANDLE CSound::ms_File = 0;
|
|
|
|
-
|
|
|
|
IEngineSound *CreateEngineSound() { return new CSound; }
|
|
|
|
|
2018-11-11 18:42:25 +00:00
|
|
|
diff --git a/src/engine/client/sound.h b/src/engine/client/sound.h
|
|
|
|
index ff357c0..cec2cde 100644
|
2017-04-12 20:27:16 +00:00
|
|
|
--- a/src/engine/client/sound.h
|
|
|
|
+++ b/src/engine/client/sound.h
|
|
|
|
@@ -21,10 +21,6 @@ public:
|
|
|
|
|
|
|
|
static void RateConvert(int SampleID);
|
|
|
|
|
|
|
|
- // TODO: Refactor: clean this mess up
|
|
|
|
- static IOHANDLE ms_File;
|
|
|
|
- static int ReadData(void *pBuffer, int Size);
|
|
|
|
-
|
|
|
|
virtual bool IsSoundEnabled() { return m_SoundEnabled != 0; }
|
|
|
|
|
2018-11-11 18:42:25 +00:00
|
|
|
virtual CSampleHandle LoadWV(const char *pFilename);
|