void AudioContext::uninitialize() { if (m_isInitialized) { // This stops the audio thread and all audio rendering. m_destinationNode->uninitialize(); // Don't allow the context to initialize a second time after it's already been explicitly uninitialized. m_isAudioThreadFinished = true; // We have to release our reference to the destination node before the context will ever be deleted since the destination node holds a reference to the context. m_destinationNode.clear(); // Get rid of the sources which may still be playing. derefUnfinishedSourceNodes(); // Because the AudioBuffers are garbage collected, we can't delete them here. // Instead, at least release the potentially large amount of allocated memory for the audio data. // Note that we do this *after* the context is uninitialized and stops processing audio. for (unsigned i = 0; i < m_allocatedBuffers.size(); ++i) m_allocatedBuffers[i]->releaseMemory(); m_allocatedBuffers.clear(); m_isInitialized = false; } }
void AudioContext::uninitialize() { ASSERT(isMainThread()); if (!m_isInitialized) return; // This stops the audio thread and all audio rendering. m_destinationNode->uninitialize(); // Don't allow the context to initialize a second time after it's already been explicitly uninitialized. m_isAudioThreadFinished = true; if (!isOfflineContext()) { document()->removeAudioProducer(this); ASSERT(s_hardwareContextCount); --s_hardwareContextCount; // Offline contexts move to 'Closed' state when dispatching the completion event. setState(State::Closed); } // Get rid of the sources which may still be playing. derefUnfinishedSourceNodes(); m_isInitialized = false; }
void AudioContext::uninitialize() { ASSERT(isMainThread()); if (m_isInitialized) { // Protect this object from being deleted before we finish uninitializing. RefPtr<AudioContext> protect(this); // This stops the audio thread and all audio rendering. m_destinationNode->uninitialize(); // Don't allow the context to initialize a second time after it's already been explicitly uninitialized. m_isAudioThreadFinished = true; // We have to release our reference to the destination node before the context will ever be deleted since the destination node holds a reference to the context. m_destinationNode.clear(); if (!isOfflineContext()) { ASSERT(s_hardwareContextCount); --s_hardwareContextCount; } // Get rid of the sources which may still be playing. derefUnfinishedSourceNodes(); deleteMarkedNodes(); m_isInitialized = false; } }
void AudioContext::uninitialize() { ASSERT(isMainThread()); if (!isInitialized()) return; m_isInitialized = false; // This stops the audio thread and all audio rendering. if (m_destinationNode) m_destinationNode->handler().uninitialize(); if (!isOfflineContext()) { ASSERT(s_hardwareContextCount); --s_hardwareContextCount; } // Get rid of the sources which may still be playing. derefUnfinishedSourceNodes(); // Reject any pending resolvers before we go away. rejectPendingResolvers(); // For an offline audio context, the completion event will set the state to closed. For an // online context, we need to do it here. We only want to set the closed state once. if (!isOfflineContext()) setContextState(Closed); // Resolve the promise now, if any if (m_closeResolver) m_closeResolver->resolve(); ASSERT(m_listener); m_listener->waitForHRTFDatabaseLoaderThreadCompletion(); clear(); }
void AudioContext::uninitialize() { ASSERT(isMainThread()); if (!m_isInitialized) return; // This stops the audio thread and all audio rendering. m_destinationNode->uninitialize(); // Don't allow the context to initialize a second time after it's already been explicitly uninitialized. m_isAudioThreadFinished = true; if (!isOfflineContext()) { ASSERT(s_hardwareContextCount); --s_hardwareContextCount; } // Get rid of the sources which may still be playing. derefUnfinishedSourceNodes(); m_isInitialized = false; }