[Scummvm-cvs-logs] SF.net SVN: scummvm:[33436] scummvm/trunk/common
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Jul 30 09:39:41 CEST 2008
Revision: 33436
http://scummvm.svn.sourceforge.net/scummvm/?rev=33436&view=rev
Author: fingolfin
Date: 2008-07-30 07:39:41 +0000 (Wed, 30 Jul 2008)
Log Message:
-----------
Changed BufferedReadStream to not permanently decrease its buffer size at the end of a stream (this would fail when using BufferedSeekableReadStream and then seeking back from the end); this also fixes a bug which let you seek back beyond the start of a stream (not that we currently support that in other streams)
Modified Paths:
--------------
scummvm/trunk/common/stream.cpp
scummvm/trunk/common/stream.h
Modified: scummvm/trunk/common/stream.cpp
===================================================================
--- scummvm/trunk/common/stream.cpp 2008-07-30 07:37:00 UTC (rev 33435)
+++ scummvm/trunk/common/stream.cpp 2008-07-30 07:39:41 UTC (rev 33436)
@@ -244,14 +244,16 @@
BufferedReadStream::BufferedReadStream(ReadStream *parentStream, uint32 bufSize, bool disposeParentStream)
: _parentStream(parentStream),
- _bufSize(bufSize),
- _disposeParentStream(disposeParentStream) {
+ _disposeParentStream(disposeParentStream),
+ _pos(0),
+ _bufSize(0),
+ _realBufSize(bufSize) {
assert(parentStream);
- _buf = new byte[_bufSize];
+ _buf = new byte[bufSize];
assert(_buf);
- _pos = _bufSize = bufSize;
}
+
BufferedReadStream::~BufferedReadStream() {
if (_disposeParentStream)
delete _parentStream;
@@ -281,18 +283,14 @@
return alreadyRead + _parentStream->read(dataPtr, dataSize);
// Refill the buffer.
- uint32 bytesRead = _parentStream->read(_buf, _bufSize);
- _pos = 0;
-
// If we didn't read as many bytes as requested, the reason
// is EOF or an error. In that case we truncate the buffer
// size, as well as the number of bytes we are going to
// return to the caller.
- if (_bufSize > bytesRead) {
- _bufSize = bytesRead;
- if (dataSize > bytesRead)
- dataSize = bytesRead;
- }
+ _bufSize = _parentStream->read(_buf, _realBufSize);
+ _pos = 0;
+ if (dataSize > _bufSize)
+ dataSize = _bufSize;
}
// Satisfy the request from the buffer
Modified: scummvm/trunk/common/stream.h
===================================================================
--- scummvm/trunk/common/stream.h 2008-07-30 07:37:00 UTC (rev 33435)
+++ scummvm/trunk/common/stream.h 2008-07-30 07:39:41 UTC (rev 33436)
@@ -428,6 +428,7 @@
byte *_buf;
uint32 _pos;
uint32 _bufSize;
+ uint32 _realBufSize;
public:
BufferedReadStream(ReadStream *parentStream, uint32 bufSize, bool disposeParentStream = false);
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