diff options
author | Matthew Hoops | 2012-06-09 18:09:54 -0400 |
---|---|---|
committer | Matthew Hoops | 2012-06-09 18:09:54 -0400 |
commit | 9b3df4de21d96324a2b9fcf8a16bf133188afccd (patch) | |
tree | 70392c01314bd497a40923af2b1c38a0e63782e8 /engines/tony | |
parent | 060449042a532e6cd7319ea36376021d76dde470 (diff) | |
download | scummvm-rg350-9b3df4de21d96324a2b9fcf8a16bf133188afccd.tar.gz scummvm-rg350-9b3df4de21d96324a2b9fcf8a16bf133188afccd.tar.bz2 scummvm-rg350-9b3df4de21d96324a2b9fcf8a16bf133188afccd.zip |
TONY: Rework the way wave files are loaded
We'll let our own sound code take care of the RIFF header
Diffstat (limited to 'engines/tony')
-rw-r--r-- | engines/tony/loc.cpp | 24 | ||||
-rw-r--r-- | engines/tony/sound.cpp | 10 | ||||
-rw-r--r-- | engines/tony/sound.h | 5 | ||||
-rw-r--r-- | engines/tony/tony.cpp | 4 | ||||
-rw-r--r-- | engines/tony/tony.h | 2 |
5 files changed, 15 insertions, 30 deletions
diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index 61271d7f39..ac238193e0 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -26,6 +26,7 @@ * Copyright (c) 1997-2003 Nayma Software */ +#include "common/memstream.h" #include "common/scummsys.h" #include "tony/mpal/mpalutils.h" #include "tony/adv.h" @@ -394,34 +395,21 @@ RMDataStream &operator>>(RMDataStream &ds, RMSfx &sfx) { } void RMSfx::readFromStream(RMDataStream &ds, bool bLOX) { - char id[4]; int size; - byte *raw; // sfx name ds >> _name; ds >> size; - // Upload the sound effect identifier from the buffer - ds.read(id, 4); - - // Ensure it's a RIFF - assert(id[0] == 'R' && id[1] == 'I' && id[2] == 'F' && id[3] == 'F'); - - // Read the size - ds >> size; - - // Read the raw WAV data - raw = new byte[size]; - ds.read(raw, size); + // Read the entire buffer into a MemoryReadStream + byte *buffer = (byte *)malloc(size); + ds.read(buffer, size); + Common::SeekableReadStream *stream = new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES); // Create the sound effect - _fx = _vm->createSFX(raw); + _fx = _vm->createSFX(stream); _fx->SetLoop(false); - - // Close the read buffer which is no longer needed - delete[] raw; } RMSfx::RMSfx() { diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 6d9eaf350b..df633e3be2 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -1062,7 +1062,7 @@ void FPSFX::Release() { /****************************************************************************\ * -* Function: bool LoadFile(byte *lpBuf); +* Function: bool loadWave(Common::SeekableReadStream *stream); * * Description: Apre un file di effetto sonoro e lo carica. * @@ -1074,7 +1074,7 @@ void FPSFX::Release() { * \****************************************************************************/ -bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { +bool FPSFX::loadWave(Common::SeekableReadStream *stream) { #ifdef REFACTOR_ME static PCMWAVEFORMAT pcmwf; static DSBUFFERDESC dsbdesc; @@ -1096,10 +1096,6 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { if (!bSoundSupported) return true; - /* Nel buffer troviamo un file WAV completo, almeno per ora */ - if (dwCodec != FPCODEC_WAV) - return false; - if (lpBuf[0] != 'W' || lpBuf[1] != 'A' || lpBuf[2] != 'V' || lpBuf[3] != 'E') return false; if (lpBuf[4] != 'f' || lpBuf[5] != 'm' || lpBuf[6] != 't' || lpBuf[7] != ' ') @@ -1158,6 +1154,8 @@ bool FPSFX::LoadFile(byte *lpBuf, uint32 dwCodec) { bFileLoaded = true; #endif + + delete stream; // Just so we don't leak it return true; } diff --git a/engines/tony/sound.h b/engines/tony/sound.h index 7defeb1149..8be1fb42f5 100644 --- a/engines/tony/sound.h +++ b/engines/tony/sound.h @@ -50,8 +50,7 @@ class CODEC; enum CODECS { FPCODEC_RAW, - FPCODEC_ADPCM, - FPCODEC_WAV + FPCODEC_ADPCM }; @@ -288,7 +287,7 @@ public: \****************************************************************************/ bool LoadFile(const char *lpszFileName, uint32 dwCodec = FPCODEC_RAW); - bool LoadFile(byte *lpBuf, uint32 dwCodec); + bool loadWave(Common::SeekableReadStream *stream); bool LoadVoiceFromVDB(Common::File &vdbFP); diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index a66e7b0684..0c0bcf331a 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -332,11 +332,11 @@ void TonyEngine::preloadSFX(int nChannel, const char *fn) { _sfx[nChannel]->LoadFile(fn, FPCODEC_ADPCM); } -FPSFX *TonyEngine::createSFX(byte *buf) { +FPSFX *TonyEngine::createSFX(Common::SeekableReadStream *stream) { FPSFX *sfx; _theSound.CreateSfx(&sfx); - sfx->LoadFile(buf, FPCODEC_WAV); + sfx->loadWave(stream); return sfx; } diff --git a/engines/tony/tony.h b/engines/tony/tony.h index 68730fa91b..cee15d07a4 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -188,7 +188,7 @@ public: void playUtilSFX(int nSfx, int nFX = 0); void stopUtilSFX(int nSfx); - FPSFX *createSFX(byte *buf); + FPSFX *createSFX(Common::SeekableReadStream *stream); void preloadSFX(int nSfx, const char *fn); void unloadAllSFX(void); |