wavelength 1.0.0
Loading...
Searching...
No Matches
FileStreamBuffer Class Reference

StreamBuffer that a file fills with asynchronous reads. More...

#include <filestreambuffer.h>

Inheritance diagram for FileStreamBuffer:
Collaboration diagram for FileStreamBuffer:

Public Member Functions

 FileStreamBuffer (const char *pszPath, int nFlags)
 Open a file and start the first read.
 ~FileStreamBuffer () override
 Close the file and free the read buffer.
void Poll () override
 Append the bytes of a finished read, then read as many bytes as the buffer has room for.
void Rewind () override
 Seek the file back to its start and clear mInputDone.
bool IsClosed () const
 Report whether the file failed to open.
File * GetFile () const
Public Member Functions inherited from StreamBuffer
 StreamBuffer (unsigned int size)
 Allocate the buffer.
 ~StreamBuffer () override
 Free the buffer.
void SetStatusAddress (void *address)
 Record the EE address that receives the free space, and write 1 there.
void Write (const void *data, unsigned int size, bool endOfStream) override
 Append bytes and schedule a notification.
void Notify () override
 Send the free space to the EE when a notification is scheduled and the space is positive.
 StreamBuffer (int nSize)
 Allocate a cleared buffer.
virtual ~StreamBuffer ()
 Free the buffer.
virtual void Add (const char *pData, int nBytes, int bLast)
 Append bytes behind the write head, wrapping at the end of the buffer.
bool IsEof ()
 Report whether the consumer took every byte and the producer has no more.
bool IsEmpty ()
 Report whether the consumer has taken every byte appended so far.
char * AcquireReadRun (int nMaxBytes, int *pnBytes)
 Take the next run of bytes, after a Poll().
void CommitReadRun (char **ppRun)
 Release the run AcquireReadRun() handed out, Poll(), and clear the caller's pointer.
int EmptySpaceForFilling ()
 Report the room the producer may fill, which keeps mMargin bytes free.
int BytesAvailable (int *pbInputDone)
 Report the bytes the consumer has not taken yet.
int GetSize () const
char * GetBuffer () const
Public Member Functions inherited from RingBuffer
 RingBuffer (unsigned int size)
 Allocate and clear a buffer of size bytes, rounded down to whole words, with both pointers at its start.
virtual ~RingBuffer ()
 Free the buffer.
virtual void Reset ()
 Discard every byte by moving both pointers to the start of the buffer.
bool IsFinished () const
 Report whether the stream has ended and every byte has been read.
unsigned int ContiguousFree () const
 Report the space the writer can fill without wrapping, less the reserve.
bool IsFull () const
 Report whether ContiguousFree() is zero.
bool IsEmpty () const
 Report whether every written byte has been read.
void * Read (unsigned int maxSize, unsigned int *size)
 Notify the writer, then return the next contiguous block of at most maxSize bytes.
void Release (void **block)
 Consume the block Read() returned and notify the writer.
unsigned int FreeSpace () const
 Report the free space, less the reserve.
unsigned int Used (bool *endOfStream) const
 Report the bytes written and not yet read.
void ClearEndOfStream ()
 Clear the end-of-stream flag.
bool EndOfStream () const
 Report the end-of-stream flag.

Additional Inherited Members

Static Public Member Functions inherited from StreamBuffer
static int SendStatus (int value, void *address)
 Write a word to EE memory over SIF DMA.
Static Public Attributes inherited from StreamBuffer
static constexpr unsigned int kSize = 0xf000
 Buffer size in bytes.
Protected Attributes inherited from StreamBuffer
int mInputDone
Protected Attributes inherited from RingBuffer
unsigned int mSize
char * mBuffer
char * mRead
char * mWrite
char * mEnd
char * mPendingRead
bool mEndOfStream
unsigned int mReserve

Detailed Description

StreamBuffer that a file fills with asynchronous reads.

The RTTI includes the class name and records StreamBuffer as the base. The object is 0x38 bytes.

Constructor & Destructor Documentation

◆ FileStreamBuffer()

FileStreamBuffer::FileStreamBuffer ( const char * pszPath,
int nFlags )

Open a file and start the first read.

Parameters
pszPathThe path of the file.
nFlagsThe open flags passed to File::New().
Ghidra address:
NTSC-U/C: 0x00299970
Ghidra address:
PAL: 0x002a3570

◆ ~FileStreamBuffer()

FileStreamBuffer::~FileStreamBuffer ( )
override

Close the file and free the read buffer.

Ghidra address:
NTSC-U/C: 0x00299a40
Ghidra address:
PAL: 0x002a3640

Member Function Documentation

◆ Poll()

void FileStreamBuffer::Poll ( )
overridevirtual

Append the bytes of a finished read, then read as many bytes as the buffer has room for.

Ghidra address:
NTSC-U/C: 0x00299838
Ghidra address:
PAL: 0x002a3438

Implements StreamBuffer.

◆ Rewind()

void FileStreamBuffer::Rewind ( )
overridevirtual

Seek the file back to its start and clear mInputDone.

The heads stay where they are.

Ghidra address:
NTSC-U/C: 0x00299918
Ghidra address:
PAL: 0x002a3518

Reimplemented from StreamBuffer.

◆ IsClosed()

bool FileStreamBuffer::IsClosed ( ) const

Report whether the file failed to open.

Returns
Whether no file is open.
Ghidra address:
NTSC-U/C: 0x00299960
Ghidra address:
PAL: 0x002a3560

◆ GetFile()

File * FileStreamBuffer::GetFile ( ) const
inline
Returns
The file, or null when it did not open.

The documentation for this class was generated from the following file: