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:
@@ -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};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user