arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QueueStream< T > Class Template Reference

Stream class which stores the data in a temporary queue buffer. The queue can be consumed e.g. by a callback function by calling readBytes();. More...

#include <BaseStream.h>

Inheritance diagram for QueueStream< T >:
BaseStream Stream Print

Public Member Functions

 QueueStream ()=default
 Empty Constructor: call setBuffer() to set the buffer.
 
 QueueStream (BaseBuffer< T > &buffer)
 Create stream from any BaseBuffer subclass.
 
 QueueStream (int bufferSize, int bufferCount, bool autoRemoveOldestDataIfFull=false)
 Default constructor.
 
virtual ~QueueStream ()
 
int available () override
 
int availableForWrite () override
 
virtual bool begin () override
 Activates the output.
 
virtual bool begin (size_t activeWhenPercentFilled)
 Activate only when filled buffer reached %.
 
void clear ()
 Clears the data in the buffer.
 
virtual void end () override
 stops the processing
 
virtual void flush () override
 
int levelPercent ()
 Returns the fill level in percent.
 
 operator bool ()
 Returns true if active.
 
int peek () override
 
int read () override
 
virtual size_t readBytes (uint8_t *data, size_t len) override
 
bool resize (int size)
 Resize the buffer.
 
void setBuffer (BaseBuffer< T > &buffer)
 
void setWriteBufferSize (int size)
 
virtual size_t write (const uint8_t *data, size_t len) override
 
virtual size_t write (uint8_t ch) override
 

Protected Member Functions

void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 

Protected Attributes

int _timeout = 10
 
bool active = false
 
size_t active_limit = 0
 
bool owns_buffer = false
 
BaseBuffer< T > * p_buffer
 
bool remove_oldest_data = false
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
size_t total_written = 0
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

template<class T>
class audio_tools::QueueStream< T >

Stream class which stores the data in a temporary queue buffer. The queue can be consumed e.g. by a callback function by calling readBytes();.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ QueueStream() [1/3]

template<class T >
QueueStream ( )
default

Empty Constructor: call setBuffer() to set the buffer.

◆ QueueStream() [2/3]

template<class T >
QueueStream ( int  bufferSize,
int  bufferCount,
bool  autoRemoveOldestDataIfFull = false 
)
inline

Default constructor.

◆ QueueStream() [3/3]

template<class T >
QueueStream ( BaseBuffer< T > &  buffer)
inline

Create stream from any BaseBuffer subclass.

◆ ~QueueStream()

template<class T >
virtual ~QueueStream ( )
inlinevirtual

Member Function Documentation

◆ available()

template<class T >
int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite()

template<class T >
int availableForWrite ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [1/2]

template<class T >
virtual bool begin ( )
inlineoverridevirtual

Activates the output.

Reimplemented from BaseStream.

◆ begin() [2/2]

template<class T >
virtual bool begin ( size_t  activeWhenPercentFilled)
inlinevirtual

Activate only when filled buffer reached %.

◆ clear()

template<class T >
void clear ( )
inline

Clears the data in the buffer.

◆ end()

template<class T >
virtual void end ( )
inlineoverridevirtual

stops the processing

Reimplemented from BaseStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ levelPercent()

template<class T >
int levelPercent ( )
inline

Returns the fill level in percent.

◆ operator bool()

template<class T >
operator bool ( )
inline

Returns true if active.

◆ peek()

template<class T >
int peek ( )
inlineoverride

◆ read()

template<class T >
int read ( )
inlineoverride

◆ readBytes()

template<class T >
virtual size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtual

Implements BaseStream.

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()

◆ resize()

template<class T >
bool resize ( int  size)
inline

Resize the buffer.

◆ setBuffer()

template<class T >
void setBuffer ( BaseBuffer< T > &  buffer)
inline

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ write() [1/2]

template<class T >
virtual size_t write ( const uint8_t data,
size_t  len 
)
inlineoverridevirtual

Implements BaseStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ active

template<class T >
bool active = false
protected

◆ active_limit

template<class T >
size_t active_limit = 0
protected

◆ owns_buffer

template<class T >
bool owns_buffer = false
protected

◆ p_buffer

template<class T >
BaseBuffer<T>* p_buffer
protected

◆ remove_oldest_data

template<class T >
bool remove_oldest_data = false
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ total_written

template<class T >
size_t total_written = 0
protected

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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