aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--saga/music.cpp10
-rw-r--r--saga/music.h7
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];