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

◆ processing_function()

void MayaFlux::Buffers::ContainerToBufferAdapter::processing_function ( 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 23 of file ContainerBuffer.cpp.

24{
25 if (!m_container || !buffer) {
26 return;
27 }
28
29 if (m_container->is_at_end()) {
30 buffer->mark_for_removal();
31 return;
32 }
33
34 try {
35 auto state = m_container->get_processing_state();
36
38 if (m_update_flags) {
39 buffer->mark_for_removal();
40 }
41 return;
42 }
43
46 if (m_container->try_acquire_processing_token(m_source_channel)) {
47 m_container->process_default();
48 }
49 }
50 }
51
52 auto audio_buffer = std::dynamic_pointer_cast<AudioBuffer>(buffer);
53 auto& buffer_data = audio_buffer->get_data();
54 uint32_t buffer_size = audio_buffer->get_num_samples();
55
56 auto read_positions = m_container->get_read_position();
57 uint64_t current_pos = (m_source_channel < read_positions.size())
58 ? read_positions[m_source_channel]
59 : 0;
60
61 if (buffer_data.size() != buffer_size) {
62 buffer_data.resize(buffer_size);
63 }
64
65 extract_channel_data(buffer_data);
66
67 if (m_auto_advance) {
68 m_container->update_read_position_for_channel(m_source_channel, current_pos + buffer_size);
69 }
70
71 if (m_update_flags) {
72 buffer->mark_for_processing(true);
73 }
74
75 m_container->mark_dimension_consumed(m_source_channel, m_reader_id);
76
77 if (m_container->all_dimensions_consumed()) {
78 m_container->update_processing_state(Kakshya::ProcessingState::READY);
79 std::dynamic_pointer_cast<Kakshya::SoundFileContainer>(m_container)->clear_all_consumption();
80 m_container->reset_processing_token();
81 }
82
83 } catch (const std::exception& e) {
84 std::cerr << "Error in ContainerToBufferAdapter::process: " << e.what() << '\n';
85 }
86}
void extract_channel_data(std::span< double > output)
Extract channel data from the container into the output buffer.
std::shared_ptr< Kakshya::StreamContainer > m_container
@ 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 extract_channel_data(), m_auto_advance, m_container, m_reader_id, m_source_channel, m_update_flags, MayaFlux::Kakshya::NEEDS_REMOVAL, MayaFlux::Kakshya::PROCESSED, and MayaFlux::Kakshya::READY.

+ Here is the call graph for this function: