arduino-audio-tools
Loading...
Searching...
No Matches
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 <CodecOpusOgg.h>

Inheritance diagram for QueueStream< T >:
BaseStream BaseStream Stream Stream Stream Stream Print Print Print Print Print Print Print Print

Public Member Functions

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

Protected Member Functions

void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().
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_t > tmp_in {0}
RingBuffer< uint8_t > tmp_out {0}
size_t total_written = 0
int write_buffer_size = 8

Detailed Description

template<class T>
class audio_tools::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/6]

template<class T>
QueueStream ( )
default

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

◆ QueueStream() [2/6]

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

Default constructor.

◆ QueueStream() [3/6]

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

Create stream from any BaseBuffer subclass.

◆ ~QueueStream() [1/2]

template<class T>
virtual ~QueueStream ( )
inlinevirtual

◆ QueueStream() [4/6]

template<class T>
QueueStream ( )
default

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

◆ QueueStream() [5/6]

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

Default constructor.

◆ QueueStream() [6/6]

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

Create stream from any BaseBuffer subclass.

◆ ~QueueStream() [2/2]

template<class T>
virtual ~QueueStream ( )
inlinevirtual

Member Function Documentation

◆ available() [1/2]

template<class T>
int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ available() [2/2]

template<class T>
int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite() [1/2]

template<class T>
int availableForWrite ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite() [2/2]

template<class T>
int availableForWrite ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ begin() [1/4]

template<class T>
virtual bool begin ( )
inlineoverridevirtual

Activates the output.

Reimplemented from BaseStream.

◆ begin() [2/4]

template<class T>
virtual bool begin ( )
inlineoverridevirtual

Activates the output.

Reimplemented from BaseStream.

◆ begin() [3/4]

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

Activate only when filled buffer reached %.

◆ begin() [4/4]

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

Activate only when filled buffer reached %.

◆ clear() [1/2]

template<class T>
void clear ( )
inline

Clears the data in the buffer.

◆ clear() [2/2]

template<class T>
void clear ( )
inline

Clears the data in the buffer.

◆ end() [1/2]

template<class T>
virtual void end ( )
inlineoverridevirtual

stops the processing

Reimplemented from BaseStream.

◆ end() [2/2]

template<class T>
virtual void end ( )
inlineoverridevirtual

stops the processing

Reimplemented from BaseStream.

◆ flush() [1/2]

template<class T>
void flush ( )
inlineoverridevirtual

Clears the data in the buffer and resets the state.

Reimplemented from BaseStream.

◆ flush() [2/2]

template<class T>
void flush ( )
inlineoverridevirtual

Clears the data in the buffer and resets the state.

Reimplemented from BaseStream.

◆ levelPercent() [1/2]

template<class T>
int levelPercent ( )
inline

Returns the fill level in percent.

◆ levelPercent() [2/2]

template<class T>
int levelPercent ( )
inline

Returns the fill level in percent.

◆ operator bool() [1/2]

template<class T>
operator bool ( )
inline

Returns true if active.

◆ operator bool() [2/2]

template<class T>
operator bool ( )
inline

Returns true if active.

◆ peek() [1/2]

template<class T>
int peek ( )
inlineoverride

◆ peek() [2/2]

template<class T>
int peek ( )
inlineoverride

◆ read() [1/2]

template<class T>
int read ( )
inlineoverride

◆ read() [2/2]

template<class T>
int read ( )
inlineoverride

◆ readBytes() [1/2]

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

Implements BaseStream.

◆ readBytes() [2/2]

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

Implements BaseStream.

◆ refillReadBuffer() [1/2]

void refillReadBuffer ( )
inlineprotectedinherited

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

◆ refillReadBuffer() [2/2]

void refillReadBuffer ( )
inlineprotectedinherited

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

◆ resize() [1/4]

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

Resize the buffer.

◆ resize() [2/4]

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

Resize the buffer.

◆ resize() [3/4]

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

Resize the buffer by indicating the size and count.

◆ resize() [4/4]

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

Resize the buffer by indicating the size and count.

◆ setBuffer() [1/2]

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

◆ setBuffer() [2/2]

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

◆ setWriteBufferSize() [1/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ setWriteBufferSize() [2/2]

void setWriteBufferSize ( int size)
inlineinherited

◆ write() [1/3]

◆ write() [2/3]

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

Implements BaseStream.

◆ write() [3/3]

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

Implements BaseStream.

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 = 8
protectedinherited

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