///////////////////////////////////////////////////////
| 149 | |
| 150 | //////////////////////////////////////////////////////////// |
| 151 | bool AudioDevice::reinitialize() |
| 152 | { |
| 153 | auto* instance = getInstance(); |
| 154 | |
| 155 | // We don't have to do anything if an instance doesn't exist yet |
| 156 | if (!instance) |
| 157 | return true; |
| 158 | |
| 159 | const std::lock_guard lock(instance->m_resourcesMutex); |
| 160 | |
| 161 | // Deinitialize all audio resources |
| 162 | for (const auto& entry : instance->m_resources) |
| 163 | entry.deinitializeFunc(entry.resource); |
| 164 | |
| 165 | // Destroy the old engine |
| 166 | if (instance->m_engine) |
| 167 | ma_engine_uninit(&*instance->m_engine); |
| 168 | |
| 169 | // Destroy the old playback device |
| 170 | if (instance->m_playbackDevice) |
| 171 | ma_device_uninit(&*instance->m_playbackDevice); |
| 172 | |
| 173 | // Destroy the old context |
| 174 | if (instance->m_context) |
| 175 | ma_context_uninit(&*instance->m_context); |
| 176 | |
| 177 | // Create the new objects |
| 178 | const auto result = instance->initialize(); |
| 179 | |
| 180 | // Reinitialize all audio resources |
| 181 | for (const auto& entry : instance->m_resources) |
| 182 | entry.reinitializeFunc(entry.resource); |
| 183 | |
| 184 | return result; |
| 185 | } |
| 186 | |
| 187 | |
| 188 | //////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected