File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 2828
2929#include < libfreenect.h>
3030#include < stdexcept>
31+ #include < sstream>
3132#include < map>
3233#include < pthread.h>
34+ #include < libusb-1.0/libusb.h>
3335
3436namespace Freenect {
3537 class Noncopyable {
@@ -209,7 +211,20 @@ namespace Freenect {
209211 // Do not call directly, thread runs here
210212 void operator ()() {
211213 while (!m_stop) {
212- if (freenect_process_events (m_ctx) < 0 ) throw std::runtime_error (" Cannot process freenect events" );
214+ int res = freenect_process_events (m_ctx);
215+ if (res < 0 )
216+ {
217+ // libusb signals an error has occurred
218+ if (res == LIBUSB_ERROR_INTERRUPTED)
219+ {
220+ // This happens sometimes, it means that a system call in libusb was interrupted somehow (perhaps due to a signal)
221+ // The simple solution seems to be just ignore it.
222+ continue ;
223+ }
224+ std::stringstream ss;
225+ ss << " Cannot process freenect events (libusb error code: " << res << " )" ;
226+ throw std::runtime_error (ss.str ());
227+ }
213228 }
214229 }
215230 static void *pthread_callback (void *user_data) {
You can’t perform that action at this time.
0 commit comments