aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTorbjörn Andersson2006-06-17 15:54:40 +0000
committerTorbjörn Andersson2006-06-17 15:54:40 +0000
commitff38faa21d09a2a41323b196ddd586289dca292e (patch)
tree32772f932901391f78e2d6f1d318037772902e73 /engines
parentce1edcfd7d4bdd863e08f73797fbf773c9c8199c (diff)
downloadscummvm-rg350-ff38faa21d09a2a41323b196ddd586289dca292e.tar.gz
scummvm-rg350-ff38faa21d09a2a41323b196ddd586289dca292e.tar.bz2
scummvm-rg350-ff38faa21d09a2a41323b196ddd586289dca292e.zip
The stopMusic() function (which is publicly accessable from the outside) now
locks the mutex to avoid pulling the proverbial rug out from beneath the timer callback's proverbial feet. To stop the music when the mutex is already locked, we use stopMusicInternal(), which is a protected function. This will hopefully fix the crash on exit which has happened to me every few months. svn-id: r23159
Diffstat (limited to 'engines')
-rw-r--r--engines/sky/music/musicbase.cpp13
-rw-r--r--engines/sky/music/musicbase.h2
2 files changed, 12 insertions, 3 deletions
diff --git a/engines/sky/music/musicbase.cpp b/engines/sky/music/musicbase.cpp
index 9d308ebc7f..e296c72827 100644
--- a/engines/sky/music/musicbase.cpp
+++ b/engines/sky/music/musicbase.cpp
@@ -47,7 +47,7 @@ void MusicBase::loadSection(uint8 pSection) {
_mutex.lock();
if (_currentMusic)
- stopMusic();
+ stopMusicInternal();
if (_musicData)
free(_musicData);
_currentSection = pSection;
@@ -82,6 +82,13 @@ void MusicBase::setVolume(uint16 param) {
void MusicBase::stopMusic(void) {
+ _mutex.lock();
+ stopMusicInternal();
+ _mutex.unlock();
+}
+
+void MusicBase::stopMusicInternal(void) {
+
for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) {
_channels[cnt]->stopNote();
delete _channels[cnt];
@@ -105,7 +112,7 @@ void MusicBase::loadNewMusic(void) {
return;
}
if (_currentMusic != 0)
- stopMusic();
+ stopMusicInternal();
_currentMusic = _onNextPoll.musicToProcess;
@@ -128,7 +135,7 @@ void MusicBase::pollMusic(void) {
_mutex.lock();
uint8 newTempo;
if (_onNextPoll.doReInit) startDriver();
- if (_onNextPoll.doStopMusic) stopMusic();
+ if (_onNextPoll.doStopMusic) stopMusicInternal();
if (_onNextPoll.musicToProcess != _currentMusic)
loadNewMusic();
diff --git a/engines/sky/music/musicbase.h b/engines/sky/music/musicbase.h
index d9f3e22beb..108ee259c9 100644
--- a/engines/sky/music/musicbase.h
+++ b/engines/sky/music/musicbase.h
@@ -85,6 +85,8 @@ protected:
void updateTempo(void);
void loadNewMusic(void);
void pollMusic(void);
+
+ void stopMusicInternal(void);
};
} // End of namespace Sky