aboutsummaryrefslogtreecommitdiff
path: root/engines/sword2
diff options
context:
space:
mode:
authorChristopher Page2008-07-21 22:46:39 +0000
committerChristopher Page2008-07-21 22:46:39 +0000
commit09f4fd946ee4b3fd6d9780e080b9bc95fbcd0a69 (patch)
treee4aae52f4e6872f8cd6bed9ddab5de6d0521f7d2 /engines/sword2
parent0cae5552db214a7e11c552205e03fd5c0c38f6fd (diff)
parente09eb75ef77d6e76b763b3a47540a530013a887f (diff)
downloadscummvm-rg350-09f4fd946ee4b3fd6d9780e080b9bc95fbcd0a69.tar.gz
scummvm-rg350-09f4fd946ee4b3fd6d9780e080b9bc95fbcd0a69.tar.bz2
scummvm-rg350-09f4fd946ee4b3fd6d9780e080b9bc95fbcd0a69.zip
Merged revisions 33052-33053,33056-33058,33061-33064,33068,33070,33072,33075,33078-33079,33083,33086-33087,33089,33094-33096,33098-33099,33104,33108-33109,33114-33117,33120,33135-33146,33160,33162,33165,33167-33169 via svnmerge from
https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk svn-id: r33183
Diffstat (limited to 'engines/sword2')
-rw-r--r--engines/sword2/music.cpp21
-rw-r--r--engines/sword2/sound.h2
2 files changed, 15 insertions, 8 deletions
diff --git a/engines/sword2/music.cpp b/engines/sword2/music.cpp
index fd72ba8d52..3b5a09578b 100644
--- a/engines/sword2/music.cpp
+++ b/engines/sword2/music.cpp
@@ -52,9 +52,11 @@ namespace Sword2 {
static Audio::AudioStream *makeCLUStream(Common::File *fp, int size);
static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base, int cd, uint32 id, uint32 *numSamples) {
- debug(3, "Playing %s from CD %d", base, cd);
+ bool alreadyOpen;
if (!fh->file.isOpen()) {
+ alreadyOpen = false;
+
struct {
const char *ext;
int mode;
@@ -75,16 +77,14 @@ static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base,
char filename[20];
for (int i = 0; i < ARRAYSIZE(file_types); i++) {
- Common::File f;
-
sprintf(filename, "%s%d.%s", base, cd, file_types[i].ext);
- if (f.open(filename)) {
+ if (Common::File::exists(filename)) {
soundMode = file_types[i].mode;
break;
}
sprintf(filename, "%s.%s", base, file_types[i].ext);
- if (f.open(filename)) {
+ if (Common::File::exists(filename)) {
soundMode = file_types[i].mode;
break;
}
@@ -105,7 +105,8 @@ static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base,
fh->idxTab = NULL;
}
}
- }
+ } else
+ alreadyOpen = true;
uint32 entrySize = (fh->fileType == kCLUMode) ? 2 : 3;
@@ -134,7 +135,13 @@ static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base,
*numSamples = len;
if (!pos || !len) {
- fh->file.close();
+ // We couldn't find the sound. Possibly as a result of a bad
+ // installation (e.g. using the music file from CD 2 as the
+ // first music file). Don't close the file if it was already
+ // open though, because something is playing from it.
+ warning("getAudioStream: Could not find %s ID %d! Possibly the wrong file", base, id);
+ if (!alreadyOpen)
+ fh->file.close();
return NULL;
}
diff --git a/engines/sword2/sound.h b/engines/sword2/sound.h
index 70bae6f851..b89ef8f12b 100644
--- a/engines/sword2/sound.h
+++ b/engines/sword2/sound.h
@@ -106,7 +106,7 @@ private:
void refill();
inline bool eosIntern() const {
- return _pos >= _bufferEnd;
+ return !_file->isOpen() || _pos >= _bufferEnd;
}
public: