ConverterStream Helper class which implements the readBytes with the help of write.
More...
#include <AudioIO.h>
template<class T>
class audio_tools::TransformationReader< T >
ConverterStream Helper class which implements the readBytes with the help of write.
- Author
- Phil Schatzmann
- Copyright
- GPLv3
- Template Parameters
-
| T | class name of the original transformer stream |
◆ available()
Fills the internal queue up to at least DEFAULT_BUFFER_SIZE bytes (if possible) and reports the currently available queue size limited by max_read_size.
◆ begin()
template<class T >
| void begin |
( |
T * |
transform, |
|
|
Stream * |
source |
|
) |
| |
|
inline |
setup of the TransformationReader class
- Parameters
-
| transform | The original transformer stream |
| source | The data source of the data to be converted the requested converted bytes |
◆ end()
◆ fillResultQueue()
template<class T >
| void fillResultQueue |
( |
size_t |
len | ) |
|
|
inlineprotected |
Fills the result queue until at least len bytes are available or no more input data arrives.
◆ getTotalBytesRead()
template<class T >
| size_t getTotalBytesRead |
( |
| ) |
const |
|
inline |
◆ readBytes()
template<class T >
| size_t readBytes |
( |
uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inline |
◆ resizeReadBuffer()
template<class T >
| void resizeReadBuffer |
( |
int |
size | ) |
|
|
inlineprotected |
Defines the read buffer size for individual reads.
◆ resizeResultQueue()
template<class T >
| void resizeResultQueue |
( |
int |
size | ) |
|
|
inline |
Defines the queue size for result.
◆ restoreOutput()
template<class T >
| void restoreOutput |
( |
Print * |
out | ) |
|
|
inlineprotected |
restores the original output in the converter class
- Parameters
-
◆ setEofOnZeroReads()
template<class T >
| void setEofOnZeroReads |
( |
bool |
flag | ) |
|
|
inline |
Defines how a run of MAX_ZERO_READ_COUNT consecutive empty reads from the source is interpreted:
- true (default): the source is treated as finished (e.g. end of file) and is_eof latches permanently - matches the historical behavior for decoders/encoders reading a finite stream.
- false: the source is treated as a live/continuous producer that is just momentarily empty (a buffer underflow). is_eof is never set, so the next call simply tries again once more data has arrived.
◆ setMaxReadSize()
template<class T >
| void setMaxReadSize |
( |
int |
size | ) |
|
|
inline |
◆ setResultQueueFactor()
template<class T >
| void setResultQueueFactor |
( |
int |
factor | ) |
|
|
inline |
Defines the queue size dependent on the read size.
◆ setupBuffers()
template<class T >
| void setupBuffers |
( |
size_t |
len | ) |
|
|
inlineprotected |
◆ setupOutput()
Makes sure that the data is written to the array
- Parameters
-
- Returns
- original output of the converter class
◆ setZeroReadDelay()
template<class T >
| void setZeroReadDelay |
( |
uint32_t |
delay_ms | ) |
|
|
inline |
Defines how long fillResultQueue() blocks in delay() after each empty read from the source, before retrying (up to MAX_ZERO_READ_COUNT times). Default is 5ms, matching historical behavior. For a live producer read from the same thread/task that also has to keep some other time-critical consumer fed (e.g. an I2S output pump driven from the same loop()), blocking here for up to MAX_ZERO_READ_COUNT * this value on every transient underflow can itself starve that consumer - set this to 0 in that case so a momentarily-empty source just returns immediately with whatever's available instead of stalling the caller.
◆ active
◆ buffer
◆ eof_on_zero_reads
template<class T >
| bool eof_on_zero_reads = true |
|
protected |
◆ is_eof
◆ last_byte_factor
template<class T >
| float last_byte_factor = 0.0f |
|
protected |
◆ last_setup_buffer_size
template<class T >
| int last_setup_buffer_size = 0 |
|
protected |
◆ max_read_size
◆ p_stream
◆ p_transform
◆ result_queue
◆ result_queue_buffer
◆ result_queue_factor
template<class T >
| int result_queue_factor = 5 |
|
protected |
◆ total_bytes_read
template<class T >
| size_t total_bytes_read = 0 |
|
protected |
◆ zero_read_delay_ms
template<class T >
| uint32_t zero_read_delay_ms = 5 |
|
protected |
The documentation for this class was generated from the following file: