aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/player_v4a.cpp
diff options
context:
space:
mode:
authorNorbert Lange2009-08-01 23:02:45 +0000
committerNorbert Lange2009-08-01 23:02:45 +0000
commita28281072d72197526e68a98442df55c9b5918e4 (patch)
treee06fe4e9c618e78401dcf6b2d29daa53002cd3b0 /engines/scumm/player_v4a.cpp
parentebe409058082e50f8377072eedaa7af34d9dc51a (diff)
downloadscummvm-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/scumm/player_v4a.cpp')
-rw-r--r--engines/scumm/player_v4a.cpp70
1 files changed, 33 insertions, 37 deletions
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);
}
}