MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
AudioOutputAccessProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
5
7struct AudioBackendService;
8}
9
10namespace MayaFlux::Kakshya {
11
12/**
13 * @class AudioOutputAccessProcessor
14 * @brief Default DataProcessor for AudioOutputContainer.
15 *
16 * Each process() call performs two writes:
17 *
18 * 1. m_processed_data — deinterleaved snapshot for the current cycle only.
19 * PLANAR: processed_data[ch] = vector<double>(buffer_size)
20 * INTERLEAVED: processed_data[0] = vector<double>(buffer_size * channels)
21 *
22 * 2. m_data (history) — the same deinterleaved per-channel data is appended
23 * to the container's growing corpus via write_frames(). The write head
24 * (get_num_frames()) advances by buffer_size each cycle, enabling
25 * CursorAccessProcessor readers to chase it independently.
26 *
27 * The snapshot pointer from AudioBackendService::get_output_snapshot is
28 * engine-owned and valid only for the duration of process(). Both writes
29 * complete before process() returns.
30 *
31 * on_attach validates that the container is an AudioOutputContainer and
32 * caches channel count, buffer size, and organization strategy.
33 */
34class MAYAFLUX_API AudioOutputAccessProcessor : public DataProcessor {
35public:
36 /**
37 * @brief Construct with the fixed output block size.
38 * @param buffer_size Frames per cycle, must match GlobalStreamInfo::buffer_size.
39 */
40 explicit AudioOutputAccessProcessor(uint32_t buffer_size);
41
42 ~AudioOutputAccessProcessor() override = default;
43
44 /**
45 * @brief Validate container type, cache structure, mark ready for processing.
46 * @throws std::invalid_argument if container is not an AudioOutputContainer.
47 */
48 void on_attach(const std::shared_ptr<SignalSourceContainer>& container) override;
49
50 /**
51 * @brief Clear cached state.
52 */
53 void on_detach(const std::shared_ptr<SignalSourceContainer>& container) override;
54
55 /**
56 * @brief Pull engine snapshot, write m_processed_data, append to m_data.
57 *
58 * No-op if the backend service is unavailable or the snapshot is empty.
59 * Logs a trace-level message in those cases rather than erroring, since
60 * the first few calls during engine startup may arrive before any cycle
61 * has completed.
62 */
63 void process(const std::shared_ptr<SignalSourceContainer>& container) override;
64
65 [[nodiscard]] bool is_processing() const override { return m_is_processing.load(); }
66
67private:
68 uint32_t m_buffer_size { 0 };
69 uint32_t m_channel_count { 0 };
70 OrganizationStrategy m_organization { OrganizationStrategy::PLANAR };
71 std::atomic<bool> m_is_processing { false };
72
73 Registry::Service::AudioBackendService* m_backend_service { nullptr };
74};
75
76} // namespace MayaFlux::Kakshya
bool is_processing() const override
Checks if the processor is currently performing processing.
Default DataProcessor for AudioOutputContainer.
Interface for processing data within SignalSourceContainer objects.
OrganizationStrategy
Data organization strategy for multi-channel/multi-frame data.
Definition NDData.hpp:49
Backend audio subsystem service interface.