arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CatStream Class Reference

Provides data from a concatenation of Streams. Please note that the provided Streams can be played only once! You will need to reset them (e.g. moving the file pointer to the beginning) and read them back if you want to process them a second time. The default timeout on the available() method is set to 0. This might be too small if you use e.g. a URLStream. More...

#include <BaseStream.h>

Inheritance diagram for CatStream:
BaseStream Stream Print

Public Member Functions

 CatStream ()=default
 
void add (Stream &stream)
 
void add (Stream *stream)
 
int available () override
 
virtual int availableForWrite () override
 
bool begin () override
 
void end () override
 
virtual void flush () override
 
 operator bool ()
 Returns true if active and we still have data.
 
size_t readBytes (uint8_t *data, size_t len) override
 
void setOnBeginCallback (void(*callback)(Stream *stream))
 
void setOnEndCallback (void(*callback)(Stream *stream))
 
void setTimeout (size_t t)
 Defines the timout the system waits for data when moving to the next stream.
 
void setWriteBufferSize (int size)
 
size_t write (const uint8_t *data, size_t size) override
 not supported
 
virtual size_t write (uint8_t ch) override
 

Protected Member Functions

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

Protected Attributes

size_t _timeout = 0
 
void(* begin_callback )(Stream *stream) = nullptr
 
void(* end_callback )(Stream *stream) = nullptr
 
Vector< Stream * > input_streams
 
bool is_active = false
 
Streamp_current_stream = nullptr
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

Provides data from a concatenation of Streams. Please note that the provided Streams can be played only once! You will need to reset them (e.g. moving the file pointer to the beginning) and read them back if you want to process them a second time. The default timeout on the available() method is set to 0. This might be too small if you use e.g. a URLStream.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ CatStream()

CatStream ( )
default

Member Function Documentation

◆ add() [1/2]

void add ( Stream stream)
inline

◆ add() [2/2]

void add ( Stream stream)
inline

◆ available()

int available ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ availableForWrite()

virtual int availableForWrite ( )
inlineoverridevirtualinherited

◆ availableWithTimout()

int availableWithTimout ( )
inlineprotected

◆ begin()

bool begin ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ end()

void end ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ moveToNextStreamOnEnd()

bool moveToNextStreamOnEnd ( )
inlineprotected

moves to the next stream if necessary: returns true if we still have a valid stream

◆ operator bool()

operator bool ( )
inline

Returns true if active and we still have data.

◆ readBytes()

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()

◆ setOnBeginCallback()

void setOnBeginCallback ( void(*)(Stream *stream)  callback)
inline

◆ setOnEndCallback()

void setOnEndCallback ( void(*)(Stream *stream)  callback)
inline

◆ setTimeout()

void setTimeout ( size_t  t)
inline

Defines the timout the system waits for data when moving to the next stream.

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ write() [1/2]

size_t write ( const uint8_t data,
size_t  size 
)
inlineoverridevirtual

not supported

Implements BaseStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Member Data Documentation

◆ _timeout

size_t _timeout = 0
protected

◆ begin_callback

void(* begin_callback) (Stream *stream) = nullptr
protected

◆ end_callback

void(* end_callback) (Stream *stream) = nullptr
protected

◆ input_streams

Vector<Stream *> input_streams
protected

◆ is_active

bool is_active = false
protected

◆ p_current_stream

Stream* p_current_stream = nullptr
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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