13#include <freertos/FreeRTOS.h>
89 static std::unique_ptr<AudioSinkTransferBuffer>
create(
size_t buffer_size);
127 static std::unique_ptr<AudioSourceTransferBuffer>
create(
size_t buffer_size);
size_t transfer_data_to_sink(TickType_t ticks_to_wait, bool post_shift=true)
Writes any available data in the transfer buffer to the sink.
void set_sink(const std::weak_ptr< RingBuffer > &ring_buffer)
Adds a ring buffer as the transfer buffer's sink.
void clear_buffered_data() override
void set_sink(speaker::Speaker *speaker)
Adds a speaker as the transfer buffer's sink.
bool has_buffered_data() const override
speaker::Speaker * speaker_
static std::unique_ptr< AudioSinkTransferBuffer > create(size_t buffer_size)
Creates a new sink transfer buffer.
size_t transfer_data_from_source(TickType_t ticks_to_wait, bool pre_shift=true)
Reads any available data from the sink into the transfer buffer.
static std::unique_ptr< AudioSourceTransferBuffer > create(size_t buffer_size)
Creates a new source transfer buffer.
void set_source(const std::weak_ptr< RingBuffer > &ring_buffer)
Adds a ring buffer as the transfer buffer's source.
size_t free() const
Returns the transfer buffer's currrently free bytes available to write.
virtual bool has_buffered_data() const
Tests if there is any data in the tranfer buffer or the source/sink.
virtual void clear_buffered_data()
Clears data in the transfer buffer and, if possible, the source/sink.
~AudioTransferBuffer()
Destructor that deallocates the transfer buffer.
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.
void increase_buffer_length(size_t bytes)
Updates the internal state of the transfer buffer.
bool reallocate(size_t new_buffer_size)
bool allocate_buffer_(size_t buffer_size)
Allocates the transfer buffer in external memory, if available.
uint8_t * get_buffer_start() const
Returns a pointer to the start of the transfer buffer where available() bytes of exisiting data can b...
void decrease_buffer_length(size_t bytes)
Updates the internal state of the transfer buffer.
size_t available() const
Returns the transfer buffer's currently available bytes to read.
std::shared_ptr< RingBuffer > ring_buffer_
size_t capacity() const
Returns the transfer buffers allocated bytes.
void deallocate_buffer_()
Deallocates the buffer and resets the class variables.
Providing packet encoding functions for exchanging data with a remote host.