LURE: Stop MIDI notes when pausing

When pausing the game by bringing up the ScummVM menu, the MIDI notes would
hang. I've added code to pause and resume the active MIDI parsers, which stops
the active notes.
This commit is contained in:
NMIError 2020-08-10 13:23:41 +02:00 committed by Thierry Crozat
parent 81c514ac8f
commit 20d5307bb9
2 changed files with 42 additions and 2 deletions

View File

@ -92,6 +92,7 @@ SoundManager::~SoundManager() {
delete _soundData;
if (_driver) {
_driver->stopAllNotes();
_driver->close();
delete _driver;
_driver = NULL;
@ -510,6 +511,35 @@ void SoundManager::fadeOut() {
musicInterface_KillAll();
}
void SoundManager::pause() {
_paused = true;
_soundMutex.lock();
MusicListIterator i;
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
(**i).pauseMusic();
}
_soundMutex.unlock();
// Terminate any hanging notes, just in case
_driver->stopAllNotes();
}
void SoundManager::resume() {
_paused = false;
_soundMutex.lock();
MusicListIterator i;
for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
(**i).resumeMusic();
}
_soundMutex.unlock();
}
/*------------------------------------------------------------------------*/
// musicInterface_Play
@ -946,4 +976,12 @@ void MidiMusic::stopMusic() {
_mt32Driver->deinitSource(_source);
}
void MidiMusic::pauseMusic() {
_parser->pausePlaying();
}
void MidiMusic::resumeMusic() {
_parser->resumePlaying();
}
} // End of namespace Lure

View File

@ -81,6 +81,8 @@ public:
void stopSong() { stopMusic(); }
void playMusic();
void stopMusic();
void pauseMusic();
void resumeMusic();
void queueTuneList(int16 tuneList);
bool queueSong(uint16 songNum);
void toggleVChange();
@ -156,8 +158,8 @@ public:
void removeSounds();
void restoreSounds();
void fadeOut();
void pause() { _paused = true; }
void resume() { _paused = false; }
void pause();
void resume();
bool getPaused() const { return _paused; }
bool hasNativeMT32() const { return _nativeMT32; }
bool isRoland() const { return _isRoland; }