[Scummvm-cvs-logs] SF.net SVN: scummvm: [28595] scummvm/trunk/engines/agi/sound.cpp

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Mon Aug 13 17:18:44 CEST 2007


Revision: 28595
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28595&view=rev
Author:   buddha_
Date:     2007-08-13 08:18:44 -0700 (Mon, 13 Aug 2007)

Log Message:
-----------
Made calcTrueSampleSize seek back to stream's start when ending the function.

Modified Paths:
--------------
    scummvm/trunk/engines/agi/sound.cpp

Modified: scummvm/trunk/engines/agi/sound.cpp
===================================================================
--- scummvm/trunk/engines/agi/sound.cpp	2007-08-13 15:13:58 UTC (rev 28594)
+++ scummvm/trunk/engines/agi/sound.cpp	2007-08-13 15:18:44 UTC (rev 28595)
@@ -49,13 +49,18 @@
  * Needed because a zero byte in the sample data ends the sample prematurely.
  */
 uint calcTrueSampleSize(Common::SeekableReadStream &sample, uint size) {
+	uint32 startPos = sample.pos(); // Save stream's starting position
 	// Search for a zero byte in the sample data,
 	// as that would end the sample prematurely.
-	for (uint i = 0; i < size; i++)
-		if (sample.readByte() == 0)
-			return i;
-	// If no zero was found in the sample, then return its whole size.
-	return size;
+	uint result = size; // Set a default value for the result
+	for (uint i = 0; i < size; i++) {
+		if (sample.readByte() == 0) {
+			result = i;
+			break;
+		}
+	}
+	sample.seek(startPos); // Seek back to the stream's starting position
+	return result;
 }
 
 struct IIgsEnvelopeSegment {


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