| 210 | } |
| 211 | |
| 212 | void AudioContext::lazyInitialize() |
| 213 | { |
| 214 | if (m_isInitialized) |
| 215 | return; |
| 216 | |
| 217 | // Don't allow the context to initialize a second time after it's already been explicitly uninitialized. |
| 218 | ASSERT(!m_isAudioThreadFinished); |
| 219 | if (m_isAudioThreadFinished) |
| 220 | return; |
| 221 | |
| 222 | if (m_device.get()) |
| 223 | { |
| 224 | if (!isOfflineContext()) |
| 225 | { |
| 226 | // This starts the audio thread and all audio rendering. |
| 227 | // The destination node's provideInput() method will now be called repeatedly to render audio. |
| 228 | // Each time provideInput() is called, a portion of the audio stream is rendered. |
| 229 | |
| 230 | graphKeepAlive = 0.25f; // pump the graph for the first 0.25 seconds |
| 231 | graphUpdateThread = std::thread(&AudioContext::update, this); |
| 232 | device_callback->start(); |
| 233 | } |
| 234 | |
| 235 | cv.notify_all(); |
| 236 | m_isInitialized = true; |
| 237 | } |
| 238 | else |
| 239 | { |
| 240 | LOG_ERROR("m_device not specified"); |
| 241 | ASSERT(m_device); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | void AudioContext::uninitialize() |
| 246 | { |
no test coverage detected