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

◆ on_attach()

void MayaFlux::Buffers::SoundStreamReader::on_attach ( const std::shared_ptr< Buffer > &  buffer)
overridevirtual

Attach the adapter to an AudioBuffer.

Registers for container state changes and prepares for processing.

Parameters
bufferThe AudioBuffer to attach to.

Reimplemented from MayaFlux::Buffers::BufferProcessor.

Definition at line 105 of file SoundContainerBuffer.cpp.

106{
107 if (!m_container || !buffer) {
108 return;
109 }
110
111 m_reader_id = m_container->register_dimension_reader(m_source_channel);
112
113 if (!m_container->is_ready_for_processing()) {
115 std::source_location::current(),
116 "SoundStreamReader: Container not ready for processing");
117 }
118
119 try {
120 auto& buffer_data = std::dynamic_pointer_cast<AudioBuffer>(buffer)->get_data();
121 uint32_t num_samples = std::dynamic_pointer_cast<AudioBuffer>(buffer)->get_num_samples();
122
123 extract_channel_data(buffer_data);
124
125 if (m_update_flags) {
126 buffer->mark_for_processing(true);
127 }
128
129 } catch (const std::exception& e) {
131 "SoundStreamReader: Error pre-filling buffer: {}", e.what());
132 }
133}
#define MF_ERROR(comp, ctx,...)
std::shared_ptr< Kakshya::StreamContainer > m_container
void extract_channel_data(std::span< double > output)
Extract channel data from the container into the output buffer.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, extract_channel_data(), m_container, m_reader_id, m_source_channel, m_update_flags, and MF_ERROR.

+ Here is the call graph for this function: