|
wavelength 1.0.0
|
The ring buffer the EE streams samples into. More...
#include <streambuffer.h>


Public Member Functions | |
| 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. | |
| virtual void | Poll ()=0 |
| Let the producer append what it has. | |
| virtual void | Rewind () |
| Move both heads back to the start 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. | |
Static Public Member Functions | |
| static int | SendStatus (int value, void *address) |
| Write a word to EE memory over SIF DMA. | |
Static Public Attributes | |
| static constexpr unsigned int | kSize = 0xf000 |
| Buffer size in bytes. | |
Protected Attributes | |
| 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 |
The ring buffer the EE streams samples into.
Ring buffer of bytes a producer appends and a consumer takes in runs.
After each change it tells the EE how much it may send by writing the free space to an EE address over SIF DMA.
The module was built without RTTI. The name is inferred from the class's routines.
The RTTI includes the class name and records no base. The data members precede the vptr, which sits at +0x20. Every routine reports the state through DebugPrint() whenever the write head has passed the end of the buffer.
|
explicit |
Allocate the buffer.
| size | Requested size. The binary ignores it and always allocates kSize bytes. |
|
override |
Free the buffer.
|
explicit |
Allocate a cleared buffer.
| nSize | The size of the buffer in bytes. |
|
virtual |
Free the buffer.
|
static |
Write a word to EE memory over SIF DMA.
| value | The word. |
| address | EE address of a 16-byte destination. |
| void StreamBuffer::SetStatusAddress | ( | void * | address | ) |
Record the EE address that receives the free space, and write 1 there.
| address | EE address. |
|
overridevirtual |
Append bytes and schedule a notification.
| data | Bytes to append, or null to record only the flag. |
| size | Byte count, or zero to record only the flag. |
| endOfStream | Whether the EE has no more data. |
Reimplemented from RingBuffer.
|
overridevirtual |
Send the free space to the EE when a notification is scheduled and the space is positive.
Implements RingBuffer.
|
virtual |
Append bytes behind the write head, wrapping at the end of the buffer.
The caller first checks EmptySpaceForFilling(). The global g_nAddWasEntered is set while the routine runs, and it stays set when there is no byte to append.
| pData | The bytes, or null to only record bLast. |
| nBytes | The number of bytes. |
| bLast | Non-zero when the producer has no more bytes. |
|
pure virtual |
Let the producer append what it has.
The member is pure in this class.
Implemented in FileStreamBuffer.
|
virtual |
Move both heads back to the start of the buffer.
Reimplemented in FileStreamBuffer.
| bool StreamBuffer::IsEof | ( | ) |
Report whether the consumer took every byte and the producer has no more.
A write head past the end of the buffer also counts as the end.
| bool StreamBuffer::IsEmpty | ( | ) |
Report whether the consumer has taken every byte appended so far.
The name is inferred.
| char * StreamBuffer::AcquireReadRun | ( | int | nMaxBytes, |
| int * | pnBytes ) |
Take the next run of bytes, after a Poll().
A run ends at the write head or at the end of the buffer.
| nMaxBytes | The most bytes the caller accepts. |
| pnBytes | Receives the size of the run. |
| void StreamBuffer::CommitReadRun | ( | char ** | ppRun | ) |
Release the run AcquireReadRun() handed out, Poll(), and clear the caller's pointer.
A null run is ignored.
| ppRun | The caller's pointer to the run. |
| int StreamBuffer::EmptySpaceForFilling | ( | ) |
Report the room the producer may fill, which keeps mMargin bytes free.
| int StreamBuffer::BytesAvailable | ( | int * | pbInputDone | ) |
Report the bytes the consumer has not taken yet.
The name is inferred.
| pbInputDone | Receives mInputDone. |
|
inline |
|
inline |
|
staticconstexpr |
Buffer size in bytes.
|
protected |
1 once the producer has no more bytes.