From 4e27de21e49900963ffa61cc9c0a676bb028f992 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 16 Aug 2023 10:57:55 +1000 Subject: clean up a bunch of obselete audio code --- src/audio/include/chunk.hpp | 65 --------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 src/audio/include/chunk.hpp (limited to 'src/audio/include/chunk.hpp') diff --git a/src/audio/include/chunk.hpp b/src/audio/include/chunk.hpp deleted file mode 100644 index f5ba6654..00000000 --- a/src/audio/include/chunk.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2023 jacqueline - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include -#include -#include -#include -#include - -#include "freertos/FreeRTOS.h" - -#include "cbor.h" -#include "freertos/message_buffer.h" -#include "freertos/portmacro.h" -#include "freertos/queue.h" -#include "result.hpp" -#include "span.hpp" -#include "stream_buffer.hpp" - -namespace audio { - -/** - * Utility for handling an input stream of chunk data, which simplifies needing - * access to blocks of data spanning two chunks. - */ -class ChunkReader { - public: - explicit ChunkReader(std::size_t chunk_size); - ~ChunkReader(); - - auto HandleBytesLeftOver(std::size_t bytes_left) -> void; - auto HandleBytesUsed(std::size_t bytes_used) -> void; - - /* - * Reads chunks of data from the given input stream, and invokes the given - * callback to process each of them in turn. - * - * The callback will be invoked with a byte buffer and its size. The callback - * should process as much data as it can from this buffer, and then return the - * number of bytes it was able to read. Any leftover bytes will be added as a - * prefix to the next chunk. - * - * If this function encounters a message in the stream that is not a chunk, it - * will place the message at the start of the working_buffer and then return. - */ - auto HandleNewData(cpp::span data) -> cpp::span; - - auto GetLeftovers() -> cpp::span; - - ChunkReader(const ChunkReader&) = delete; - ChunkReader& operator=(const ChunkReader&) = delete; - - private: - std::byte* raw_working_buffer_; - cpp::span working_buffer_; - cpp::span last_data_in_working_buffer_; - std::size_t leftover_bytes_ = 0; -}; - -} // namespace audio -- cgit v1.2.3