[Scummvm-cvs-logs] SF.net SVN: scummvm:[47203] scummvm/trunk/sound/voc.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sat Jan 9 19:51:26 CET 2010


Revision: 47203
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47203&view=rev
Author:   lordhoto
Date:     2010-01-09 18:51:25 +0000 (Sat, 09 Jan 2010)

Log Message:
-----------
Implement some safer handling of the "Extended" block in VOC files.

Modified Paths:
--------------
    scummvm/trunk/sound/voc.cpp

Modified: scummvm/trunk/sound/voc.cpp
===================================================================
--- scummvm/trunk/sound/voc.cpp	2010-01-09 18:18:52 UTC (rev 47202)
+++ scummvm/trunk/sound/voc.cpp	2010-01-09 18:51:25 UTC (rev 47203)
@@ -147,15 +147,21 @@
 		case 7:	// end of loop
 			assert(len == 0);
 			break;
-		case 8: // "Extended"
-			// This occures in the LoL Intro demo. This block can usually be used to create stereo
-			// sound, but the LoL intro has only an empty block, thus this dummy implementation will
-			// work.
+		case 8: { // "Extended"
+			// This occures in the LoL Intro demo. 
+			// This block overwrites the next parameters of a block 1 "Sound data".
+			// To assure we never get any bad data here, we will assert in case
+			// this tries to define a stereo sound block or tries to use something
+			// different than 8bit unsigned sound data.
+			// TODO: Actually we would need to check the frequency divisor (the
+			// first word) here too. It is used in the following equation:
+			// sampleRate = 256000000/(channels * (65536 - frequencyDivisor))
 			assert(len == 4);
 			stream.readUint16LE();
-			stream.readByte();
-			stream.readByte();
-			break;
+			uint8 codec = stream.readByte();
+			uint8 channels = stream.readByte() + 1;
+			assert(codec == 0 && channels == 1);
+			} break;
 		default:
 			warning("Unhandled code %d in VOC file (len %d)", code, len);
 			return ret_sound;


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