diff options
author | Travis Howell | 2006-10-19 05:37:22 +0000 |
---|---|---|
committer | Travis Howell | 2006-10-19 05:37:22 +0000 |
commit | 8c72861de463e0db36b234750fb19904e5f04d3b (patch) | |
tree | 9b8139009ee2510033fc3392f2daab1d8b737e35 /sound | |
parent | ed3c6871f967ab15321df14ca6a026e08d96fae1 (diff) | |
download | scummvm-rg350-8c72861de463e0db36b234750fb19904e5f04d3b.tar.gz scummvm-rg350-8c72861de463e0db36b234750fb19904e5f04d3b.tar.bz2 scummvm-rg350-8c72861de463e0db36b234750fb19904e5f04d3b.zip |
Add option to load a module via stream
svn-id: r24387
Diffstat (limited to 'sound')
-rw-r--r-- | sound/mods/module.cpp | 10 | ||||
-rw-r--r-- | sound/mods/module.h | 3 | ||||
-rw-r--r-- | sound/mods/protracker.cpp | 8 | ||||
-rw-r--r-- | sound/mods/protracker.h | 1 |
4 files changed, 20 insertions, 2 deletions
diff --git a/sound/mods/module.cpp b/sound/mods/module.cpp index f7f343fde5..4c20c3a741 100644 --- a/sound/mods/module.cpp +++ b/sound/mods/module.cpp @@ -46,6 +46,14 @@ bool Module::load(const char *fn) { Common::MemoryReadStream st(buf, bufsz); + bool result = loadStream(st); + + delete[] buf; + + return result; +} + +bool Module::loadStream(Common::SeekableReadStream &st) { st.read(songname, 20); songname[0] = '\0'; @@ -155,8 +163,6 @@ bool Module::load(const char *fn) { assert(st.eos()); - delete[] buf; - return true; } diff --git a/sound/mods/module.h b/sound/mods/module.h index f16d3eb4f4..4073d5d4ec 100644 --- a/sound/mods/module.h +++ b/sound/mods/module.h @@ -24,6 +24,8 @@ #ifndef SOUND_MODS_MODULE_H #define SOUND_MODS_MODULE_H +#include "common/file.h" + namespace Modules { /* @@ -68,6 +70,7 @@ public: ~Module(); bool load(const char *fn); + bool loadStream(Common::SeekableReadStream &st); }; } // End of namespace Modules diff --git a/sound/mods/protracker.cpp b/sound/mods/protracker.cpp index 2a308407e4..8948ae4c20 100644 --- a/sound/mods/protracker.cpp +++ b/sound/mods/protracker.cpp @@ -78,6 +78,14 @@ void ProtrackerPlayer::loadModule(const char *fn) { _module->load(fn); } +void ProtrackerPlayer::loadModuleStream(Common::SeekableReadStream &fs) { + if (_module) + delete _module; + + _module = new Module(); + _module->loadStream(fs); +} + void ProtrackerPlayer::generateSound() { _generatedSamplesOverflow += 5.0 * 44100.0 / (2.0 * _bpm); int samples = (int)floor(_generatedSamplesOverflow); diff --git a/sound/mods/protracker.h b/sound/mods/protracker.h index 070f972d4a..c6511e8a47 100644 --- a/sound/mods/protracker.h +++ b/sound/mods/protracker.h @@ -139,6 +139,7 @@ public: void stop(); void loadModule(const char *fn); + void loadModuleStream(Common::SeekableReadStream &fs); void mix(byte *buf, int len); |