diff options
author | Max Horn | 2005-01-09 15:57:38 +0000 |
---|---|---|
committer | Max Horn | 2005-01-09 15:57:38 +0000 |
commit | 7df70de2b1e070ed6474f81f9da782bc22f21bb1 (patch) | |
tree | 9be433339c87291a98fee6d968bfd794b1c12169 | |
parent | 9cea3d393f0c3657f3caef72a13dce5594581bdd (diff) | |
download | scummvm-rg350-7df70de2b1e070ed6474f81f9da782bc22f21bb1.tar.gz scummvm-rg350-7df70de2b1e070ed6474f81f9da782bc22f21bb1.tar.bz2 scummvm-rg350-7df70de2b1e070ed6474f81f9da782bc22f21bb1.zip |
Mark some places which probably should use loadWAVFromStream(); maybe some of the engine maintainers can look into using it
svn-id: r16503
-rw-r--r-- | saga/sndres.cpp | 10 | ||||
-rw-r--r-- | simon/sound.cpp | 8 | ||||
-rw-r--r-- | sword1/music.cpp | 10 | ||||
-rw-r--r-- | sword1/sound.cpp | 14 | ||||
-rw-r--r-- | sword2/driver/d_sound.cpp | 11 |
5 files changed, 51 insertions, 2 deletions
diff --git a/saga/sndres.cpp b/saga/sndres.cpp index f51250ae22..9757e3217d 100644 --- a/saga/sndres.cpp +++ b/saga/sndres.cpp @@ -34,6 +34,7 @@ #include "common/file.h" #include "sound/voc.h" +#include "sound/wave.h" namespace Saga { @@ -200,6 +201,15 @@ int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, SOUNDBUFFER *snd_buf int SndRes::loadWavSound(byte *snd_res, size_t snd_res_len, SOUNDBUFFER *snd_buf_i) { // TODO: This function should, perhaps, be made more robust. + // TODO: use loadWAVFromStream to load the WAVE data! + /* + int rate, size; + bye flags; + bool isValidWAV; + Common::MemoryReadStream stream(snd_res, snd_res_len); + isValidWAV = loadWAVFromStream(stream, size, rate, flags); + */ + MemoryReadStreamEndian readS(snd_res, snd_res_len, IS_BIG_ENDIAN); byte buf[4]; diff --git a/simon/sound.cpp b/simon/sound.cpp index db67ae58d3..9e4f357628 100644 --- a/simon/sound.cpp +++ b/simon/sound.cpp @@ -28,6 +28,7 @@ #include "sound/mp3.h" #include "sound/voc.h" #include "sound/vorbis.h" +#include "sound/wave.h" namespace Simon { @@ -152,6 +153,13 @@ void WavSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) { _file->seek(_offsets[sound], SEEK_SET); + // TODO: use loadWAVFromStream to load the WAVE data! + /* + int rate, size; + bye flags; + isValidWAV = loadWAVFromStream(*_file, size, rate, flags); + */ + if (_file->read(&wave_hdr, sizeof(wave_hdr)) != sizeof(wave_hdr) || wave_hdr.riff != MKID('RIFF') || wave_hdr.wave != MKID('WAVE') || wave_hdr.fmt != MKID('fmt ') || READ_LE_UINT16(&wave_hdr.format_tag) != 1 diff --git a/sword1/music.cpp b/sword1/music.cpp index 4eb2ddf403..c2b21409a3 100644 --- a/sword1/music.cpp +++ b/sword1/music.cpp @@ -26,6 +26,7 @@ #include "common/file.h" #include "sound/mp3.h" #include "sound/vorbis.h" +#include "sound/wave.h" #define SMP_BUFSIZE 8192 @@ -43,6 +44,15 @@ WaveAudioStream::WaveAudioStream(File *source, uint32 pSize) { _sampleBuf = (uint8*)malloc(SMP_BUFSIZE); _sourceFile->incRef(); if (_sourceFile->isOpen()) { + // TODO: use loadWAVFromStream to load the WAVE data! + /* + int rate, size; + bye flags; + const uint32 initialPos = _sourceFile->pos(); + isValidWAV = loadWAVFromStream(*_sourceFile, size, rate, flags); + */ + + _sourceFile->read(wavHeader, WAVEHEADERSIZE); _isStereo = (READ_LE_UINT16(wavHeader + 0x16) == 2); _rate = READ_LE_UINT16(wavHeader + 0x18); diff --git a/sword1/sound.cpp b/sword1/sound.cpp index a97e57071b..6c0e0c3e8f 100644 --- a/sword1/sound.cpp +++ b/sword1/sound.cpp @@ -28,6 +28,7 @@ #include "sound/mp3.h" #include "sound/vorbis.h" +#include "sound/wave.h" namespace Sword1 { @@ -221,6 +222,15 @@ int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) { _cowFile.seek(index); _cowFile.read(fBuf, cSize); uint32 headerPos = 0; + + // TODO: use loadWAVFromStream to load the WAVE data! + /* + int rate, size; + bye flags; + Common::MemoryReadStream stream(fBuf, cSize); + isValidWAV = loadWAVFromStream(stream, size, rate, flags); + */ + while ((READ_BE_UINT32(fBuf + headerPos) != 'data') && (headerPos < 100)) headerPos++; if (headerPos < 100) { @@ -235,9 +245,9 @@ int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) { if (READ_LE_UINT16(fBuf + headerPos) == 1) { resSize = READ_LE_UINT16(fBuf + headerPos + 2); resSize |= READ_LE_UINT16(fBuf + headerPos + 6) << 16; - resSize >>= 1; } else - resSize = READ_LE_UINT32(fBuf + headerPos + 2) >> 1; + resSize = READ_LE_UINT32(fBuf + headerPos + 2); + resSize >>= 1; } assert(!(headerPos & 1)); int16 *srcData = (int16*)fBuf; diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp index cb536de3df..495fcf24b0 100644 --- a/sword2/driver/d_sound.cpp +++ b/sword2/driver/d_sound.cpp @@ -29,6 +29,7 @@ #include "sound/vorbis.h" #include "sound/flac.h" #include "sound/rate.h" +#include "sound/wave.h" #include "sword2/sword2.h" #include "sword2/resman.h" #include "sword2/driver/d_draw.h" @@ -1128,6 +1129,16 @@ int32 Sound::playFx(int32 id, byte *data, uint8 vol, int8 pan, uint8 type) { WavInfo wavInfo; + // TODO: use loadWAVFromStream to load the WAVE data! + /* + int rate, size; + bye flags; + // FIXME: Instead of passing an arbitrary large size for the memory stream + // here, we should instead determine the real size of the memory area. + Common::MemoryReadStream stream(data, 10000000); + isValidWAV = loadWAVFromStream(stream, size, rate, flags); + */ + if (!getWavInfo(data, &wavInfo)) { warning("playFx: Not a valid WAV file"); return RDERR_INVALIDWAV; |