-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Milestone
Description
This issue happens randomly on my machine: By running the sample code available on the docs, sometimes the program would freeze for several seconds just before the exit point. After digging into the code, I found out that the library was freezing at the "freenect_process_events(m_ctx)" call. By moving the "m_stop=true" assignment to the top of the Freenect destructor, the device thread would finish without any problems while the m_devices container is being erased.
So, to solve this, I just had to apply these changes:
--- a/wrappers/cpp/libfreenect.hpp
+++ b/wrappers/cpp/libfreenect.hpp
@@ -182,10 +182,10 @@ namespace Freenect {
if(pthread_create(&m_thread, NULL, pthread_callback, (void*)this) != 0) throw std::runtime_error("Cannot initialize freenect thread");
}
~Freenect() {
+ m_stop = true;
for(DeviceMap::iterator it = m_devices.begin() ; it != m_devices.end() ; ++it) {
delete it->second;
}
- m_stop = true;
pthread_join(m_thread, NULL);
if(freenect_shutdown(m_ctx) < 0){} //FN_WARNING("Freenect did not shutdown in a clean fashion");
}
Metadata
Metadata
Assignees
Labels
No labels