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 28
28
29
29
#include < libfreenect.h>
30
30
#include < stdexcept>
31
+ #include < sstream>
31
32
#include < map>
32
33
#include < pthread.h>
34
+ #include < libusb-1.0/libusb.h>
33
35
34
36
namespace Freenect {
35
37
class Noncopyable {
@@ -209,7 +211,20 @@ namespace Freenect {
209
211
// Do not call directly, thread runs here
210
212
void operator ()() {
211
213
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
+ }
213
228
}
214
229
}
215
230
static void *pthread_callback (void *user_data) {
You can’t perform that action at this time.
0 commit comments