From f364782d05cf0772bf2eaa71ea418650e0d9bf27 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 08:46:32 +0100 Subject: ACCESS: Some rework in MusicManager --- engines/access/room.cpp | 5 ++--- engines/access/sound.cpp | 10 +++++++--- engines/access/sound.h | 10 +++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 7ef3d6937d..8ef61a9d68 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -152,8 +152,7 @@ void Room::doRoom() { void Room::clearRoom() { if (_vm->_midi->_music) { _vm->_midi->stopSong(); - delete _vm->_midi->_music; - _vm->_midi->_music = nullptr; + _vm->_midi->freeMusic(); } _vm->_sound->freeSounds(); @@ -183,7 +182,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_midi->freeMusic(); if (roomInfo._musicFile._fileNum != -1) { - _vm->_midi->_music = _vm->_files->loadFile(roomInfo._musicFile); + _vm->_midi->loadMusic(roomInfo._musicFile); _vm->_midi->midiPlay(); _vm->_midi->_musicRepeat = true; } diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index a24dd1a24b..316ac54d42 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -172,8 +172,12 @@ void MusicManager::stopSong() { // TODO } -Resource *MusicManager::loadMusic(int fileNum, int subfile) { - return _vm->_files->loadFile(fileNum, subfile); +void MusicManager::loadMusic(int fileNum, int subfile) { + _music = _vm->_files->loadFile(fileNum, subfile); +} + +void MusicManager::loadMusic(FileIdent file) { + _music = _vm->_files->loadFile(file); } void MusicManager::newMusic(int musicId, int mode) { @@ -189,7 +193,7 @@ void MusicManager::newMusic(int musicId, int mode) { _musicRepeat = (mode == 2); _tempMusic = _music; stopSong(); - _music = loadMusic(97, musicId); + loadMusic(97, musicId); } } diff --git a/engines/access/sound.h b/engines/access/sound.h index b14ce7c685..827a00f8b5 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -75,13 +75,14 @@ private: AccessEngine *_vm; Audio::Mixer *_mixer; - Resource *loadMusic(int fileNum, int subfile); + Resource *_tempMusic; public: - Resource *_music; - Resource *_tempMusic; bool _musicRepeat; bool _playingSound; + + Resource *_music; + public: MusicManager(AccessEngine *vm, Audio::Mixer *mixer); ~MusicManager(); @@ -97,6 +98,9 @@ public: void newMusic(int musicId, int mode); void freeMusic(); + + void loadMusic(int fileNum, int subfile); + void loadMusic(FileIdent file); }; } // End of namespace Access -- cgit v1.2.3