aboutsummaryrefslogtreecommitdiff
path: root/sword2/driver
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-12-31 14:05:53 +0000
committerTorbjörn Andersson2003-12-31 14:05:53 +0000
commitc85301b2a979efd0807945800f2fadd50a898158 (patch)
treec3e4532e763ed9ecbd39e308327d25ffe43f0e59 /sword2/driver
parentcde55eb4fadd6fec5b5b288de106fda66f24809e (diff)
downloadscummvm-rg350-c85301b2a979efd0807945800f2fadd50a898158.tar.gz
scummvm-rg350-c85301b2a979efd0807945800f2fadd50a898158.tar.bz2
scummvm-rg350-c85301b2a979efd0807945800f2fadd50a898158.zip
When saving the music state, remember the name of the music file that was
open so that it can be re-opened afterwards. It's not so much that it may have changed, but it may have been closed. This should fix a crash when escaping the credits. svn-id: r12055
Diffstat (limited to 'sword2/driver')
-rw-r--r--sword2/driver/d_sound.cpp14
-rw-r--r--sword2/driver/d_sound.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index 5398aebb8a..e17c7d6882 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -196,6 +196,11 @@ void Sound::saveMusicState() {
_music[2]._filePos = _music[saveStream]._filePos;
_music[2]._fileEnd = _music[saveStream]._fileEnd;
_music[2]._lastSample = _music[saveStream]._lastSample;
+
+ if (fpMus.isOpen())
+ savedMusicFilename = strdup(fpMus.name());
+ else
+ savedMusicFilename = NULL;
}
void Sound::restoreMusicState() {
@@ -226,6 +231,15 @@ void Sound::restoreMusicState() {
_music[restoreStream]._filePos = _music[2]._filePos;
_music[restoreStream]._fileEnd = _music[2]._fileEnd;
_music[restoreStream]._lastSample = _music[2]._lastSample;
+
+ if (savedMusicFilename) {
+ if (fpMus.isOpen())
+ fpMus.close();
+
+ fpMus.open(savedMusicFilename);
+ free(savedMusicFilename);
+ savedMusicFilename = NULL;
+ }
}
void Sound::playLeadOut(uint8 *leadOut) {
diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h
index a9e97317a6..56580fc561 100644
--- a/sword2/driver/d_sound.h
+++ b/sword2/driver/d_sound.h
@@ -109,6 +109,8 @@ private:
void updateCompSampleStreaming(int16 *data, uint len);
+ char *savedMusicFilename;
+
public:
Sound(Sword2Engine *vm);
~Sound();