COMMON: Split common/stream.h into several headers

svn-id: r54385
This commit is contained in:
Max Horn 2010-11-19 17:03:07 +00:00
parent 111384473b
commit 2180b2d6b5
140 changed files with 1000 additions and 720 deletions

View file

@ -33,6 +33,7 @@
#include "backends/fs/stdiostream.h"
#include "dsmain.h"
#include "fat/gba_nds_fat.h"
#include "common/bufferedstream.h"
namespace DS {

View file

@ -27,6 +27,7 @@
#include "engines/engine.h"
#include "backends/fs/abstract-fs.h"
#include "backends/fs/psp/psp-stream.h"
#include "common/bufferedstream.h"
#include <sys/stat.h>
#include <unistd.h>

View file

@ -31,7 +31,7 @@
#include "icon.h"
#include "DCLauncherDialog.h"
#include <common/config-manager.h>
#include <common/stream.h>
#include <common/memstream.h>
#include "backends/plugins/dc/dc-provider.h"
#include "sound/mixer_intern.h"

View file

@ -30,7 +30,7 @@
#include "fat/gba_nds_fat.h"
#include "backends/fs/ds/ds-fs.h"
#include "common/config-manager.h"
#include "common/bufferedstream.h"
#define SAVE_BUFFER_SIZE 100000

68
common/bufferedstream.h Normal file
View file

@ -0,0 +1,68 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef COMMON_BUFFEREDSTREAM_H
#define COMMON_BUFFEREDSTREAM_H
#include "common/stream.h"
namespace Common {
/**
* Take an arbitrary ReadStream and wrap it in a custom stream which
* transparently provides buffering.
* Users can specify how big the buffer should be, and whether the wrapped
* stream should be disposed when the wrapper is disposed.
*
* It is safe to call this with a NULL parameter (in this case, NULL is
* returned).
*/
ReadStream *wrapBufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream);
/**
* Take an arbitrary SeekableReadStream and wrap it in a custom stream which
* transparently provides buffering.
* Users can specify how big the buffer should be, and whether the wrapped
* stream should be disposed when the wrapper is disposed.
*
* It is safe to call this with a NULL parameter (in this case, NULL is
* returned).
*/
SeekableReadStream *wrapBufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream);
/**
* Take an arbitrary WriteStream and wrap it in a custom stream which
* transparently provides buffering.
* Users can specify how big the buffer should be. Currently, the
* parent stream is \em always disposed when the wrapper is disposed.
*
* It is safe to call this with a NULL parameter (in this case, NULL is
* returned).
*/
WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize);
} // End of namespace Common
#endif

81
common/iff_container.cpp Normal file
View file

@ -0,0 +1,81 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "common/iff_container.h"
#include "common/substream.h"
namespace Common {
IFFParser::IFFParser(Common::ReadStream *stream, bool disposeStream) : _stream(stream), _disposeStream(disposeStream) {
setInputStream(stream);
}
IFFParser::~IFFParser() {
if (_disposeStream) {
delete _stream;
}
_stream = 0;
}
void IFFParser::setInputStream(Common::ReadStream *stream) {
assert(stream);
_formChunk.setInputStream(stream);
_chunk.setInputStream(stream);
_formChunk.readHeader();
if (_formChunk.id != ID_FORM) {
error("IFFParser input is not a FORM type IFF file");
}
_formSize = _formChunk.size;
_formType = _formChunk.readUint32BE();
}
void IFFParser::parse(IFFCallback &callback) {
bool stop;
do {
_chunk.feed();
_formChunk.incBytesRead(_chunk.size);
if (_formChunk.hasReadAll()) {
break;
}
_formChunk.incBytesRead(8);
_chunk.readHeader();
// invoke the callback
Common::SubReadStream stream(&_chunk, _chunk.size);
IFFChunk chunk(_chunk.id, _chunk.size, &stream);
stop = callback(chunk);
// eats up all the remaining data in the chunk
while (!stream.eos()) {
stream.readByte();
}
} while (!stop);
}
} // End of namespace Common

View file

@ -223,41 +223,11 @@ protected:
Common::ReadStream *_stream;
bool _disposeStream;
void setInputStream(Common::ReadStream *stream) {
assert(stream);
_formChunk.setInputStream(stream);
_chunk.setInputStream(stream);
_formChunk.readHeader();
if (_formChunk.id != ID_FORM) {
error("IFFParser input is not a FORM type IFF file");
}
_formSize = _formChunk.size;
_formType = _formChunk.readUint32BE();
}
void setInputStream(Common::ReadStream *stream);
public:
IFFParser(Common::ReadStream *stream, bool disposeStream = false) : _stream(stream), _disposeStream(disposeStream) {
setInputStream(stream);
}
~IFFParser() {
if (_disposeStream) {
delete _stream;
}
_stream = 0;
}
/**
* Returns the IFF FORM type.
* @return the IFF FORM type of the stream, or 0 if FORM header is not found.
*/
Common::IFF_ID getFORMType() const;
/**
* Returns the size of the data.
* @return the size of the data in file, or -1 if FORM header is not found.
*/
uint32 getFORMSize() const;
IFFParser(Common::ReadStream *stream, bool disposeStream = false);
~IFFParser();
/**
* Callback type for the parser.
@ -268,31 +238,7 @@ public:
* Parse the IFF container, invoking the callback on each chunk encountered.
* The callback can interrupt the parsing by returning 'true'.
*/
void parse(IFFCallback &callback) {
bool stop;
do {
_chunk.feed();
_formChunk.incBytesRead(_chunk.size);
if (_formChunk.hasReadAll()) {
break;
}
_formChunk.incBytesRead(8);
_chunk.readHeader();
// invoke the callback
Common::SubReadStream stream(&_chunk, _chunk.size);
IFFChunk chunk(_chunk.id, _chunk.size, &stream);
stop = callback(chunk);
// eats up all the remaining data in the chunk
while (!stream.eos()) {
stream.readByte();
}
} while (!stop);
}
void parse(IFFCallback &callback);
};

View file

@ -30,6 +30,8 @@
#include "common/fs.h"
#include "common/macresman.h"
#include "common/md5.h"
#include "common/substream.h"
#include "common/memstream.h"
#ifdef MACOSX
#include "common/config-manager.h"

199
common/memstream.h Normal file
View file

@ -0,0 +1,199 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef COMMON_MEMSTREAM_H
#define COMMON_MEMSTREAM_H
#include "common/stream.h"
namespace Common {
/**
* Simple memory based 'stream', which implements the ReadStream interface for
* a plain memory block.
*/
class MemoryReadStream : public SeekableReadStream {
private:
const byte * const _ptrOrig;
const byte *_ptr;
const uint32 _size;
uint32 _pos;
byte _encbyte;
DisposeAfterUse::Flag _disposeMemory;
bool _eos;
public:
/**
* This constructor takes a pointer to a memory buffer and a length, and
* wraps it. If disposeMemory is true, the MemoryReadStream takes ownership
* of the buffer and hence free's it when destructed.
*/
MemoryReadStream(const byte *dataPtr, uint32 dataSize, DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO) :
_ptrOrig(dataPtr),
_ptr(dataPtr),
_size(dataSize),
_pos(0),
_encbyte(0),
_disposeMemory(disposeMemory),
_eos(false) {}
~MemoryReadStream() {
if (_disposeMemory)
free(const_cast<byte *>(_ptrOrig));
}
void setEnc(byte value) { _encbyte = value; }
uint32 read(void *dataPtr, uint32 dataSize);
bool eos() const { return _eos; }
void clearErr() { _eos = false; }
int32 pos() const { return _pos; }
int32 size() const { return _size; }
bool seek(int32 offs, int whence = SEEK_SET);
};
/**
* This is a wrapper around MemoryReadStream, but it adds non-endian
* read methods whose endianness is set on the stream creation.
*/
class MemoryReadStreamEndian : public MemoryReadStream {
private:
const bool _bigEndian;
public:
MemoryReadStreamEndian(const byte *buf, uint32 len, bool bigEndian = false) : MemoryReadStream(buf, len), _bigEndian(bigEndian) {}
uint16 readUint16() {
uint16 val;
read(&val, 2);
return (_bigEndian) ? TO_BE_16(val) : TO_LE_16(val);
}
uint32 readUint32() {
uint32 val;
read(&val, 4);
return (_bigEndian) ? TO_BE_32(val) : TO_LE_32(val);
}
FORCEINLINE int16 readSint16() {
return (int16)readUint16();
}
FORCEINLINE int32 readSint32() {
return (int32)readUint32();
}
};
/**
* Simple memory based 'stream', which implements the WriteStream interface for
* a plain memory block.
*/
class MemoryWriteStream : public WriteStream {
private:
byte *_ptr;
const uint32 _bufSize;
uint32 _pos;
public:
MemoryWriteStream(byte *buf, uint32 len) : _ptr(buf), _bufSize(len), _pos(0) {}
uint32 write(const void *dataPtr, uint32 dataSize) {
// Write at most as many bytes as are still available...
if (dataSize > _bufSize - _pos)
dataSize = _bufSize - _pos;
memcpy(_ptr, dataPtr, dataSize);
_ptr += dataSize;
_pos += dataSize;
return dataSize;
}
uint32 pos() const { return _pos; }
uint32 size() const { return _bufSize; }
};
/**
* A sort of hybrid between MemoryWriteStream and Array classes. A stream
* that grows as it's written to.
*/
class MemoryWriteStreamDynamic : public WriteStream {
private:
uint32 _capacity;
uint32 _size;
byte *_ptr;
byte *_data;
uint32 _pos;
DisposeAfterUse::Flag _disposeMemory;
void ensureCapacity(uint32 new_len) {
if (new_len <= _capacity)
return;
byte *old_data = _data;
_capacity = new_len + 32;
_data = (byte *)malloc(_capacity);
_ptr = _data + _pos;
if (old_data) {
// Copy old data
memcpy(_data, old_data, _size);
free(old_data);
}
_size = new_len;
}
public:
MemoryWriteStreamDynamic(DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO) : _capacity(0), _size(0), _ptr(0), _data(0), _pos(0), _disposeMemory(disposeMemory) {}
~MemoryWriteStreamDynamic() {
if (_disposeMemory)
free(_data);
}
uint32 write(const void *dataPtr, uint32 dataSize) {
ensureCapacity(_pos + dataSize);
memcpy(_ptr, dataPtr, dataSize);
_ptr += dataSize;
_pos += dataSize;
if (_pos > _size)
_size = _pos;
return dataSize;
}
uint32 pos() const { return _pos; }
uint32 size() const { return _size; }
byte *getData() { return _data; }
bool seek(int32 offset, int whence = SEEK_SET);
};
} // End of namespace Common
#endif

View file

@ -11,6 +11,7 @@ MODULE_OBJS := \
file.o \
fs.o \
hashmap.o \
iff_container.o \
macresman.o \
memorypool.o \
md5.o \

View file

@ -24,6 +24,9 @@
*/
#include "common/stream.h"
#include "common/memstream.h"
#include "common/substream.h"
#include "common/bufferedstream.h"
#include "common/str.h"
#include "common/util.h"
@ -33,7 +36,7 @@ void WriteStream::writeString(const String &str) {
write(str.c_str(), str.size());
}
MemoryReadStream *ReadStream::readStream(uint32 dataSize) {
SeekableReadStream *ReadStream::readStream(uint32 dataSize) {
void *buf = malloc(dataSize);
dataSize = read(buf, dataSize);
assert(dataSize > 0);

View file

@ -32,7 +32,7 @@
namespace Common {
class String;
class MemoryReadStream;
class SeekableReadStream;
/**
* Virtual base class for both ReadStream and WriteStream.
@ -301,7 +301,7 @@ public:
* the end of the stream was reached. Which can be determined by
* calling err() and eos().
*/
MemoryReadStream *readStream(uint32 dataSize);
SeekableReadStream *readStream(uint32 dataSize);
};
@ -389,297 +389,6 @@ public:
virtual String readLine();
};
/**
* SubReadStream provides access to a ReadStream restricted to the range
* [currentPosition, currentPosition+end).
*
* Manipulating the parent stream directly /will/ mess up a substream.
* Likewise, manipulating two substreams of a parent stream will cause them to
* step on each others toes.
*/
class SubReadStream : virtual public ReadStream {
protected:
ReadStream *_parentStream;
DisposeAfterUse::Flag _disposeParentStream;
uint32 _pos;
uint32 _end;
bool _eos;
public:
SubReadStream(ReadStream *parentStream, uint32 end, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO)
: _parentStream(parentStream),
_disposeParentStream(disposeParentStream),
_pos(0),
_end(end),
_eos(false) {
assert(parentStream);
}
~SubReadStream() {
if (_disposeParentStream)
delete _parentStream;
}
virtual bool eos() const { return _eos; }
virtual bool err() const { return _parentStream->err(); }
virtual void clearErr() { _eos = false; _parentStream->clearErr(); }
virtual uint32 read(void *dataPtr, uint32 dataSize);
};
/*
* SeekableSubReadStream provides access to a SeekableReadStream restricted to
* the range [begin, end).
* The same caveats apply to SeekableSubReadStream as do to SeekableReadStream.
*
* Manipulating the parent stream directly /will/ mess up a substream.
* @see SubReadStream
*/
class SeekableSubReadStream : public SubReadStream, public SeekableReadStream {
protected:
SeekableReadStream *_parentStream;
uint32 _begin;
public:
SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO);
virtual int32 pos() const { return _pos - _begin; }
virtual int32 size() const { return _end - _begin; }
virtual bool seek(int32 offset, int whence = SEEK_SET);
};
/**
* This is a wrapper around SeekableSubReadStream, but it adds non-endian
* read methods whose endianness is set on the stream creation.
*
* Manipulating the parent stream directly /will/ mess up a substream.
* @see SubReadStream
*/
class SeekableSubReadStreamEndian : public SeekableSubReadStream {
private:
const bool _bigEndian;
public:
SeekableSubReadStreamEndian(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool bigEndian = false, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO)
: SeekableSubReadStream(parentStream, begin, end, disposeParentStream), _bigEndian(bigEndian) {
}
uint16 readUint16() {
uint16 val;
read(&val, 2);
return (_bigEndian) ? TO_BE_16(val) : TO_LE_16(val);
}
uint32 readUint32() {
uint32 val;
read(&val, 4);
return (_bigEndian) ? TO_BE_32(val) : TO_LE_32(val);
}
FORCEINLINE int16 readSint16() {
return (int16)readUint16();
}
FORCEINLINE int32 readSint32() {
return (int32)readUint32();
}
};
/**
* Take an arbitrary ReadStream and wrap it in a custom stream which
* transparently provides buffering.
* Users can specify how big the buffer should be, and whether the wrapped
* stream should be disposed when the wrapper is disposed.
*
* It is safe to call this with a NULL parameter (in this case, NULL is
* returned).
*/
ReadStream *wrapBufferedReadStream(ReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream);
/**
* Take an arbitrary SeekableReadStream and wrap it in a custom stream which
* transparently provides buffering.
* Users can specify how big the buffer should be, and whether the wrapped
* stream should be disposed when the wrapper is disposed.
*
* It is safe to call this with a NULL parameter (in this case, NULL is
* returned).
*/
SeekableReadStream *wrapBufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream);
/**
* Take an arbitrary WriteStream and wrap it in a custom stream which
* transparently provides buffering.
* Users can specify how big the buffer should be. Currently, the
* parent stream is \em always disposed when the wrapper is disposed.
*
* It is safe to call this with a NULL parameter (in this case, NULL is
* returned).
*/
WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize);
/**
* Simple memory based 'stream', which implements the ReadStream interface for
* a plain memory block.
*/
class MemoryReadStream : public SeekableReadStream {
private:
const byte * const _ptrOrig;
const byte *_ptr;
const uint32 _size;
uint32 _pos;
byte _encbyte;
DisposeAfterUse::Flag _disposeMemory;
bool _eos;
public:
/**
* This constructor takes a pointer to a memory buffer and a length, and
* wraps it. If disposeMemory is true, the MemoryReadStream takes ownership
* of the buffer and hence free's it when destructed.
*/
MemoryReadStream(const byte *dataPtr, uint32 dataSize, DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO) :
_ptrOrig(dataPtr),
_ptr(dataPtr),
_size(dataSize),
_pos(0),
_encbyte(0),
_disposeMemory(disposeMemory),
_eos(false) {}
~MemoryReadStream() {
if (_disposeMemory)
free(const_cast<byte *>(_ptrOrig));
}
void setEnc(byte value) { _encbyte = value; }
uint32 read(void *dataPtr, uint32 dataSize);
bool eos() const { return _eos; }
void clearErr() { _eos = false; }
int32 pos() const { return _pos; }
int32 size() const { return _size; }
bool seek(int32 offs, int whence = SEEK_SET);
};
/**
* This is a wrapper around MemoryReadStream, but it adds non-endian
* read methods whose endianness is set on the stream creation.
*/
class MemoryReadStreamEndian : public MemoryReadStream {
private:
const bool _bigEndian;
public:
MemoryReadStreamEndian(const byte *buf, uint32 len, bool bigEndian = false) : MemoryReadStream(buf, len), _bigEndian(bigEndian) {}
uint16 readUint16() {
uint16 val;
read(&val, 2);
return (_bigEndian) ? TO_BE_16(val) : TO_LE_16(val);
}
uint32 readUint32() {
uint32 val;
read(&val, 4);
return (_bigEndian) ? TO_BE_32(val) : TO_LE_32(val);
}
FORCEINLINE int16 readSint16() {
return (int16)readUint16();
}
FORCEINLINE int32 readSint32() {
return (int32)readUint32();
}
};
/**
* Simple memory based 'stream', which implements the WriteStream interface for
* a plain memory block.
*/
class MemoryWriteStream : public WriteStream {
private:
byte *_ptr;
const uint32 _bufSize;
uint32 _pos;
public:
MemoryWriteStream(byte *buf, uint32 len) : _ptr(buf), _bufSize(len), _pos(0) {}
uint32 write(const void *dataPtr, uint32 dataSize) {
// Write at most as many bytes as are still available...
if (dataSize > _bufSize - _pos)
dataSize = _bufSize - _pos;
memcpy(_ptr, dataPtr, dataSize);
_ptr += dataSize;
_pos += dataSize;
return dataSize;
}
uint32 pos() const { return _pos; }
uint32 size() const { return _bufSize; }
};
/**
* A sort of hybrid between MemoryWriteStream and Array classes. A stream
* that grows as it's written to.
*/
class MemoryWriteStreamDynamic : public WriteStream {
private:
uint32 _capacity;
uint32 _size;
byte *_ptr;
byte *_data;
uint32 _pos;
DisposeAfterUse::Flag _disposeMemory;
void ensureCapacity(uint32 new_len) {
if (new_len <= _capacity)
return;
byte *old_data = _data;
_capacity = new_len + 32;
_data = (byte *)malloc(_capacity);
_ptr = _data + _pos;
if (old_data) {
// Copy old data
memcpy(_data, old_data, _size);
free(old_data);
}
_size = new_len;
}
public:
MemoryWriteStreamDynamic(DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO) : _capacity(0), _size(0), _ptr(0), _data(0), _pos(0), _disposeMemory(disposeMemory) {}
~MemoryWriteStreamDynamic() {
if (_disposeMemory)
free(_data);
}
uint32 write(const void *dataPtr, uint32 dataSize) {
ensureCapacity(_pos + dataSize);
memcpy(_ptr, dataPtr, dataSize);
_ptr += dataSize;
_pos += dataSize;
if (_pos > _size)
_size = _pos;
return dataSize;
}
uint32 pos() const { return _pos; }
uint32 size() const { return _size; }
byte *getData() { return _data; }
bool seek(int32 offset, int whence = SEEK_SET);
};
} // End of namespace Common
#endif

129
common/substream.h Normal file
View file

@ -0,0 +1,129 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef COMMON_SUBSTREAM_H
#define COMMON_SUBSTREAM_H
#include "common/stream.h"
namespace Common {
/**
* SubReadStream provides access to a ReadStream restricted to the range
* [currentPosition, currentPosition+end).
*
* Manipulating the parent stream directly /will/ mess up a substream.
* Likewise, manipulating two substreams of a parent stream will cause them to
* step on each others toes.
*/
class SubReadStream : virtual public ReadStream {
protected:
ReadStream *_parentStream;
DisposeAfterUse::Flag _disposeParentStream;
uint32 _pos;
uint32 _end;
bool _eos;
public:
SubReadStream(ReadStream *parentStream, uint32 end, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO)
: _parentStream(parentStream),
_disposeParentStream(disposeParentStream),
_pos(0),
_end(end),
_eos(false) {
assert(parentStream);
}
~SubReadStream() {
if (_disposeParentStream)
delete _parentStream;
}
virtual bool eos() const { return _eos; }
virtual bool err() const { return _parentStream->err(); }
virtual void clearErr() { _eos = false; _parentStream->clearErr(); }
virtual uint32 read(void *dataPtr, uint32 dataSize);
};
/*
* SeekableSubReadStream provides access to a SeekableReadStream restricted to
* the range [begin, end).
* The same caveats apply to SeekableSubReadStream as do to SeekableReadStream.
*
* Manipulating the parent stream directly /will/ mess up a substream.
* @see SubReadStream
*/
class SeekableSubReadStream : public SubReadStream, public SeekableReadStream {
protected:
SeekableReadStream *_parentStream;
uint32 _begin;
public:
SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO);
virtual int32 pos() const { return _pos - _begin; }
virtual int32 size() const { return _end - _begin; }
virtual bool seek(int32 offset, int whence = SEEK_SET);
};
/**
* This is a wrapper around SeekableSubReadStream, but it adds non-endian
* read methods whose endianness is set on the stream creation.
*
* Manipulating the parent stream directly /will/ mess up a substream.
* @see SubReadStream
*/
class SeekableSubReadStreamEndian : public SeekableSubReadStream {
private:
const bool _bigEndian;
public:
SeekableSubReadStreamEndian(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool bigEndian = false, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO)
: SeekableSubReadStream(parentStream, begin, end, disposeParentStream), _bigEndian(bigEndian) {
}
uint16 readUint16() {
uint16 val;
read(&val, 2);
return (_bigEndian) ? TO_BE_16(val) : TO_LE_16(val);
}
uint32 readUint32() {
uint32 val;
read(&val, 4);
return (_bigEndian) ? TO_BE_32(val) : TO_LE_32(val);
}
FORCEINLINE int16 readSint16() {
return (int16)readUint16();
}
FORCEINLINE int32 readSint32() {
return (int32)readUint32();
}
};
} // End of namespace Common
#endif

View file

@ -34,6 +34,8 @@
#include "common/unarj.h"
#include "common/file.h"
#include "common/hash-str.h"
#include "common/memstream.h"
#include "common/bufferedstream.h"
namespace Common {

View file

@ -106,6 +106,7 @@ typedef struct {
#include "common/fs.h"
#include "common/unzip.h"
#include "common/file.h"
#include "common/memstream.h"
#include "common/hashmap.h"
#include "common/hash-str.h"

View file

@ -27,7 +27,7 @@
#include "common/util.h"
#include "common/archive.h"
#include "common/fs.h"
#include "common/stream.h"
#include "common/memstream.h"
namespace Common {

View file

@ -27,6 +27,7 @@
#include "common/events.h"
#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/memstream.h"
#include "common/savefile.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"

View file

@ -30,6 +30,7 @@
#include "graphics/cursorman.h"
#include "common/events.h"
#include "common/memstream.h"
#include "common/savefile.h"
namespace Agi {

View file

@ -26,6 +26,7 @@
#include "common/config-manager.h"
#include "common/fs.h"
#include "common/md5.h"
#include "common/memstream.h"
#include "common/str-array.h"
#include "agi/agi.h"
@ -839,7 +840,7 @@ bool SoundGen2GS::loadInstrumentHeaders(const Common::FSNode &exePath, const IIg
}
// Read the whole executable file into memory
Common::SharedPtr<Common::MemoryReadStream> data(file.readStream(file.size()));
Common::SharedPtr<Common::SeekableReadStream> data(file.readStream(file.size()));
file.close();
// Check that we got enough data to be able to parse the instruments
@ -891,7 +892,7 @@ bool SoundGen2GS::loadWaveFile(const Common::FSNode &wavePath, const IIgsExeInfo
// Open the wave file and read it into memory
file.open(wavePath);
Common::SharedPtr<Common::MemoryReadStream> uint8Wave(file.readStream(file.size()));
Common::SharedPtr<Common::SeekableReadStream> uint8Wave(file.readStream(file.size()));
file.close();
// Check that we got the whole wave file

View file

@ -47,6 +47,7 @@
#include "sound/midiparser.h"
#include "common/config-manager.h"
#include "common/file.h"
#include "common/memstream.h"
#include "common/stream.h"
#include "agi/agi.h"

View file

@ -27,6 +27,7 @@
#include "common/file.h"
#include "common/memstream.h"
#include "common/util.h"
#include "agos/agos.h"

View file

@ -25,6 +25,7 @@
#include "common/config-manager.h"
#include "common/file.h"
#include "common/memstream.h"
#include "agos/intern.h"
#include "agos/agos.h"

View file

@ -24,6 +24,7 @@
*/
#include "common/file.h"
#include "common/memstream.h"
#include "common/util.h"
#include "agos/agos.h"
@ -305,7 +306,7 @@ class CompressedSound : public BaseSound {
public:
CompressedSound(Audio::Mixer *mixer, Common::File *file, uint32 base) : BaseSound(mixer, file, base, false) {}
Common::MemoryReadStream *loadStream(uint sound) const {
Common::SeekableReadStream *loadStream(uint sound) const {
if (_offsets == NULL)
return NULL;
@ -334,7 +335,7 @@ class MP3Sound : public CompressedSound {
public:
MP3Sound(Audio::Mixer *mixer, Common::File *file, uint32 base = 0) : CompressedSound(mixer, file, base) {}
Audio::AudioStream *makeAudioStream(uint sound) {
Common::MemoryReadStream *tmp = loadStream(sound);
Common::SeekableReadStream *tmp = loadStream(sound);
if (!tmp)
return NULL;
return Audio::makeMP3Stream(tmp, DisposeAfterUse::YES);
@ -350,7 +351,7 @@ class VorbisSound : public CompressedSound {
public:
VorbisSound(Audio::Mixer *mixer, Common::File *file, uint32 base = 0) : CompressedSound(mixer, file, base) {}
Audio::AudioStream *makeAudioStream(uint sound) {
Common::MemoryReadStream *tmp = loadStream(sound);
Common::SeekableReadStream *tmp = loadStream(sound);
if (!tmp)
return NULL;
return Audio::makeVorbisStream(tmp, DisposeAfterUse::YES);
@ -366,7 +367,7 @@ class FLACSound : public CompressedSound {
public:
FLACSound(Audio::Mixer *mixer, Common::File *file, uint32 base = 0) : CompressedSound(mixer, file, base) {}
Audio::AudioStream *makeAudioStream(uint sound) {
Common::MemoryReadStream *tmp = loadStream(sound);
Common::SeekableReadStream *tmp = loadStream(sound);
if (!tmp)
return NULL;
return Audio::makeFLACStream(tmp, DisposeAfterUse::YES);
@ -775,7 +776,7 @@ void Sound::playVoiceData(byte *soundData, uint sound) {
void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, int pan, int vol, bool loop) {
int size = READ_LE_UINT32(soundData + 4) + 8;
Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundData, size);
Common::SeekableReadStream *stream = new Common::MemoryReadStream(soundData, size);
Audio::RewindableAudioStream *sndStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
convertVolume(vol);

View file

@ -28,7 +28,7 @@
*/
#include "common/endian.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "cine/cine.h"
#include "cine/anim.h"
@ -485,7 +485,7 @@ void convert4BBP(byte *dest, const byte *source, int16 width, int16 height) {
* @param[out] animHeader Image header reference
* @param readS Input stream open for reading
*/
void loadAnimHeader(AnimHeaderStruct &animHeader, Common::MemoryReadStream readS) {
void loadAnimHeader(AnimHeaderStruct &animHeader, Common::SeekableReadStream &readS) {
animHeader.field_0 = readS.readByte();
animHeader.field_1 = readS.readByte();
animHeader.field_2 = readS.readByte();

View file

@ -25,7 +25,7 @@
#include "common/endian.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "cine/cine.h"
#include "cine/various.h"

View file

@ -25,7 +25,7 @@
#include "common/endian.h"
#include "common/scummsys.h"
#include "common/memstream.h"
#include "common/util.h"
#include "cine/cine.h"

View file

@ -801,7 +801,7 @@ bool CineEngine::makeLoad(char *saveName) {
// Hopefully devices with more limited memory can also cope with this memory allocation.
saveSize = 256 * 1024;
}
Common::SharedPtr<Common::MemoryReadStream> in(saveFile->readStream(saveSize));
Common::SharedPtr<Common::SeekableReadStream> in(saveFile->readStream(saveSize));
// Try to detect the used savegame format
enum CineSaveGameFormat saveGameFormat = detectSaveGameFormat(*in);

View file

@ -25,7 +25,7 @@
#include "common/endian.h"
#include "common/file.h"
#include "common/system.h"
#include "common/memstream.h"
#include "cine/cine.h"
#include "cine/sound.h"

View file

@ -25,6 +25,7 @@
#include "cruise/cruise_main.h"
#include "common/endian.h"
#include "common/memstream.h"
namespace Cruise {

View file

@ -23,7 +23,7 @@
*
*/
#include "common/stream.h"
#include "common/memstream.h"
#include "cruise/cruise.h"
#include "cruise/cruise_main.h"

View file

@ -31,6 +31,8 @@
#include "draci/sound.h"
#include "draci/surface.h"
#include "common/memstream.h"
namespace Draci {
Animation::Animation(DraciEngine *vm, int id, uint z, bool playing) : _vm(vm) {

View file

@ -25,7 +25,7 @@
#include "common/debug.h"
#include "common/str.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "draci/barchive.h"
#include "draci/draci.h"

View file

@ -25,7 +25,7 @@
#include "common/keyboard.h"
#include "common/serializer.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "common/system.h"
#include "common/util.h"

View file

@ -23,7 +23,7 @@
*
*/
#include "common/stream.h"
#include "common/memstream.h"
#include "common/system.h"
#include "draci/draci.h"

View file

@ -25,7 +25,7 @@
#include "common/array.h"
#include "common/debug.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "common/stack.h"
#include "draci/draci.h"

View file

@ -28,7 +28,8 @@
#include "common/debug.h"
#include "common/file.h"
#include "common/str.h"
#include "common/stream.h"
#include "common/substream.h"
#include "common/memstream.h"
#include "common/unzip.h"
#include "draci/sound.h"
@ -301,7 +302,7 @@ uint Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffe
// only used for dubbing, which is only played from one place in
// script.cpp, which blocks until the dubbed sentence has finished
// playing.
Common::SeekableReadStream* stream;
Common::SeekableReadStream *stream;
const int skip = buffer._format == RAW80 ? 80 : 0;
if (buffer._stream) {
stream = new Common::SeekableSubReadStream(

View file

@ -23,7 +23,7 @@
*
*/
#include "common/stream.h"
#include "common/memstream.h"
#include "draci/draci.h"
#include "draci/font.h"

View file

@ -23,9 +23,7 @@
*
*/
#include <stdlib.h>
#include "common/stream.h"
#include "common/memstream.h"
#include "draci/draci.h"
#include "draci/animation.h"

View file

@ -25,7 +25,7 @@
#include "common/endian.h"
#include "common/types.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "gob/gob.h"
#include "gob/dataio.h"

View file

@ -25,6 +25,7 @@
#include "common/endian.h"
#include "common/file.h"
#include "common/memstream.h"
#include "gob/gob.h"
#include "gob/demos/demoplayer.h"

View file

@ -23,7 +23,7 @@
*
*/
#include "common/stream.h"
#include "common/memstream.h"
#include "gob/gob.h"
#include "gob/map.h"

View file

@ -25,7 +25,7 @@
#include "common/util.h"
#include "common/endian.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "gob/gob.h"
#include "gob/resources.h"

View file

@ -24,6 +24,7 @@
*/
#include "common/endian.h"
#include "common/memstream.h"
#include "common/savefile.h"
#include "gob/gob.h"

View file

@ -77,7 +77,7 @@ protected:
Common::String _fileName;
byte *_data;
Common::MemoryReadStream *_stream;
Common::SeekableReadStream *_stream;
Common::InSaveFile *openSave() const;

View file

@ -25,6 +25,7 @@
#include "common/util.h"
#include "common/endian.h"
#include "common/memstream.h"
#include "common/system.h"
#include "common/savefile.h"

View file

@ -24,7 +24,7 @@
*/
#include "common/util.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "sound/mixer.h"
#include "sound/decoders/raw.h"
#include "sound/decoders/wave.h"

View file

@ -30,6 +30,7 @@
#include "backends/audiocd/audiocd.h"
#include "common/config-manager.h"
#include "common/macresman.h"
#include "common/memstream.h"
#include "sound/midiparser.h"
namespace Groovie {

View file

@ -25,6 +25,7 @@
#include "common/archive.h"
#include "common/macresman.h"
#include "common/substream.h"
#include "groovie/resource.h"
#include "groovie/groovie.h"

View file

@ -26,6 +26,7 @@
#include "groovie/saveload.h"
#include "common/system.h"
#include "common/substream.h"
#define SUPPORTED_SAVEFILE_VERSION 1
// 0 - Just script variables, compatible with the original

View file

@ -26,8 +26,9 @@
#include "kyra/resource_intern.h"
#include "kyra/resource.h"
#include "common/stream.h"
#include "common/endian.h"
#include "common/memstream.h"
#include "common/substream.h"
namespace Kyra {

View file

@ -25,6 +25,7 @@
#include "common/endian.h"
#include "common/savefile.h"
#include "common/substream.h"
#include "common/system.h"
#include "kyra/kyra_v2.h"

View file

@ -31,6 +31,7 @@
#include "common/endian.h"
#include "common/savefile.h"
#include "common/substream.h"
#include "common/system.h"
#include "graphics/scaler.h"

View file

@ -25,6 +25,7 @@
#include "common/endian.h"
#include "common/savefile.h"
#include "common/substream.h"
#include "common/system.h"
#include "kyra/kyra_mr.h"

View file

@ -25,6 +25,7 @@
#include "common/endian.h"
#include "common/memstream.h"
#include "common/system.h"
#include "engines/util.h"

View file

@ -225,7 +225,7 @@ AnimFrame *Animation::processChunkFrame(Common::SeekableReadStream *in, const Ch
assert (c.frame == 0);
// Create a temporary chunk buffer
Common::MemoryReadStream *str = in->readStream(c.size);
Common::SeekableReadStream *str = in->readStream(c.size);
// Read the frame information
FrameInfo i;

View file

@ -32,6 +32,7 @@
#include "common/debug.h"
#include "common/file.h"
#include "common/substream.h"
namespace LastExpress {

View file

@ -42,7 +42,7 @@ bool Cursor::load(Common::SeekableReadStream *stream) {
return false;
// Load the whole file to memory
Common::MemoryReadStream *data = stream->readStream((uint32) stream->size());
Common::SeekableReadStream *data = stream->readStream((uint32) stream->size());
delete stream;
if (!data)
return false;

View file

@ -32,6 +32,7 @@
#include "sound/decoders/adpcm.h"
#include "sound/audiostream.h"
#include "common/memstream.h"
namespace LastExpress {

View file

@ -78,6 +78,7 @@
#include "common/savefile.h"
#include "common/serializer.h"
#include "common/memstream.h"
namespace LastExpress {

View file

@ -28,6 +28,8 @@
#include "m4/compression.h"
#include "m4/graphics.h"
#include "common/memstream.h"
namespace M4 {
BaseAsset::BaseAsset(MadsM4Engine *vm) : _vm(vm) {
@ -382,7 +384,7 @@ void SpriteAsset::loadStreamingFrame(M4Sprite *frame, int frameIndex, int destX,
loadFrameHeader(frameHeader);
if (frameHeader.w > 0 && frameHeader.h > 0) {
Common::MemoryReadStream *frameData = _stream->readStream(getFrameSize(frameIndex));
Common::SeekableReadStream *frameData = _stream->readStream(getFrameSize(frameIndex));
if (frameHeader.stream) {
frame->loadDeltaRle(frameData, destX - frameHeader.x, destY - frameHeader.y);
} else {

View file

@ -26,6 +26,8 @@
#include "m4/compression.h"
#include "m4/m4.h"
#include "common/memstream.h"
namespace M4 {
const char *madsPackString = "MADSPACK";
@ -90,6 +92,10 @@ void MadsPack::initialise(Common::SeekableReadStream *stream) {
_dataOffset = stream->pos();
}
Common::SeekableReadStream *MadsPack::getItemStream(int index) {
return new Common::MemoryReadStream(_items[index].data, _items[index].size, DisposeAfterUse::NO);
}
MadsPack::~MadsPack() {
for (int i = 0; i < _count; ++i)
delete[] _items[i].data;

View file

@ -58,9 +58,7 @@ public:
int getCount() const { return _count; }
MadsPackEntry &getItem(int index) const { return _items[index]; }
MadsPackEntry &operator[](int index) const { return _items[index]; }
Common::MemoryReadStream *getItemStream(int index) {
return new Common::MemoryReadStream(_items[index].data, _items[index].size, DisposeAfterUse::NO);
}
Common::SeekableReadStream *getItemStream(int index);
int getDataOffset() const { return _dataOffset; }
};

View file

@ -25,6 +25,7 @@
#include "common/array.h"
#include "common/hashmap.h"
#include "common/substream.h"
#include "m4/converse.h"
#include "m4/resource.h"

View file

@ -740,7 +740,7 @@ void M4Surface::madsLoadBackground(int roomNumber, RGBList **palData) {
void M4Surface::rexLoadBackground(Common::SeekableReadStream *source, RGBList **palData) {
MadsPack packData(source);
Common::MemoryReadStream *sourceUnc = packData.getItemStream(0);
Common::SeekableReadStream *sourceUnc = packData.getItemStream(0);
int sceneWidth = sourceUnc->readUint16LE();
int sceneHeight = sourceUnc->readUint16LE();

View file

@ -288,7 +288,7 @@ void MadsM4Engine::dumpFile(const char* filename, bool uncompress) {
}
} else {
MadsPack packData(fileS);
Common::MemoryReadStream *sourceUnc;
Common::SeekableReadStream *sourceUnc;
for (int i = 0; i < packData.getCount(); i++) {
sourceUnc = packData.getItemStream(i);
debugCN(kDebugCore, "Dumping compressed chunk %i of %i, size is %i\n", i + 1, packData.getCount(), sourceUnc->size());

View file

@ -28,7 +28,7 @@
#include "m4/m4.h"
#include "m4/midi.h"
#include "common/stream.h"
#include "common/memstream.h"
namespace M4 {

View file

@ -27,6 +27,8 @@
#include "m4/resource.h"
#include "m4/events.h"
#include "common/substream.h"
namespace M4 {
FileSystem::FileSystem(const char *hashFilename) {

View file

@ -223,7 +223,7 @@ public:
uint32 readUint32();
protected:
ScriptInterpreter *_inter;
Common::MemoryReadStream *_code;
Common::SeekableReadStream *_code;
};
struct ScriptFunctionEntry {

View file

@ -25,6 +25,8 @@
#include "m4/woodscript.h"
#include "common/memstream.h"
namespace M4 {
// FIXME: Put in Engine/WoodScript class

View file

@ -77,7 +77,7 @@ public:
uint32 pos() const { return _code->pos() / 4; }
protected:
WoodScript *_ws;
Common::MemoryReadStream *_code;
Common::SeekableReadStream *_code;
Sequence *_sequence;
static int32 _dataFormats[];
bool decodeArgument(int32 format, int32 data, long *&arg, long &value);

View file

@ -275,7 +275,7 @@ void GameDatabase::openFromRed(const char *redFilename, const char *filename) {
_isRedSource = true;
_filename = filename;
_redFilename = redFilename;
Common::MemoryReadStream *fileS = RedReader::loadFromRed(redFilename, filename);
Common::SeekableReadStream *fileS = RedReader::loadFromRed(redFilename, filename);
if (!fileS)
error("GameDatabase::openFromRed() Could not load %s from %s", filename, redFilename);
load(*fileS);
@ -289,7 +289,7 @@ void GameDatabase::reload() {
error("GameDatabase::reload() Could not open %s", _filename.c_str());
reloadFromStream(fd);
} else {
Common::MemoryReadStream *fileS = RedReader::loadFromRed(_redFilename.c_str(), _filename.c_str());
Common::SeekableReadStream *fileS = RedReader::loadFromRed(_redFilename.c_str(), _filename.c_str());
if (!fileS)
error("GameDatabase::openFromRed() Could not load %s from %s", _filename.c_str(), _redFilename.c_str());
reloadFromStream(*fileS);

View file

@ -24,11 +24,11 @@
*/
#include "made/redreader.h"
#include "common/memstream.h"
namespace Made {
Common::MemoryReadStream *RedReader::load(const char *redFilename, const char *filename) {
Common::SeekableReadStream *RedReader::load(const char *redFilename, const char *filename) {
Common::File fd;
FileEntry fileEntry;
@ -49,9 +49,9 @@ Common::MemoryReadStream *RedReader::load(const char *redFilename, const char *f
}
Common::MemoryReadStream *RedReader::loadFromRed(const char *redFilename, const char *filename) {
Common::SeekableReadStream *RedReader::loadFromRed(const char *redFilename, const char *filename) {
RedReader* red = new RedReader();
Common::MemoryReadStream* stream = red->load(redFilename, filename);
Common::SeekableReadStream *stream = red->load(redFilename, filename);
delete red;
return stream;
}

View file

@ -34,8 +34,8 @@ namespace Made {
class RedReader {
public:
Common::MemoryReadStream *load(const char *redFilename, const char *filename);
static Common::MemoryReadStream *loadFromRed(const char *redFilename, const char *filename);
Common::SeekableReadStream *load(const char *redFilename, const char *filename);
static Common::SeekableReadStream *loadFromRed(const char *redFilename, const char *filename);
private:
struct FileEntry {
uint32 compSize, origSize;

View file

@ -24,6 +24,7 @@
*/
#include "common/endian.h"
#include "common/memstream.h"
#include "sound/mixer.h"
#include "sound/decoders/raw.h"

View file

@ -28,6 +28,7 @@
#include "common/debug.h"
#include "common/util.h"
#include "common/endian.h"
#include "common/memstream.h"
#include "common/system.h"
namespace Mohawk {

View file

@ -31,6 +31,7 @@
#include "mohawk/graphics.h"
#include "common/config-file.h"
#include "common/substream.h"
namespace Mohawk {

View file

@ -25,6 +25,7 @@
#include "mohawk/resource.h"
#include "common/substream.h"
#include "common/util.h"
namespace Mohawk {

View file

@ -28,6 +28,7 @@
#include "common/savefile.h"
#include "common/str.h"
#include "common/memstream.h"
namespace Mohawk {

View file

@ -25,6 +25,8 @@
#include "common/config-manager.h"
#include "common/fs.h"
#include "common/memstream.h"
#include "common/substream.h"
#include "parallaction/parser.h"
#include "parallaction/parallaction.h"
@ -1087,4 +1089,4 @@ Common::SeekableReadStream* AmigaDisk_ns::loadSound(const char* name) {
return tryOpenFile(path);
}
} // namespace Parallaction
} // End of namespace Parallaction

View file

@ -24,7 +24,7 @@
*/
#include "common/endian.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "parallaction/parallaction.h"
@ -670,7 +670,6 @@ GfxObj* DosDisk_br::createInventoryObjects(Common::SeekableReadStream &stream) {
void Parallaction_ns::initFonts() {
if (getPlatform() == Common::kPlatformPC) {
_dialogueFont = _disk->loadFont("comic");
_labelFont = _disk->loadFont("topaz");
@ -683,7 +682,6 @@ void Parallaction_ns::initFonts() {
_menuFont = _disk->loadFont("slide");
_introFont = _disk->loadFont("intro");
}
}
void Parallaction_br::initFonts() {
@ -701,4 +699,4 @@ void Parallaction_br::initFonts() {
}
}
}
} // End of namespace Parallaction

View file

@ -1004,4 +1004,4 @@ void Parallaction::scheduleLocationSwitch(const char *location) {
}
} // namespace Parallaction
} // End of namespace Parallaction

View file

@ -606,7 +606,7 @@ private:
extern Parallaction *_vm;
} // namespace Parallaction
} // End of namespace Parallaction
#endif

View file

@ -257,5 +257,4 @@ void Parser::parseStatement() {
(*(*_currentOpcodes)[_lookup])();
}
} // namespace Parallaction
} // End of namespace Parallaction

View file

@ -409,13 +409,6 @@ public:
virtual void parse(Script *script, ProgramPtr program);
};
} // namespace Parallaction
} // End of namespace Parallaction
#endif

View file

@ -26,6 +26,7 @@
#include "common/debug.h"
#include "common/endian.h"
#include "common/config-manager.h"
#include "common/substream.h"
#include "queen/resource.h"
namespace Queen {

View file

@ -26,7 +26,7 @@
#include "common/config-manager.h"
#include "common/endian.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "queen/sound.h"
#include "queen/input.h"
@ -119,7 +119,7 @@ public:
MP3Sound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {}
protected:
void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
Common::MemoryReadStream *tmp = f->readStream(size);
Common::SeekableReadStream *tmp = f->readStream(size);
assert(tmp);
_mixer->playStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeMP3Stream(tmp, DisposeAfterUse::YES)));
}
@ -132,7 +132,7 @@ public:
OGGSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {}
protected:
void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
Common::MemoryReadStream *tmp = f->readStream(size);
Common::SeekableReadStream *tmp = f->readStream(size);
assert(tmp);
_mixer->playStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeVorbisStream(tmp, DisposeAfterUse::YES)));
}
@ -145,7 +145,7 @@ public:
FLACSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {}
protected:
void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) {
Common::MemoryReadStream *tmp = f->readStream(size);
Common::SeekableReadStream *tmp = f->readStream(size);
assert(tmp);
_mixer->playStream(Audio::Mixer::kSFXSoundType, soundHandle, new AudioStreamWrapper(Audio::makeFLACStream(tmp, DisposeAfterUse::YES)));
}

View file

@ -36,6 +36,7 @@
#include "sound/decoders/raw.h"
#include "common/config-manager.h"
#include "common/file.h"
#include "common/substream.h"
namespace Saga {

View file

@ -30,7 +30,7 @@
#include "common/array.h"
#include "common/random.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "sound/mididrv.h"
#include "saga/gfx.h"

View file

@ -30,7 +30,7 @@
#include "sci/graphics/maciconbar.h"
#include "sci/graphics/palette.h"
#include "common/stream.h"
#include "common/memstream.h"
#include "common/system.h"
#include "graphics/pict.h"
#include "graphics/surface.h"
@ -54,7 +54,7 @@ void GfxMacIconBar::drawIcons() {
if (!res)
continue;
Common::MemoryReadStream *stream = new Common::MemoryReadStream(res->data, res->size);
Common::SeekableReadStream *stream = new Common::MemoryReadStream(res->data, res->size);
Graphics::Surface *surf = pict->decodeImage(stream, pal);
remapColors(surf, pal);

View file

@ -32,6 +32,7 @@
#include "backends/audiocd/audiocd.h"
#include "common/file.h"
#include "common/memstream.h"
#include "common/system.h"
#include "sound/audiostream.h"
@ -281,7 +282,7 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
// additional buffer here. MP3/OGG/FLAC decompression works on-the-fly
// instead.
memcpy(compressedData, audioRes->data, audioRes->size);
Common::MemoryReadStream *compressedStream = new Common::MemoryReadStream(compressedData, audioRes->size, DisposeAfterUse::YES);
Common::SeekableReadStream *compressedStream = new Common::MemoryReadStream(compressedData, audioRes->size, DisposeAfterUse::YES);
switch (audioCompressionType) {
case MKID_BE('MP3 '):
@ -315,7 +316,7 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
}
} else if (audioRes->size > 4 && READ_BE_UINT32(audioRes->data) == MKID_BE('RIFF')) {
// WAVE detected
Common::MemoryReadStream *waveStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
Common::SeekableReadStream *waveStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
// Calculate samplelen from WAVE header
int waveSize = 0, waveRate = 0;
@ -327,7 +328,7 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES);
} else if (audioRes->size > 4 && READ_BE_UINT32(audioRes->data) == MKID_BE('FORM')) {
// AIFF detected
Common::MemoryReadStream *waveStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
Common::SeekableReadStream *waveStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
// Calculate samplelen from AIFF header
int waveSize = 0, waveRate = 0;
@ -340,7 +341,7 @@ Audio::RewindableAudioStream *AudioPlayer::getAudioStream(uint32 number, uint32
} else if (audioRes->size > 14 && READ_BE_UINT16(audioRes->data) == 1 && READ_BE_UINT16(audioRes->data + 2) == 1
&& READ_BE_UINT16(audioRes->data + 4) == 5 && READ_BE_UINT32(audioRes->data + 10) == 0x00018051) {
// Mac snd detected
Common::MemoryReadStream *sndStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
Common::SeekableReadStream *sndStream = new Common::MemoryReadStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
audioSeekStream = Audio::makeMacSndStream(sndStream, DisposeAfterUse::YES);
} else {

View file

@ -29,6 +29,7 @@
#include "common/file.h"
#include "common/frac.h"
#include "common/memstream.h"
#include "common/util.h"
namespace Sci {

View file

@ -27,6 +27,7 @@
#include "common/config-manager.h"
#include "common/file.h"
#include "common/memstream.h"
#include "sound/fmopl.h"
#include "sound/softsynth/emumidi.h"

View file

@ -27,6 +27,8 @@
#include "scumm/scumm.h"
#include "common/substream.h"
namespace Scumm {
#pragma mark -

View file

@ -27,6 +27,7 @@
#define SCUMM_FILE_H
#include "common/file.h"
#include "common/memstream.h"
#include "scumm/detection.h"

View file

@ -27,6 +27,7 @@
#define SCUMM_FILE_NES_H
#include "common/file.h"
#include "common/memstream.h"
#include "scumm/file.h"

View file

@ -26,6 +26,7 @@
#ifdef ENABLE_HE
#include "common/system.h"
#include "common/memstream.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
#include "sound/decoders/raw.h"

View file

@ -832,7 +832,7 @@ int Win32ResExtractor::convertIcons(byte *data, int datasize, byte **cursor, int
uint32 c, d;
int completed;
int matched = 0;
MemoryReadStream *in = new MemoryReadStream(data, datasize);
Common::MemoryReadStream *in = new Common::MemoryReadStream(data, datasize);
if (!in->read(&dir, sizeof(Win32CursorIconFileDir)- sizeof(Win32CursorIconFileDirEntry)))
goto cleanup;

View file

@ -147,9 +147,6 @@ public:
bool _arg_raw;
Common::String _fileName;
CachedCursor _cursorCache[MAX_CACHED_CURSORS];
typedef Common::MemoryReadStream MemoryReadStream;
};
class Win32ResExtractor : public ResExtractor {

View file

@ -700,7 +700,7 @@ int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte
assert(len);
if (!soundDesc->compressedStream) {
Common::MemoryReadStream *tmp = cmpFile->readStream(len);
Common::SeekableReadStream *tmp = cmpFile->readStream(len);
assert(tmp);
#ifdef USE_FLAC
if (soundMode == 3)

View file

@ -24,6 +24,7 @@
*/
#include "common/config-manager.h"
#include "common/memstream.h"
#include "common/savefile.h"
#include "common/system.h"
#include "common/zlib.h"

Some files were not shown because too many files have changed in this diff Show more