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

◆ read_once()

bool MayaFlux::Buffers::AudioBuffer::read_once ( std::shared_ptr< AudioBuffer buffer,
bool  force = false 
)
virtual

Reads audio data into the buffer from the audio backend.

Parameters
bufferShared pointer to the AudioBuffer to read data into
forceWhether to force reading even if in processing state
Returns
True if data was successfully read, false otherwise

This method attempts to read audio data from the audio backend into the provided AudioBuffer. If force is true, it will attempt to read even if the current buffer or the copy buffer are in processing state

Definition at line 94 of file AudioBuffer.cpp.

95{
96 if (buffer && buffer->get_num_samples() == m_num_samples) {
97 if (m_is_processing.load() || buffer->is_processing()) {
99 "read_once: Attempting to read from an audio buffer while it is being processed.");
100
101 if (!force) {
103 "read_once: Skipping read due to ongoing processing.");
104 return false;
105 }
107 "read_once: Forcing read despite ongoing processing. This may lead to data corruption.");
108 }
109 m_data = buffer->get_data();
110 m_has_data = true;
111 return true;
112 }
113
115 "read_once: Buffer read failed due to size mismatch or null buffer.");
116
117 return false;
118}
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
bool m_has_data
Whether the audio buffer has data to process this cycle.
std::atomic< bool > m_is_processing
uint32_t m_num_samples
Capacity of the buffer in audio samples.
std::vector< double > m_data
Vector storing the actual double-precision audio sample data.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, m_data, m_has_data, m_is_processing, m_num_samples, MF_ERROR, and MF_WARN.