diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-01-12 14:28:52 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-01-12 14:28:52 +1100 |
| commit | 2056cad0ab7b805f0ed5629b100b50f8ea9e127e (patch) | |
| tree | 1e8385d48e18551240e9ef9683b8696292f8d760 /src/audio/include/stream_buffer.hpp | |
| parent | 01be69eca1fa89c047fc29f5cb0ea8ba0898dad1 (diff) | |
| download | tangara-fw-2056cad0ab7b805f0ed5629b100b50f8ea9e127e.tar.gz | |
WIP
Diffstat (limited to 'src/audio/include/stream_buffer.hpp')
| -rw-r--r-- | src/audio/include/stream_buffer.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/audio/include/stream_buffer.hpp b/src/audio/include/stream_buffer.hpp index cfb4bf9d..3853a53f 100644 --- a/src/audio/include/stream_buffer.hpp +++ b/src/audio/include/stream_buffer.hpp @@ -10,13 +10,35 @@ namespace audio { +/* + * A collection of the buffers required for two IAudioElement implementations to + * stream data between each other. + * + * Currently, we use a FreeRTOS MessageBuffer to hold the byte stream, and also + * maintain two chunk-sized buffers for the elements to stage their read and + * write operations (as MessageBuffer copies the given data into its memory + * space). A future optimisation here could be to instead post himem memory + * addresses to the message buffer, and then maintain address spaces into which + * we map these messages, rather than 'real' allocated buffers as we do now. + */ class StreamBuffer { public: explicit StreamBuffer(std::size_t chunk_size, std::size_t buffer_size); ~StreamBuffer(); + /* Returns the handle for the underlying message buffer. */ auto Handle() -> MessageBufferHandle_t* { return &handle_; } + + /* + * Returns a chunk-sized staging buffer that should be used *only* by the + * reader (sink) element. + */ auto ReadBuffer() -> cpp::span<std::byte> { return input_chunk_; } + + /* + * Returns a chunk-sized staging buffer that should be used *only* by the + * writer (source) element. + */ auto WriteBuffer() -> cpp::span<std::byte> { return output_chunk_; } StreamBuffer(const StreamBuffer&) = delete; |
