[Scummvm-cvs-logs] SF.net SVN: scummvm:[48920] scummvm/trunk/sound/decoders/raw.cpp
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Mon May 3 20:28:05 CEST 2010
Revision: 48920
http://scummvm.svn.sourceforge.net/scummvm/?rev=48920&view=rev
Author: lordhoto
Date: 2010-05-03 18:28:05 +0000 (Mon, 03 May 2010)
Log Message:
-----------
Check for read/seek errors of the underlying SeekableReadStream in RawStream.
Modified Paths:
--------------
scummvm/trunk/sound/decoders/raw.cpp
Modified: scummvm/trunk/sound/decoders/raw.cpp
===================================================================
--- scummvm/trunk/sound/decoders/raw.cpp 2010-05-03 18:27:45 UTC (rev 48919)
+++ scummvm/trunk/sound/decoders/raw.cpp 2010-05-03 18:28:05 UTC (rev 48920)
@@ -63,8 +63,16 @@
// Set current buffer state, playing first block
_stream->seek(_curBlock->pos, SEEK_SET);
- _blockLeft = _curBlock->len;
+ // In case of an error we will stop (or rather
+ // not start) stream playback.
+ if (_stream->err()) {
+ _blockLeft = 0;
+ _curBlock = _blocks.end();
+ } else {
+ _blockLeft = _curBlock->len;
+ }
+
// Add up length of all blocks in order to caluclate total play time
int32 len = 0;
for (RawStreamBlockList::const_iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
@@ -187,7 +195,12 @@
maxSamples -= samplesRead;
_blockLeft -= samplesRead;
- // TODO: Check for possible read errors
+ // In case of an error we will stop
+ // stream playback.
+ if (_stream->err()) {
+ _blockLeft = 0;
+ _curBlock = _blocks.end();
+ }
// Advance to the next block in case the current
// one is already finished.
@@ -210,9 +223,14 @@
if (_curBlock != _blocks.end()) {
_stream->seek(_curBlock->pos, SEEK_SET);
- // TODO: Check for errors while seeking
-
- _blockLeft = _curBlock->len;
+ // In case of an error we will stop
+ // stream playback.
+ if (_stream->err()) {
+ _blockLeft = 0;
+ _curBlock = _blocks.end();
+ } else {
+ _blockLeft = _curBlock->len;
+ }
}
}
}
@@ -244,8 +262,16 @@
const uint32 offset = seekSample - curSample;
_stream->seek(_curBlock->pos + offset * (is16Bit ? 2 : 1), SEEK_SET);
- _blockLeft = _curBlock->len - offset;
+ // In case of an error we will stop
+ // stream playback.
+ if (_stream->err()) {
+ _blockLeft = 0;
+ _curBlock = _blocks.end();
+ } else {
+ _blockLeft = _curBlock->len - offset;
+ }
+
return true;
}
}
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