diff options
author | Norbert Lange | 2009-08-01 23:02:45 +0000 |
---|---|---|
committer | Norbert Lange | 2009-08-01 23:02:45 +0000 |
commit | a28281072d72197526e68a98442df55c9b5918e4 (patch) | |
tree | e06fe4e9c618e78401dcf6b2d29daa53002cd3b0 /engines | |
parent | ebe409058082e50f8377072eedaa7af34d9dc51a (diff) | |
download | scummvm-rg350-a28281072d72197526e68a98442df55c9b5918e4.tar.gz scummvm-rg350-a28281072d72197526e68a98442df55c9b5918e4.tar.bz2 scummvm-rg350-a28281072d72197526e68a98442df55c9b5918e4.zip |
engines/scumm/scumm.cpp: terminate method is pretty redundant - removed
tfmx, player_v4a: refactored Tfmx to allow sharing of resources between 2 instances. Needed changes in player_v4a aswell
svn-id: r42980
Diffstat (limited to 'engines')
-rw-r--r-- | engines/scumm/music.h | 6 | ||||
-rw-r--r-- | engines/scumm/player_v4a.cpp | 70 | ||||
-rw-r--r-- | engines/scumm/player_v4a.h | 4 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 5 |
4 files changed, 36 insertions, 49 deletions
diff --git a/engines/scumm/music.h b/engines/scumm/music.h index c6555318a9..2fd7c50bce 100644 --- a/engines/scumm/music.h +++ b/engines/scumm/music.h @@ -81,12 +81,6 @@ public: * @return the music timer */ virtual int getMusicTimer() const { return 0; } - - /** - * Terminate the music engine. Called just before the music engine - * is deleted. - */ - virtual void terminate() {} }; } // End of namespace Scumm diff --git a/engines/scumm/player_v4a.cpp b/engines/scumm/player_v4a.cpp index 649f198f70..dabbd5f950 100644 --- a/engines/scumm/player_v4a.cpp +++ b/engines/scumm/player_v4a.cpp @@ -32,10 +32,22 @@ namespace Scumm { -Player_V4A::Player_V4A(ScummEngine *scumm, Audio::Mixer *mixer) - : _vm(scumm), _mixer(mixer), _musicId(), _sfxSlots(), _initState(0), _tfmxMusic(0), _tfmxSfx(0), _musicHandle(), _sfxHandle(), _signal(0) { +Player_V4A::Player_V4A(ScummEngine *scumm, Audio::Mixer *mixer) : + _vm(scumm), + _mixer(mixer), + _tfmxMusic(_mixer->getOutputRate(), true), + _tfmxSfx(_mixer->getOutputRate(), true), + _musicHandle(), + _sfxHandle(), + _musicId(), + _sfxSlots(), + _initState(0), + _signal(0) { + assert(scumm); assert(mixer); + assert(_vm->_game.id == GID_MONKEY_VGA); + _tfmxMusic.setSignalPtr(&_signal, 1); } bool Player_V4A::init() { @@ -44,33 +56,19 @@ bool Player_V4A::init() { Common::File fileMdat; Common::File fileSample; - bool mdatExists = fileMdat.open("music.dat"); - bool sampleExists = fileSample.open("sample.dat"); - - if (mdatExists && sampleExists) { - Audio::Tfmx *play = new Audio::Tfmx(_mixer->getOutputRate(), true); - if (play->load(fileMdat, fileSample)) { - play->setSignalPtr(&_signal, 1); - _tfmxMusic = play; - } else - delete play; - - play = new Audio::Tfmx(_mixer->getOutputRate(), true); - fileMdat.seek(0); - fileSample.seek(0); - if (play->load(fileMdat, fileSample)) { - _tfmxSfx = play; - } else - delete play; + + if (fileMdat.open("music.dat") && fileSample.open("sample.dat")) { + if (_tfmxMusic.load(fileMdat, fileSample)) { + _tfmxSfx.setModuleData(_tfmxMusic); + return true; + } } - return _tfmxMusic != 0; + return false; } Player_V4A::~Player_V4A() { _mixer->stopHandle(_musicHandle); _mixer->stopHandle(_sfxHandle); - delete _tfmxMusic; - delete _tfmxSfx; } void Player_V4A::setMusicVolume(int vol) { @@ -79,13 +77,11 @@ void Player_V4A::setMusicVolume(int vol) { void Player_V4A::stopAllSounds() { debug(5, "player_v4a: stopAllSounds"); - if (_tfmxMusic) { - _tfmxMusic->stopSong(); - _signal = 0; - } + _tfmxMusic.stopSong(); + _signal = 0; _musicId = 0; - if (_tfmxSfx) - _tfmxSfx->stopSong(); + + _tfmxSfx.stopSong(); clearSfxSlots(); } @@ -95,13 +91,13 @@ void Player_V4A::stopSound(int nr) { return; if (nr == _musicId) { _musicId = 0; - _tfmxMusic->stopSong(); + _tfmxMusic.stopSong(); _signal = 0; } else { const int chan = getSfxChan(nr); if (chan != -1) { setSfxSlot(chan, 0); - _tfmxSfx->stopMacroEffect(chan); + _tfmxSfx.stopMacroEffect(chan); } } } @@ -139,10 +135,10 @@ void Player_V4A::startSound(int nr) { debug(3, "player_v4a: play %d: custom %i - %02X", nr, index, type); // start an empty Song so timing is setup - if (_tfmxSfx->getSongIndex() < 0) - _tfmxSfx->doSong(0x18); + if (_tfmxSfx.getSongIndex() < 0) + _tfmxSfx.doSong(0x18); - const int chan = _tfmxSfx->doSfx((uint16)index); + const int chan = _tfmxSfx.doSfx((uint16)index); if (chan >= 0 && chan < ARRAYSIZE(_sfxSlots)) setSfxSlot(chan, nr, type); else @@ -150,20 +146,20 @@ void Player_V4A::startSound(int nr) { // the Tfmx-player newer "ends" the output by itself, so this should be threadsafe if (!_mixer->isSoundHandleActive(_sfxHandle)) - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, _tfmxSfx, -1, Audio::Mixer::kMaxChannelVolume, 0, false); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, &_tfmxSfx, -1, Audio::Mixer::kMaxChannelVolume, 0, false); } else { // Song debug(3, "player_v4a: play %d: song %i - %02X", nr, index, type); if (ptr[6] != 0x7F) warning("player_v4a: Song has wrong type"); - _tfmxMusic->doSong(index); + _tfmxMusic.doSong(index); _signal = 2; _musicId = nr; // the Tfmx-player newer "ends" the output by itself, so this should be threadsafe if (!_mixer->isSoundHandleActive(_musicHandle)) - _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _tfmxMusic, -1, Audio::Mixer::kMaxChannelVolume, 0, false); + _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, &_tfmxMusic, -1, Audio::Mixer::kMaxChannelVolume, 0, false); } } diff --git a/engines/scumm/player_v4a.h b/engines/scumm/player_v4a.h index 373e06fe41..5f5fae6b56 100644 --- a/engines/scumm/player_v4a.h +++ b/engines/scumm/player_v4a.h @@ -56,8 +56,8 @@ private: ScummEngine *const _vm; Audio::Mixer *const _mixer; - Audio::Tfmx *_tfmxMusic; - Audio::Tfmx *_tfmxSfx; + Audio::Tfmx _tfmxMusic; + Audio::Tfmx _tfmxSfx; Audio::SoundHandle _musicHandle; Audio::SoundHandle _sfxHandle; diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index b02c3b3346..5e3bd66b0a 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -546,10 +546,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) ScummEngine::~ScummEngine() { Common::clearAllDebugChannels(); - if (_musicEngine) { - _musicEngine->terminate(); - delete _musicEngine; - } + delete _musicEngine; _mixer->stopAll(); |