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

◆ stop()

void MayaFlux::IO::IOManager::stop ( )

Finalizes all in-flight output while consumers are still running.

Stops every audio, video, volume and spatial capture through its stop_*_capture() call, closes the sound writers and waits for pending saves. A capture the caller never stopped is still finalized (an Ogawa archive or video container left open is not a valid file), and volume/spatial captures release their scheduler reference here instead of reaching into an already-destroyed scheduler.

The IOService stays registered and readers stay alive, so threads that consume them keep working. Idempotent. Call before the subsystems stop (see Engine::End()), while backend services and logging sinks are alive.

Definition at line 106 of file IOManager.cpp.

107{
108 if (m_stop_done.exchange(true)) {
109 return;
110 }
111
112 {
113 std::vector<uint32_t> ids;
114 {
115 std::lock_guard lock(m_audio_captures_mutex);
116 ids.reserve(m_audio_captures.size());
117 for (const auto& [id, _] : m_audio_captures)
118 ids.push_back(id);
119 }
120 for (auto id : ids)
122 }
123
124 {
125 std::vector<uint32_t> ids;
126 {
127 std::lock_guard lock(m_video_captures_mutex);
128 ids.reserve(m_video_captures.size());
129 for (const auto& [id, _] : m_video_captures)
130 ids.push_back(id);
131 }
132 for (auto id : ids)
134 }
135
136 {
137 std::vector<uint32_t> ids;
138 {
139 std::lock_guard lock(m_volume_captures_mutex);
140 ids.reserve(m_volume_captures.size());
141 for (const auto& [id, _] : m_volume_captures)
142 ids.push_back(id);
143 }
144 for (auto id : ids)
146 }
147
148 {
149 std::vector<uint32_t> ids;
150 {
151 std::lock_guard lock(m_spatial_captures_mutex);
152 ids.reserve(m_spatial_captures.size());
153 for (const auto& [id, _] : m_spatial_captures)
154 ids.push_back(id);
155 }
156 for (auto id : ids)
158 }
159
160 for (auto& w : m_writers) {
161 if (w->is_open()) {
162 auto fut = w->close();
163 fut.wait();
164 }
165 }
166
168
170}
#define MF_TRACE(comp, ctx,...)
std::vector< uint64_t > ids
std::unordered_map< uint32_t, SpatialCaptureEntry > m_spatial_captures
std::unordered_map< uint32_t, AudioCaptureState > m_audio_captures
void stop_spatial_capture(uint32_t capture_id)
Stop a running spatial capture and release it.
void stop_audio_capture(uint32_t capture_id)
Stop a running audio capture and finalise the file.
std::mutex m_volume_captures_mutex
void stop_volume_capture(uint32_t capture_id)
Stop a running volume capture and release it.
void stop_video_capture(uint32_t capture_id)
Stop a running video capture and finalise the file.
std::vector< std::shared_ptr< SoundFileWriter > > m_writers
std::mutex m_spatial_captures_mutex
std::mutex m_video_captures_mutex
std::atomic< bool > m_stop_done
void wait_for_pending_saves()
Wait for all in-flight save operations to complete.
std::unordered_map< uint32_t, VideoCaptureState > m_video_captures
std::mutex m_audio_captures_mutex
std::unordered_map< uint32_t, std::unique_ptr< IO::VolumeCapture > > m_volume_captures
@ Init
Engine/subsystem initialization.
@ IO
Networking, file handling, streaming.

References ids, MayaFlux::Journal::Init, MayaFlux::Journal::IO, m_audio_captures, m_audio_captures_mutex, m_spatial_captures, m_spatial_captures_mutex, m_stop_done, m_video_captures, m_video_captures_mutex, m_volume_captures, m_volume_captures_mutex, m_writers, MF_TRACE, stop_audio_capture(), stop_spatial_capture(), stop_video_capture(), stop_volume_capture(), and wait_for_pending_saves().

Referenced by shutdown().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: