ESPHome
2025.2.0
|
#include <audio_transfer_buffer.h>
Public Member Functions | |
size_t | transfer_data_from_source (TickType_t ticks_to_wait) |
Reads any available data from the sink into the transfer buffer. More... | |
void | set_source (const std::weak_ptr< RingBuffer > &ring_buffer) |
Adds a ring buffer as the transfer buffer's source. More... | |
![]() | |
~AudioTransferBuffer () | |
Destructor that deallocates the transfer buffer. More... | |
uint8_t * | get_buffer_start () const |
Returns a pointer to the start of the transfer buffer where available() bytes of exisiting data can be read. More... | |
uint8_t * | get_buffer_end () const |
Returns a pointer to the end of the transfer buffer where free() bytes of new data can be written. More... | |
void | decrease_buffer_length (size_t bytes) |
Updates the internal state of the transfer buffer. More... | |
void | increase_buffer_length (size_t bytes) |
Updates the internal state of the transfer buffer. More... | |
size_t | available () const |
Returns the transfer buffer's currently available bytes to read. More... | |
size_t | capacity () const |
Returns the transfer buffers allocated bytes. More... | |
size_t | free () const |
Returns the transfer buffer's currrently free bytes available to write. More... | |
virtual void | clear_buffered_data () |
Clears data in the transfer buffer and, if possible, the source/sink. More... | |
virtual bool | has_buffered_data () const |
Tests if there is any data in the tranfer buffer or the source/sink. More... | |
bool | reallocate (size_t new_buffer_size) |
Static Public Member Functions | |
static std::unique_ptr< AudioSourceTransferBuffer > | create (size_t buffer_size) |
Creates a new source transfer buffer. More... | |
Additional Inherited Members | |
![]() | |
bool | allocate_buffer_ (size_t buffer_size) |
Allocates the transfer buffer in external memory, if available. More... | |
void | deallocate_buffer_ () |
Deallocates the buffer and resets the class variables. More... | |
![]() | |
std::shared_ptr< RingBuffer > | ring_buffer_ |
uint8_t * | buffer_ {nullptr} |
uint8_t * | data_start_ {nullptr} |
size_t | buffer_size_ {0} |
size_t | buffer_length_ {0} |
Definition at line 115 of file audio_transfer_buffer.h.
|
static |
Creates a new source transfer buffer.
buffer_size | Size of the transfer buffer in bytes. |
Definition at line 22 of file audio_transfer_buffer.cpp.
|
inline |
Adds a ring buffer as the transfer buffer's source.
ring_buffer | weak_ptr to the allocated ring buffer |
Definition at line 133 of file audio_transfer_buffer.h.
size_t esphome::audio::AudioSourceTransferBuffer::transfer_data_from_source | ( | TickType_t | ticks_to_wait | ) |
Reads any available data from the sink into the transfer buffer.
ticks_to_wait | FreeRTOS ticks to block while waiting for the source to have enough data |
Definition at line 109 of file audio_transfer_buffer.cpp.