IStreamEngine.h
The highest level. There is only one StreamingEngine in the application and it controls all I/O streams.
General purpose flags.
enum EFlags { FLAGS_NO_SYNC_CALLBACK = BIT(0), FLAGS_FILE_ON_DISK = BIT(1), FLAGS_IGNORE_TMP_OUT_OF_MEM = BIT(2), FLAGS_WRITE_ONLY_EXTERNAL_BUFFER = BIT(3) };
IStreamEngine.h
Members |
Description |
FLAGS_NO_SYNC_CALLBACK = BIT(0) |
If this is set only asynchronous callback will be called. |
FLAGS_FILE_ON_DISK = BIT(1) |
If this is set the file will be read from disc directly, instead of from the pak system. |
FLAGS_IGNORE_TMP_OUT_OF_MEM = BIT(2) |
Ignore the tmp out of streaming memory for this request |
FLAGS_WRITE_ONLY_EXTERNAL_BUFFER = BIT(3) |
External buffer is write only |
enum EJobType { ejtStarted = 1<<0, ejtPending = 1<<1, ejtFinished = 1<<2 };
IStreamEngine.h
virtual ~IStreamEngine();
virtual void BeginReadGroup() = 0;
Call this methods before/after submitting large number of new requests.
virtual void EndReadGroup() = 0;
virtual void GetMemoryStatistics(ICrySizer * pSizer) = 0;
Puts the memory statistics into the given sizer object. According to the specifications in interface ICrySizer.
ICrySizer
virtual uint32 GetPauseMask() const = 0;
Get pause bit mask
virtual void GetStreamingOpenStatistics(SStreamEngineOpenStats& openStatsOut) = 0;
Returns the counts of open streaming requests.
virtual const char* GetStreamTaskTypeName(EStreamTaskType type) = 0;
virtual bool IsStreamDataOnHDD() const = 0;
Is the streaming data available on harddisc for fast streaming
virtual void PauseIO(bool bPause) = 0;
Pause/resumes any IO active from the streaming engine
virtual void PauseStreaming(bool bPause, uint32 nPauseTypesBitmask) = 0;
Pause/resumes streaming of specific data types. nPauseTypesBitmask is a bit mask of data types (ex, 1<
virtual void SetStreamDataOnHDD(bool bFlag) = 0;
Inform streaming engine that the streaming data is available on HDD
virtual size_t StartBatchRead(IReadStreamPtr* pStreamsOut, const StreamReadBatchParams* pReqs, size_t numReqs) = 0;
virtual IReadStreamPtr StartRead(const EStreamTaskType tSource, const char* szFile, IStreamCallback* pCallback = NULL, const StreamReadParams* pParams = NULL) = 0;
Parameters |
Description |
IStreamCallback* pCallback = NULL |
pParams - PLACEHOLDER for the future additional parameters (like priority), or really a pointer to a structure that will hold the parameters if there are too many of them. |
szSource |
szFile - |
IReadStream is reference-counted and will be automatically deleted if you don't refer to it; if you don't store it immediately in an auto-pointer, it may be deleted as soon as on the next line of code, because the read operation may complete immediately inside StartRead() and the object is self-disposed as soon as the callback is called.
Starts asynchronous read from the specified file (the file may be on a virtual file system, in pak or zip file or wherever). Reads the file contents into the given buffer, up to the given size. Upon success, calls success callback. If the file is truncated or for other reason can not be read, calls error callback. The callback can be NULL (in this case, the client should poll the returned IReadStream object; the returned object must be locked for that)
In some implementations disposal of the old pointers happen synchronously (in the main thread) outside StartRead() (it happens in the entity update), so you're guaranteed that it won't trash inside the calling function. However, this may change in the future and you'll be required to assign it to IReadStream immediately (StartRead will return IReadStream_AutoPtr then).
the error/success/ progress callbacks can also be called from INSIDE this function.
IReadStream,IReadStream_AutoPtr
virtual void Update() = 0;
Per frame update ofthe streaming engine, synchronous events are dispatched from this function.
virtual void Update(uint32 nUpdateTypesBitmask) = 0;
Per frame update of the streaming engine, synchronous events are dispatched from this function, by particular TypesBitmask.
virtual void UpdateAndWait(bool bAbortAll = false) = 0;
Waits until all submitted requests are complete. (can abort all reads which are currently in flight)