[Scummvm-cvs-logs] SF.net SVN: scummvm:[33094] scummvm/trunk/engines/sword2
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Fri Jul 18 06:16:02 CEST 2008
Revision: 33094
http://scummvm.svn.sourceforge.net/scummvm/?rev=33094&view=rev
Author: eriktorbjorn
Date: 2008-07-18 04:16:00 +0000 (Fri, 18 Jul 2008)
Log Message:
-----------
Don't crash if you try to use music file #2 as music file #1. When the music
wasn't found, it would close the file even if something else was already
playing from it. (Some music is in both files.)
Modified Paths:
--------------
scummvm/trunk/engines/sword2/music.cpp
scummvm/trunk/engines/sword2/sound.h
Modified: scummvm/trunk/engines/sword2/music.cpp
===================================================================
--- scummvm/trunk/engines/sword2/music.cpp 2008-07-18 01:46:33 UTC (rev 33093)
+++ scummvm/trunk/engines/sword2/music.cpp 2008-07-18 04:16:00 UTC (rev 33094)
@@ -52,9 +52,11 @@
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 @@
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 @@
fh->idxTab = NULL;
}
}
- }
+ } else
+ alreadyOpen = true;
uint32 entrySize = (fh->fileType == kCLUMode) ? 2 : 3;
@@ -134,7 +135,13 @@
*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;
}
Modified: scummvm/trunk/engines/sword2/sound.h
===================================================================
--- scummvm/trunk/engines/sword2/sound.h 2008-07-18 01:46:33 UTC (rev 33093)
+++ scummvm/trunk/engines/sword2/sound.h 2008-07-18 04:16:00 UTC (rev 33094)
@@ -106,7 +106,7 @@
void refill();
inline bool eosIntern() const {
- return _pos >= _bufferEnd;
+ return !_file->isOpen() || _pos >= _bufferEnd;
}
public:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list