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

◆ processing_function()

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

Extracts and processes data from the container into the target AudioBuffer.

Handles dimension mapping, position tracking, and state synchronization.

Parameters
bufferThe AudioBuffer to fill.

Implements MayaFlux::Buffers::BufferProcessor.

Definition at line 25 of file SoundContainerBuffer.cpp.

26{
27 if (!m_container || !buffer) {
28 return;
29 }
30
31 if (m_container->is_at_end()) {
32 buffer->mark_for_removal();
33 return;
34 }
35
36 try {
37 auto state = m_container->get_processing_state();
38
40 if (m_update_flags) {
41 buffer->mark_for_removal();
42 }
43 return;
44 }
45
48 if (m_container->try_acquire_processing_token(m_source_channel)) {
49 m_container->process_default();
50 }
51 }
52 }
53
54 auto audio_buffer = std::dynamic_pointer_cast<AudioBuffer>(buffer);
55 auto& buffer_data = audio_buffer->get_data();
56 uint32_t buffer_size = audio_buffer->get_num_samples();
57
58 auto read_positions = m_container->get_read_position();
59 uint64_t current_pos = (m_source_channel < read_positions.size())
60 ? read_positions[m_source_channel]
61 : 0;
62
63 if (buffer_data.size() != buffer_size) {
64 buffer_data.resize(buffer_size);
65 }
66
67 extract_channel_data(buffer_data);
68
69 if (m_auto_advance) {
70 m_container->update_read_position_for_channel(m_source_channel, current_pos + buffer_size);
71 }
72
73 if (m_update_flags) {
74 buffer->mark_for_processing(true);
75 }
76
77 m_container->mark_dimension_consumed(m_source_channel, m_reader_id);
78
79 if (m_container->all_dimensions_consumed()) {
80 m_container->update_processing_state(Kakshya::ProcessingState::READY);
81 std::dynamic_pointer_cast<Kakshya::SoundFileContainer>(m_container)->clear_all_consumption();
82 m_container->reset_processing_token();
83 }
84
85 } catch (const std::exception& e) {
87 "SoundStreamReader: Error during processing: {}", e.what());
88 }
89}
#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.
@ READY
Container has data loaded and is ready for processing.
@ NEEDS_REMOVAL
Container is marked for removal from the system.
@ PROCESSED
Container has completed processing and results are available.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, extract_channel_data(), m_auto_advance, m_container, m_reader_id, m_source_channel, m_update_flags, MF_ERROR, MayaFlux::Kakshya::NEEDS_REMOVAL, MayaFlux::Kakshya::PROCESSED, and MayaFlux::Kakshya::READY.

+ Here is the call graph for this function: