MayaFlux 0.1.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 117 of file RtAudioSingleton.hpp.

118 {
119 std::lock_guard<std::mutex> lock(s_mutex);
120 if (s_instance && s_stream_open) {
121 try {
122 if (s_instance->isStreamRunning()) {
123 s_instance->stopStream();
124 }
125 if (s_instance->isStreamOpen()) {
126 s_instance->closeStream();
127 }
128 s_stream_open = false;
129 } catch (const RtAudioErrorType& e) {
130 std::cerr << "Error during RtAudio cleanup: " << s_instance->getErrorText() << std::endl;
131 }
132 }
133 if (s_instance) {
134 s_instance.reset();
135 }
136 }
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.

References s_instance, s_mutex, and s_stream_open.

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

+ Here is the caller graph for this function: