diff options
author | Torbjörn Andersson | 2005-01-17 14:19:17 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2005-01-17 14:19:17 +0000 |
commit | 8e93b45efe7f5b19143b3a6658dec8594d577089 (patch) | |
tree | 4a6eb115645db0e8e3125424ee562a72bd0e2351 /saga | |
parent | 9a31154db35f86115f15d76d6f08710da35fe4f4 (diff) | |
download | scummvm-rg350-8e93b45efe7f5b19143b3a6658dec8594d577089.tar.gz scummvm-rg350-8e93b45efe7f5b19143b3a6658dec8594d577089.tar.bz2 scummvm-rg350-8e93b45efe7f5b19143b3a6658dec8594d577089.zip |
If the game tries to start a piece of music that happens to be playing
already, let it continue playing rather than restarting it. (I've been
meaning to make this change for some time, but now it appeared on the TODO
list as well. :-)
svn-id: r16583
Diffstat (limited to 'saga')
-rw-r--r-- | saga/music.cpp | 10 | ||||
-rw-r--r-- | saga/music.h | 7 |
2 files changed, 16 insertions, 1 deletions
diff --git a/saga/music.cpp b/saga/music.cpp index 634c40434d..956bdaedae 100644 --- a/saga/music.cpp +++ b/saga/music.cpp @@ -349,6 +349,10 @@ Music::~Music() { delete _player; } +bool Music::isPlaying() { + return _musicHandle.isActive() || _player->isPlaying(); +} + // The Wyrmkeep release of Inherit The Earth features external MIDI files, so // we need a mapping from resource number to filename. // @@ -397,6 +401,12 @@ int Music::play(uint32 music_rn, uint16 flags) { return SUCCESS; } + if (isPlaying() && _trackNumber == music_rn) { + return SUCCESS; + } + + _trackNumber = music_rn; + _player->stopMusic(); if (_musicHandle.isActive()) diff --git a/saga/music.h b/saga/music.h index adf122c6f7..707da30727 100644 --- a/saga/music.h +++ b/saga/music.h @@ -51,6 +51,9 @@ class MusicPlayer : public MidiDriver { public: MusicPlayer(MidiDriver *driver); ~MusicPlayer(); + + bool isPlaying() { return _isPlaying; } + void setVolume(int volume); int getVolume() { return _masterVolume; } @@ -59,7 +62,7 @@ public: void playMusic(); void stopMusic(); void setLoop(bool loop) { _looping = loop; } - void setPassThrough(bool b) { _passThrough = b; } + void setPassThrough(bool b) { _passThrough = b; } void setGM(bool isGM) { _isGM = isGM; } @@ -110,6 +113,7 @@ public: void setAdlib(bool b) { _adlib = b; } bool hasAdlib() { return _adlib; } void setPassThrough(bool b) { _player->setPassThrough(b); } + bool isPlaying(void); int play(uint32 music_rn, uint16 flags = MUSIC_DEFAULT); int pause(void); @@ -122,6 +126,7 @@ private: MusicPlayer *_player; PlayingSoundHandle _musicHandle; + uint32 _trackNumber; static const MUSIC_MIDITABLE _midiTableITECD[26]; MUSIC_DIGITABLE _digiTableITECD[27]; |