ESPHome
2025.2.0
|
#include <audio_transfer_buffer.h>
Public Member Functions | |
~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) |
Protected Member Functions | |
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... | |
Protected Attributes | |
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 18 of file audio_transfer_buffer.h.
esphome::audio::AudioTransferBuffer::~AudioTransferBuffer | ( | ) |
Destructor that deallocates the transfer buffer.
Definition at line 10 of file audio_transfer_buffer.cpp.
|
protected |
Allocates the transfer buffer in external memory, if available.
Definition at line 81 of file audio_transfer_buffer.cpp.
|
inline |
Returns the transfer buffer's currently available bytes to read.
Definition at line 44 of file audio_transfer_buffer.h.
|
inline |
Returns the transfer buffers allocated bytes.
Definition at line 47 of file audio_transfer_buffer.h.
|
virtual |
Clears data in the transfer buffer and, if possible, the source/sink.
Reimplemented in esphome::audio::AudioSinkTransferBuffer.
Definition at line 46 of file audio_transfer_buffer.cpp.
|
protected |
Deallocates the buffer and resets the class variables.
Definition at line 97 of file audio_transfer_buffer.cpp.
void esphome::audio::AudioTransferBuffer::decrease_buffer_length | ( | size_t | bytes | ) |
Updates the internal state of the transfer buffer.
This should be called after reading data
bytes | The number of bytes consumed/read |
Definition at line 39 of file audio_transfer_buffer.cpp.
size_t esphome::audio::AudioTransferBuffer::free | ( | ) | const |
Returns the transfer buffer's currrently free bytes available to write.
Definition at line 32 of file audio_transfer_buffer.cpp.
|
inline |
Returns a pointer to the end of the transfer buffer where free() bytes of new data can be written.
Definition at line 33 of file audio_transfer_buffer.h.
|
inline |
Returns a pointer to the start of the transfer buffer where available() bytes of exisiting data can be read.
Definition at line 30 of file audio_transfer_buffer.h.
|
virtual |
Tests if there is any data in the tranfer buffer or the source/sink.
Reimplemented in esphome::audio::AudioSinkTransferBuffer.
Definition at line 65 of file audio_transfer_buffer.cpp.
void esphome::audio::AudioTransferBuffer::increase_buffer_length | ( | size_t | bytes | ) |
Updates the internal state of the transfer buffer.
This should be called after writing data
bytes | The number of bytes written |
Definition at line 44 of file audio_transfer_buffer.cpp.
bool esphome::audio::AudioTransferBuffer::reallocate | ( | size_t | new_buffer_size | ) |
Definition at line 72 of file audio_transfer_buffer.cpp.
|
protected |
Definition at line 72 of file audio_transfer_buffer.h.
|
protected |
Definition at line 76 of file audio_transfer_buffer.h.
|
protected |
Definition at line 75 of file audio_transfer_buffer.h.
|
protected |
Definition at line 73 of file audio_transfer_buffer.h.
|
protected |
Definition at line 70 of file audio_transfer_buffer.h.