1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-28 21:53:48 +00:00

[core] Bugfix: Implement ring buffer with xRingbuffer (#7973)

This commit is contained in:
Kevin Ahrendt
2024-12-18 21:07:07 -05:00
committed by GitHub
parent 0aaef9293b
commit 61499dbdd8
2 changed files with 82 additions and 21 deletions

View File

@@ -3,7 +3,7 @@
#ifdef USE_ESP32
#include <freertos/FreeRTOS.h>
#include <freertos/stream_buffer.h>
#include <freertos/ringbuf.h>
#include <cinttypes>
#include <memory>
@@ -82,9 +82,14 @@ class RingBuffer {
static std::unique_ptr<RingBuffer> create(size_t len);
protected:
StreamBufferHandle_t handle_;
StaticStreamBuffer_t structure_;
uint8_t *storage_;
/// @brief Discards data from the ring buffer.
/// @param discard_bytes amount of bytes to discard
/// @return True if all bytes were successfully discarded, false otherwise
bool discard_bytes_(size_t discard_bytes);
RingbufHandle_t handle_{nullptr};
StaticRingbuffer_t structure_;
uint8_t *storage_{nullptr};
size_t size_{0};
};