diff options
author | Paul Gilbert | 2016-08-10 23:10:46 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-10 23:10:46 -0400 |
commit | 47c7e39bca80a5249288fac5c5da4a44d552e763 (patch) | |
tree | 9d33277863fb8e3414b3c23d1809a2cf7a0b0200 /engines | |
parent | 2b486009f51bf386be3c9d97c22b7b17b0e898e8 (diff) | |
download | scummvm-rg350-47c7e39bca80a5249288fac5c5da4a44d552e763.tar.gz scummvm-rg350-47c7e39bca80a5249288fac5c5da4a44d552e763.tar.bz2 scummvm-rg350-47c7e39bca80a5249288fac5c5da4a44d552e763.zip |
TITANIC: Add music handler stopping code
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/sound/music_handler.cpp | 22 | ||||
-rw-r--r-- | engines/titanic/sound/music_handler.h | 17 | ||||
-rw-r--r-- | engines/titanic/sound/music_player.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/sound/music_player.h | 4 | ||||
-rw-r--r-- | engines/titanic/sound/music_room.cpp | 3 | ||||
-rw-r--r-- | engines/titanic/sound/music_wave.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/sound/music_wave.h | 5 |
7 files changed, 52 insertions, 11 deletions
diff --git a/engines/titanic/sound/music_handler.cpp b/engines/titanic/sound/music_handler.cpp index 9ef5ffaa5a..037c340f0b 100644 --- a/engines/titanic/sound/music_handler.cpp +++ b/engines/titanic/sound/music_handler.cpp @@ -27,11 +27,15 @@ namespace Titanic { CMusicHandler::CMusicHandler(CProjectItem *project, CSoundManager *soundManager) : - _project(project), _soundManager(soundManager), - _field124(0) { + _project(project), _soundManager(soundManager), _stopWaves(false), + _soundHandle(-1), _waveFile(nullptr) { Common::fill(&_musicWaves[0], &_musicWaves[4], (CMusicWave *)nullptr); } +CMusicHandler::~CMusicHandler() { + stop(); +} + CMusicWave *CMusicHandler::createMusicWave(int waveIndex, int count) { switch (waveIndex) { case 0: @@ -59,4 +63,18 @@ bool CMusicHandler::isBusy() { return false; } +void CMusicHandler::stop() { + if (_waveFile) { + _soundManager->stopSound(_soundHandle); + delete _waveFile; + _waveFile = nullptr; + _soundHandle = -1; + } + + for (int idx = 0; idx < 4; ++idx) { + if (_stopWaves && _musicWaves[idx]) + _musicWaves[idx]->stop(); + } +} + } // End of namespace Titanic diff --git a/engines/titanic/sound/music_handler.h b/engines/titanic/sound/music_handler.h index 7b8ee035b6..17ffea965a 100644 --- a/engines/titanic/sound/music_handler.h +++ b/engines/titanic/sound/music_handler.h @@ -24,6 +24,7 @@ #define TITANIC_MUSIC_HANDLER_H #include "titanic/sound/music_wave.h" +#include "titanic/sound/wave_file.h" namespace Titanic { @@ -35,9 +36,12 @@ private: CProjectItem *_project; CSoundManager *_soundManager; CMusicWave *_musicWaves[4]; - int _field124; + bool _stopWaves; + CWaveFile *_waveFile; + int _soundHandle; public: CMusicHandler(CProjectItem *project, CSoundManager *soundManager); + ~CMusicHandler(); /** * Creates a new music wave class instance, and assigns it to a slot @@ -49,7 +53,16 @@ public: bool isBusy(); - void set124(int val) { _field124 = val; } + /** + * Flags whether the loaded music waves will be stopped when the + * music handler is stopped + */ + void setStopWaves(bool flag) { _stopWaves = flag; } + + /** + * Stop playing the music + */ + void stop(); }; } // End of namespace Titanic diff --git a/engines/titanic/sound/music_player.cpp b/engines/titanic/sound/music_player.cpp index fb5a596875..cd764c7f93 100644 --- a/engines/titanic/sound/music_player.cpp +++ b/engines/titanic/sound/music_player.cpp @@ -39,7 +39,7 @@ void CMusicPlayer::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_isActive, indent); file->writeQuotedLine(_stopTarget, indent); - file->writeNumberLine(_fieldCC, indent); + file->writeNumberLine(_stopWaves, indent); file->writeNumberLine(_musicId, indent); CGameObject::save(file, indent); @@ -49,7 +49,7 @@ void CMusicPlayer::load(SimpleFile *file) { file->readNumber(); _isActive = file->readNumber(); _stopTarget = file->readString(); - _fieldCC = file->readNumber(); + _stopWaves = file->readNumber(); _musicId = file->readNumber(); CGameObject::load(file); @@ -120,7 +120,7 @@ bool CMusicPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) { bool CMusicPlayer::CreateMusicPlayerMsg(CCreateMusicPlayerMsg *msg) { if (CMusicRoom::_musicHandler) { - CMusicRoom::_musicHandler->set124(_fieldCC); + CMusicRoom::_musicHandler->setStopWaves(_stopWaves); return true; } @@ -156,7 +156,7 @@ bool CMusicPlayer::CreateMusicPlayerMsg(CCreateMusicPlayerMsg *msg) { wave->load(5, "z#505.wav", 53); wave->load(6, "z#501.wav", 58); - CMusicRoom::_musicHandler->set124(_fieldCC); + CMusicRoom::_musicHandler->setStopWaves(_stopWaves); } return true; diff --git a/engines/titanic/sound/music_player.h b/engines/titanic/sound/music_player.h index 3ed1bffdbd..7b82d4da00 100644 --- a/engines/titanic/sound/music_player.h +++ b/engines/titanic/sound/music_player.h @@ -41,12 +41,12 @@ class CMusicPlayer : public CGameObject { protected: bool _isActive; CString _stopTarget; - int _fieldCC; + bool _stopWaves; int _musicId; public: CLASSDEF; CMusicPlayer() : CGameObject(), - _isActive(false), _fieldCC(0), _musicId(100) {} + _isActive(false), _stopWaves(false), _musicId(100) {} /** * Save the data for the class to file diff --git a/engines/titanic/sound/music_room.cpp b/engines/titanic/sound/music_room.cpp index 06cf866811..34217de184 100644 --- a/engines/titanic/sound/music_room.cpp +++ b/engines/titanic/sound/music_room.cpp @@ -58,7 +58,8 @@ void CMusicRoom::startMusic(int musicId) { } void CMusicRoom::stopMusic() { - // TODO + if (_musicHandler) + _musicHandler->stop(); } } // End of namespace Titanic diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp index 753098eb46..6b5b187805 100644 --- a/engines/titanic/sound/music_wave.cpp +++ b/engines/titanic/sound/music_wave.cpp @@ -47,4 +47,8 @@ CWaveFile *CMusicWave::createWaveFile(const CString &name) { return _soundManager->loadSound(name); } +void CMusicWave::stop() { + +} + } // End of namespace Titanic diff --git a/engines/titanic/sound/music_wave.h b/engines/titanic/sound/music_wave.h index dcdd3615fb..b240f4a856 100644 --- a/engines/titanic/sound/music_wave.h +++ b/engines/titanic/sound/music_wave.h @@ -59,6 +59,11 @@ public: * Loads a new file into the list of available entries */ void load(int index, const CString &filename, int v3); + + /** + * Stops the music + */ + void stop(); }; } // End of namespace Titanic |