void Context::shutdown() { --m_initializationCounter; if (m_initializationCounter > 0) { xnLogInfo(XN_LOG_MASK_ALL, "Shutdown: still need %d more shutdown calls (to match initializations)", m_initializationCounter); return; } if (!s_valid) { return; } s_valid = FALSE; m_cs.Lock(); // Close all recorders. while (m_recorders.Begin() != m_recorders.End()) { Recorder* pRecorder = *m_recorders.Begin(); recorderClose(pRecorder); } // Destroy all streams while (m_streams.Begin() != m_streams.End()) { VideoStream* pStream = *m_streams.Begin(); streamDestroy(pStream); } // Close all devices while (m_devices.Begin() != m_devices.End()) { Device* pDevice = *m_devices.Begin(); m_devices.Remove(pDevice); pDevice->close(); XN_DELETE(pDevice); } for (xnl::List<DeviceDriver*>::Iterator iter = m_deviceDrivers.Begin(); iter != m_deviceDrivers.End(); ++iter) { DeviceDriver* pDriver = *iter; XN_DELETE(pDriver); } m_deviceDrivers.Clear(); m_newFrameAvailableEvent.Close(); m_cs.Unlock(); xnLogClose(); }
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) { if (dwReason == DLL_PROCESS_DETACH) { xnLogClose(); } BOOL bRes = DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved); // init log from local file (if it exists) if (dwReason == DLL_PROCESS_ATTACH) { xnLogInitFromXmlFile("OpenNIConfig.xml"); } return bRes; }