diff options
-rw-r--r-- | engines/supernova/resman.cpp | 20 | ||||
-rw-r--r-- | engines/supernova/resman.h | 14 |
2 files changed, 18 insertions, 16 deletions
diff --git a/engines/supernova/resman.cpp b/engines/supernova/resman.cpp index 9bfede8782..aed4f18374 100644 --- a/engines/supernova/resman.cpp +++ b/engines/supernova/resman.cpp @@ -99,8 +99,6 @@ ResourceManager::ResourceManager() } ResourceManager::~ResourceManager() { - delete _musicIntro; - delete _musicOutro; for (int i = 0; i < kAudioNumSamples; ++i) delete _soundSamples[i]; for (int i = 0; i < kNumImageFiles; ++i) @@ -140,14 +138,8 @@ void ResourceManager::initSoundFiles() { streamFlag, DisposeAfterUse::YES); } - Common::MemoryReadStream *music; - music = convertToMod("msn_data.052"); - _musicIntro = Audio::makeProtrackerStream(music); - delete music; - - music = convertToMod("msn_data.049"); - _musicOutro = Audio::makeProtrackerStream(music); - delete music; + _musicIntroBuffer.reset(convertToMod("msn_data.052")); + _musicOutroBuffer.reset(convertToMod("msn_data.049")); } void ResourceManager::initGraphics() { @@ -192,12 +184,14 @@ Audio::SeekableAudioStream *ResourceManager::getSoundStream(AudioId index) { return stream; } -Audio::AudioStream *ResourceManager::getSoundStream(MusicId index) const { +Audio::AudioStream *ResourceManager::getSoundStream(MusicId index) { switch (index) { case kMusicIntro: - return _musicIntro; + _musicIntro.reset(Audio::makeProtrackerStream(_musicIntroBuffer.get())); + return _musicIntro.get(); case kMusicOutro: - return _musicOutro; + _musicOutro.reset(Audio::makeProtrackerStream(_musicOutroBuffer.get())); + return _musicOutro.get(); default: error("Invalid music constant in playAudio()"); } diff --git a/engines/supernova/resman.h b/engines/supernova/resman.h index cca38b2f74..12304abf5e 100644 --- a/engines/supernova/resman.h +++ b/engines/supernova/resman.h @@ -23,12 +23,18 @@ #ifndef SUPERNOVA_RESOURCES_H #define SUPERNOVA_RESOURCES_H +#include "common/ptr.h" + #include "supernova/sound.h" namespace Audio { class SeekableAudioStream; } +namespace Common { +class MemoryReadStream; +} + namespace Supernova { class MSNImage; @@ -48,7 +54,7 @@ public: ~ResourceManager(); Audio::SeekableAudioStream *getSoundStream(AudioId index); - Audio::AudioStream *getSoundStream(MusicId index) const; + Audio::AudioStream *getSoundStream(MusicId index); MSNImage *getImage(int filenumber) const; const byte *getImage(CursorId id) const; @@ -60,8 +66,10 @@ private: private: Audio::SeekableAudioStream *_soundSamples[kAudioNumSamples]; - Audio::AudioStream *_musicIntro; - Audio::AudioStream *_musicOutro; + Common::ScopedPtr<Common::MemoryReadStream> _musicIntroBuffer; + Common::ScopedPtr<Common::MemoryReadStream> _musicOutroBuffer; + Common::ScopedPtr<Audio::AudioStream> _musicIntro; + Common::ScopedPtr<Audio::AudioStream> _musicOutro; int _audioRate; MSNImage *_images[kNumImageFiles]; byte _cursorNormal[256]; |