MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ linearized_view()

template<typename T , typename StoragePolicy , typename ConcurrencyPolicy = SingleThreadedPolicy, typename AccessPattern = QueueAccess>
std::span< T > MayaFlux::Memory::RingBuffer< T, StoragePolicy, ConcurrencyPolicy, AccessPattern >::linearized_view ( ) const
inline

Get linearized view of buffer contents.

Returns
Span ordered by AccessPattern

Only available for SingleThreadedPolicy. Returns contiguous view of buffer data in logical order:

Not Real-time Safe: Copies data to linear buffer. Use sparingly in audio processing paths.

Definition at line 925 of file RingBuffer.hpp.

927 {
928 const size_t cap = m_storage.capacity();
929 const size_t count = size();
930
931 if constexpr (AccessPattern::push_front) {
932 for (size_t i = 0; i < count; ++i) {
933 size_t idx = (m_state.write_index + cap - i) % cap;
934 m_linearized[i] = m_storage.buffer[idx];
935 }
936 } else {
937 for (size_t i = 0; i < count; ++i) {
938 size_t idx = (m_state.read_index + i) % cap;
939 m_linearized[i] = m_storage.buffer[idx];
940 }
941 }
942
943 return { m_linearized.data(), count };
944 }
size_t count
size_t size() const noexcept
Get approximate element count.

References count, MayaFlux::Memory::RingBuffer< T, StoragePolicy, ConcurrencyPolicy, AccessPattern >::m_linearized, MayaFlux::Memory::RingBuffer< T, StoragePolicy, ConcurrencyPolicy, AccessPattern >::m_state, MayaFlux::Memory::RingBuffer< T, StoragePolicy, ConcurrencyPolicy, AccessPattern >::m_storage, and MayaFlux::Memory::RingBuffer< T, StoragePolicy, ConcurrencyPolicy, AccessPattern >::size().

Referenced by MayaFlux::Memory::RingBuffer< T, StoragePolicy, ConcurrencyPolicy, AccessPattern >::snapshot().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: