diff options
author | Johannes Schickel | 2010-05-03 18:28:05 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-05-03 18:28:05 +0000 |
commit | e7f29db4980ec3ad654a1b490ae040d09ad36ef1 (patch) | |
tree | 0ac8cd62f7f81b80cf52226bf2161ccb7cae0dd8 /sound/decoders | |
parent | df318c0ec3627198941a0c2bf5c3704d44ba1530 (diff) | |
download | scummvm-rg350-e7f29db4980ec3ad654a1b490ae040d09ad36ef1.tar.gz scummvm-rg350-e7f29db4980ec3ad654a1b490ae040d09ad36ef1.tar.bz2 scummvm-rg350-e7f29db4980ec3ad654a1b490ae040d09ad36ef1.zip |
Check for read/seek errors of the underlying SeekableReadStream in RawStream.
svn-id: r48920
Diffstat (limited to 'sound/decoders')
-rw-r--r-- | sound/decoders/raw.cpp | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/sound/decoders/raw.cpp b/sound/decoders/raw.cpp index 04f6e4255c..d2efb19534 100644 --- a/sound/decoders/raw.cpp +++ b/sound/decoders/raw.cpp @@ -63,7 +63,15 @@ public: // 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; @@ -187,7 +195,12 @@ int RawStream<is16Bit, isUnsigned, isLE>::fillBuffer(int maxSamples) { 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 @@ void RawStream<is16Bit, isUnsigned, isLE>::updateBlockIfNeeded() { 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,7 +262,15 @@ bool RawStream<is16Bit, isUnsigned, isLE>::seek(const Timestamp &where) { 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; } |