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

◆ cleanup()

static void MayaFlux::Core::RtAudioSingleton::cleanup ( )
inlinestatic

Releases all audio system resources.

Thread-safe method that performs complete cleanup of the audio subsystem, including stopping and closing any active streams and releasing the RtAudio instance. This method is idempotent and can be safely called multiple times.

This method should be called only before application termination to ensure proper resource deallocation and prevent memory leaks. It is not intended for general use and should not be called during normal application operation.

Definition at line 148 of file RtAudioSingleton.hpp.

149 {
150 std::lock_guard<std::mutex> lock(s_mutex);
151 if (s_instance && s_stream_open) {
152 try {
153 if (s_instance->isStreamRunning()) {
154 s_instance->stopStream();
155 }
156 if (s_instance->isStreamOpen()) {
157 s_instance->closeStream();
158 }
159 s_stream_open = false;
160 } catch (const RtAudioErrorType& e) {
164 std::source_location::current(),
165 "Error during RtAudio cleanup: {}",
166 s_instance->getErrorText());
167 }
168 }
169 if (s_instance) {
170 s_instance.reset();
171 }
172 }
static std::unique_ptr< RtAudio > s_instance
Singleton instance of the RtAudio driver (nullptr until first access)
static bool s_stream_open
Stream state flag to enforce exclusive stream ownership.
static std::mutex s_mutex
Synchronization primitive for thread-safe access to the singleton.
@ AudioBackend
Audio processing backend (RtAudio, JACK, ASIO)
void error_rethrow(Component component, Context context, std::source_location location=std::source_location::current(), std::string_view additional_context="")
Catch and log an exception, then rethrow it.
@ Core
Core engine, backend, subsystems.

References MayaFlux::Journal::AudioBackend, MayaFlux::Journal::Core, s_instance, s_mutex, and s_stream_open.

Referenced by MayaFlux::Core::RtAudioBackend::cleanup().

+ Here is the caller graph for this function: