MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Core.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file API/Core.hpp
5 * @brief Core engine lifecycle and configuration API
6 *
7 * This header provides the fundamental engine control and configuration
8 * functions that form the foundation of the MayaFlux framework. All other
9 * subsystems depend on the engine being properly initialized and configured.
10 *
11 * The Core API handles:
12 * - Engine initialization with various stream configurations
13 * - Engine lifecycle management (Start, Pause, Resume, End)
14 * - Access to core engine context and configuration
15 * - Global stream information queries
16 *
17 * This is typically the first API users interact with when setting up
18 * a MayaFlux application, and other API modules depend on these functions
19 * for accessing engine subsystems.
20 */
21namespace MayaFlux {
22
23namespace Core {
24 struct GlobalStreamInfo;
25 struct GlobalGraphicsConfig;
26 struct GlobalInputConfig;
27 struct GlobalNetworkConfig;
28 class Engine;
29}
30
31//-------------------------------------------------------------------------
32// Engine Management
33//-------------------------------------------------------------------------
34
35/**
36 * @brief Checks if the default engine has been initialized
37 * @return true if the engine is initialized, false otherwise
38 */
39bool is_initialized();
40
41/**
42 * @brief Checks if the default engine has currently accepted all configurations and initialized all managers
43 * @return true if the engine is fully configured and ready for processing, false otherwise
44 */
45bool is_configured();
46
47/**
48 * @brief Gets the default engine instance
49 * @return Reference to the default Engine
50 *
51 * Creates the engine if it doesn't exist yet. This is the centrally managed
52 * engine instance that all convenience functions in this namespace operate on.
53 */
54MAYAFLUX_API Core::Engine& get_context();
55
56/**
57 * @brief Replaces the default engine with a new instance
58 * @param instance New engine instance to use as default
59 *
60 * Transfers state from the old engine to the new one if possible.
61 *
62 * @warning This function uses move semantics. After calling this function,
63 * the engine instance passed as parameter will be left in a moved-from state
64 * and should not be used further. This is intentional to avoid resource duplication
65 * and ensure proper transfer of ownership. Users should be careful to not access
66 * the moved-from instance after calling this function.
67 *
68 * This function is intended for advanced use cases where custom engine configuration
69 * is required beyond what the standard initialization functions provide.
70 */
71MAYAFLUX_API void set_and_transfer_context(Core::Engine instance);
72
73/**
74 * @brief Initializes the default engine with specified parameters
75 * @param sample_rate Audio sample rate in Hz
76 * @param buffer_size Size of audio processing buffer in frames
77 * @param num_out_channels Number of output channels
78 * @param num_in_channels Number of input channels
79 *
80 * Convenience wrapper for Engine::Init() on the default engine.
81 */
82MAYAFLUX_API void Init(uint32_t sample_rate, uint32_t buffer_size = 512, uint32_t num_out_channels = 2, uint32_t num_in_channels = 0);
83
84/**
85 * @brief Initializes the default engine with default settings
86 *
87 * Convenience wrapper for Engine::Init() on the default engine.
88 */
89MAYAFLUX_API void Init();
90
91/**
92 * @brief Initializes the default engine with specified stream and graphics info
93 * @param stream_info Configuration for sample rate, buffer size, and channels
94 * @param graphics_info Configuration for graphics/windowing backend
95 * @param input_config Configuration for input handling
96 * @param network_config Configuration for network subsystem
97 *
98 * Convenience wrapper for Engine::Init() on the default engine.
99 */
100MAYAFLUX_API void Init(Core::GlobalStreamInfo stream_info, Core::GlobalGraphicsConfig graphics_config, Core::GlobalInputConfig input_config, Core::GlobalNetworkConfig network_config);
101
102/**
103 * @brief Starts audio processing on the default engine
104 *
105 * Convenience wrapper for Engine::Start() on the default engine.
106 */
107MAYAFLUX_API void Start();
108
109/**
110 * @brief Pauses audio processing on the default engine
111 *
112 * Convenience wrapper for Engine::Pause() on the default engine.
113 */
114MAYAFLUX_API void Pause();
115
116/**
117 * @brief Resumes audio processing on the default engine
118 *
119 * Convenience wrapper for Engine::Resume() on the default engine.
120 */
121MAYAFLUX_API void Resume();
122
123/**
124 * @brief Blocks launcher until user input (optional convenience function)
125 *
126 * Use this only in launcher applications that need to block the main
127 * thread until shutdown is requested.
128 *
129 * On macOS: Spawns input thread and allow GLFW to run on main thread
130 * On Linux/Windows: Simple blocking cin.get()
131 *
132 * Usage (optional):
133 * ```cpp
134 * engine->start_graphics();
135 * std::cout << "Press Enter to stop...\n";
136 * MayaFlux::Await(); // Blocks here (optional)
137 * engine->stop_graphics();
138 * ```
139 */
140MAYAFLUX_API void Await();
141
142/**
143 * @brief Stops and cleans up the default engine
144 *
145 * Convenience wrapper for Engine::End() on the default engine.
146 */
147MAYAFLUX_API void End();
148
149}
@ Core
Core engine, backend, subsystems.
void Resume()
Resumes audio processing on the default engine.
Definition Core.cpp:132
void Start()
Starts audio processing on the default engine.
Definition Core.cpp:120
bool is_configured()
Checks if the default engine has currently accepted all configurations and initialized all managers.
Definition Core.cpp:60
void Pause()
Pauses audio processing on the default engine.
Definition Core.cpp:125
void Init()
Initializes the default engine with default settings.
Definition Core.cpp:96
void set_and_transfer_context(Core::Engine instance)
Replaces the default engine with a new instance.
Definition Core.cpp:73
Core::Engine & get_context()
Gets the default engine instance.
Definition Core.cpp:68
void Await()
Blocks launcher until user input (optional convenience function)
Definition Core.cpp:139
bool is_initialized()
Checks if the default engine has been initialized.
Definition Core.cpp:52
void End()
Stops and cleans up the default engine.
Definition Core.cpp:146
Main namespace for the Maya Flux audio engine.
Definition Runtime.cpp:12