aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorKari Salminen2007-08-13 15:18:44 +0000
committerKari Salminen2007-08-13 15:18:44 +0000
commit985ac6ceaa2a34554d27dc39116559ddae808522 (patch)
tree48835a41c4fc9a2f4e2ad9ff6a36214fd1acba87 /engines
parent8801cf9b3cec813a89ba2d64674804edfba73880 (diff)
downloadscummvm-rg350-985ac6ceaa2a34554d27dc39116559ddae808522.tar.gz
scummvm-rg350-985ac6ceaa2a34554d27dc39116559ddae808522.tar.bz2
scummvm-rg350-985ac6ceaa2a34554d27dc39116559ddae808522.zip
Made calcTrueSampleSize seek back to stream's start when ending the function.
svn-id: r28595
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/sound.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp
index f376ca2ff7..d5db02f732 100644
--- a/engines/agi/sound.cpp
+++ b/engines/agi/sound.cpp
@@ -49,13 +49,18 @@ namespace Agi {
* 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 {