MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
AudioBounceBuffer.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project.
2// SPDX-License-Identifier: Apache-2.0
3
4#pragma once
5
6#include <cstdint>
7#include "Region.hpp"
8
10{
11
15 {
16 std::uint64_t headIndex;
17 std::size_t count;
18 };
19
24 {
25 public:
31 explicit AudioBounceBufferEntry(std::uint32_t size);
32
35 [[nodiscard]]
36 AudioEntryHeader const* header() const noexcept;
37
40 [[nodiscard]]
41 std::uint8_t const* samples() const noexcept;
42
45 [[nodiscard]]
46 std::uint8_t const* data() const noexcept;
47
50 [[nodiscard]]
51 std::size_t size() const noexcept;
52
53 private:
54 std::vector<std::uint8_t> _data;
55 };
56
64 {
65 public:
66 AudioBounceBuffer(std::size_t entryCount, std::size_t entrySize, DataLayout::Continuous layout);
67
70 [[nodiscard]]
71 std::vector<Region> getRegions() const noexcept;
72
74 [[nodiscard]]
75 std::size_t entryCount() const noexcept;
76
79 [[nodiscard]]
80 std::size_t entrySize() const noexcept;
81
86 AudioEntryHeader const& unpack(std::size_t entryIndex, Region const& outRegion) const;
87
88 static void getMutableMultiBufferSlices(std::uint64_t index, std::size_t count, std::size_t bufferLength, std::size_t sampleWordSize,
89 std::size_t channelCount, std::uint8_t* baseBufferPtr, mxlMutableWrappedMultiBufferSlice& slice) noexcept;
90
91 private:
92 std::vector<AudioBounceBufferEntry> _entries;
94 };
95}
std::uint8_t const * samples() const noexcept
Return a view to the samples data of the bounce buffer entry.
std::size_t size() const noexcept
The total size of the bounce buffer entry in bytes.
AudioEntryHeader const * header() const noexcept
Return a view on the header of the bounce buffer entry.
AudioBounceBufferEntry(std::uint32_t size)
Construct an AudioBounceBufferEntry with the given size in bytes. The size should be large enough to ...
std::uint8_t const * data() const noexcept
Return a view to the beginning of the bounce buffer entry data.
AudioEntryHeader const & unpack(std::size_t entryIndex, Region const &outRegion) const
Copy the samples from the bounce buffer entry to the provided output region, and return the header of...
std::vector< Region > getRegions() const noexcept
Return the regions corresponding to the bounce buffer entries. Each region corresponds to one bounce ...
static void getMutableMultiBufferSlices(std::uint64_t index, std::size_t count, std::size_t bufferLength, std::size_t sampleWordSize, std::size_t channelCount, std::uint8_t *baseBufferPtr, mxlMutableWrappedMultiBufferSlice &slice) noexcept
std::size_t entryCount() const noexcept
Return the number of entries in the bounce buffer.
AudioBounceBuffer(std::size_t entryCount, std::size_t entrySize, DataLayout::Continuous layout)
std::vector< AudioBounceBufferEntry > _entries
std::size_t entrySize() const noexcept
Return the size of a bounce buffer entry in bytes.
Represent a memory region (unregistered).
Definition Region.hpp:24
struct mxlMutableWrappedMultiBufferSlice_t mxlMutableWrappedMultiBufferSlice
std::size_t count(uuids::uuid id) const noexcept
Returns the number of writers registered for flow id 'id'.
Header for an audio bounce buffer entry.
Continuous layout variant of DataLayout.
uint64_t index