[Scummvm-cvs-logs] SF.net SVN: scummvm:[34859] scummvm/branches/branch-0-12-0/engines/sword1/ sound.cpp
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Tue Oct 28 20:37:20 CET 2008
Revision: 34859
http://scummvm.svn.sourceforge.net/scummvm/?rev=34859&view=rev
Author: eriktorbjorn
Date: 2008-10-28 19:37:20 +0000 (Tue, 28 Oct 2008)
Log Message:
-----------
Backported fix for bug #2182450 ("BS1 Demo: Crash due to missing speech
segment").
Modified Paths:
--------------
scummvm/branches/branch-0-12-0/engines/sword1/sound.cpp
Modified: scummvm/branches/branch-0-12-0/engines/sword1/sound.cpp
===================================================================
--- scummvm/branches/branch-0-12-0/engines/sword1/sound.cpp 2008-10-27 11:04:36 UTC (rev 34858)
+++ scummvm/branches/branch-0-12-0/engines/sword1/sound.cpp 2008-10-28 19:37:20 UTC (rev 34859)
@@ -262,29 +262,54 @@
headerPos++;
if (headerPos < 100) {
int32 resSize;
+ int16 *srcData;
+ uint32 srcPos;
+ int16 length;
+ cSize /= 2;
headerPos += 4; // skip 'data' tag
if (_cowMode != CowDemo) {
resSize = READ_LE_UINT32(fBuf + headerPos) >> 1;
headerPos += 4;
} else {
- // the demo speech files have the uncompressed size embedded
- // in the compressed stream *sigh*
- if (READ_LE_UINT16(fBuf + headerPos) == 1) {
- resSize = READ_LE_UINT16(fBuf + headerPos + 2);
- resSize |= READ_LE_UINT16(fBuf + headerPos + 6) << 16;
- } else
- resSize = READ_LE_UINT32(fBuf + headerPos + 2);
- resSize >>= 1;
+ // the demo speech files have the uncompressed size
+ // embedded in the compressed stream *sigh*
+ //
+ // But not always, apparently. See bug #2182450. Is
+ // there any way to figure out the size other than
+ // decoding the sound in that case?
+
+ if (fBuf[headerPos + 1] == 0) {
+ if (READ_LE_UINT16(fBuf + headerPos) == 1) {
+ resSize = READ_LE_UINT16(fBuf + headerPos + 2);
+ resSize |= READ_LE_UINT16(fBuf + headerPos + 6) << 16;
+ } else
+ resSize = READ_LE_UINT32(fBuf + headerPos + 2);
+ resSize >>= 1;
+ } else {
+ resSize = 0;
+ srcData = (int16*)fBuf;
+ srcPos = headerPos >> 1;
+ while (srcPos < cSize) {
+ length = (int16)READ_LE_UINT16(srcData + srcPos);
+ srcPos++;
+ if (length < 0) {
+ resSize -= length;
+ srcPos++;
+ } else {
+ resSize += length;
+ srcPos += length;
+ }
+ }
+ }
}
assert(!(headerPos & 1));
- int16 *srcData = (int16*)fBuf;
- uint32 srcPos = headerPos >> 1;
- cSize /= 2;
+ srcData = (int16*)fBuf;
+ srcPos = headerPos >> 1;
uint32 dstPos = 0;
int16 *dstData = (int16*)malloc(resSize * 2);
int32 samplesLeft = resSize;
while (srcPos < cSize && samplesLeft > 0) {
- int16 length = (int16)READ_LE_UINT16(srcData + srcPos);
+ length = (int16)READ_LE_UINT16(srcData + srcPos);
srcPos++;
if (length < 0) {
length = -length;
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