[Scummvm-cvs-logs] SF.net SVN: scummvm:[46409] tools/branches/gsoc2009-gui/compress_scumm_san. cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Dec 17 22:40:26 CET 2009


Revision: 46409
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46409&view=rev
Author:   fingolfin
Date:     2009-12-17 21:40:26 +0000 (Thu, 17 Dec 2009)

Log Message:
-----------
TOOLS: Fixing some more bugs in compress_scumm_san

Modified Paths:
--------------
    tools/branches/gsoc2009-gui/compress_scumm_san.cpp

Modified: tools/branches/gsoc2009-gui/compress_scumm_san.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_scumm_san.cpp	2009-12-17 21:39:52 UTC (rev 46408)
+++ tools/branches/gsoc2009-gui/compress_scumm_san.cpp	2009-12-17 21:40:26 UTC (rev 46409)
@@ -322,8 +322,10 @@
 	int l, r, z;
 
 	const std::string wavPath = outputDir + "/" + inputFilename + ".wav";
-	File wavFile(wavPath.c_str(), "wb+");
+	File &wavFile(_waveTmpFile);
 
+	wavFile.open(wavPath.c_str(), "wb+");
+
 	int frameAudioSize = 0;
 	if (fps == 12) {
 		frameAudioSize = 7352;
@@ -341,20 +343,24 @@
 	print("Mixing tracks into wav file...\n");
 	for (l = 0; l < COMPRESS_SCUMM_SAN_MAX_TRACKS; l++) {
 		if (_audioTracks[l].used) {
-		char filename[200];
+			char filename[200];
 			sprintf(filename, "%s/%s_%04d_%03d.tmp", outputDir.c_str(), inputFilename.c_str(), _audioTracks[l].animFrame, _audioTracks[l].trackId);
 			_audioTracks[l].file.open(filename, "rb");
-			_audioTracks[l].file.seek(0, SEEK_END);
-			int fileSize = _audioTracks[l].file.pos();
-			_audioTracks[l].file.seek(0, SEEK_SET);
+			const uint32 fileSize = _audioTracks[l].file.size();
 			byte *tmpBuf = (byte *)malloc(fileSize);
 			_audioTracks[l].file.read_throwsOnError(tmpBuf, fileSize);
 			_audioTracks[l].file.close();
 			unlink(filename);
 
 			byte *wavBuf = (byte *)malloc(fileSize);
+			memset(wavBuf, 0, fileSize);
 			wavFile.seek(44 + (frameAudioSize * _audioTracks[l].animFrame), SEEK_SET);
-			wavFile.read_throwsOnError(wavBuf, fileSize);
+			try {
+				wavFile.read_throwsOnError(wavBuf, fileSize);
+			} catch (...) {
+				// ... pass through
+				wavFile.clearErr();
+			}
 
 			int offset = 0;
 			for (z = 0; z < _audioTracks[l].countFrames; z++) {
@@ -389,7 +395,6 @@
 		}
 	}
 
-	_waveTmpFile = wavFile;
 	_waveDataSize = frames * frameAudioSize;
 }
 
@@ -620,7 +625,7 @@
 	
 	try {
 		flu_in.open(flupath, "rb");
-	} catch(...) {
+	} catch (...) {
 		// pass
 	}
 
@@ -690,7 +695,7 @@
 		for (;;) {
 			try {
 				tag = input.readUint32BE(); // chunk tag
-			} catch(...) {
+			} catch (...) {
 				break;
 			}
 			if (input.eos())


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