| 1196 | } |
| 1197 | |
| 1198 | static int cond_wait(hid_device *dev, pthread_cond_t *cond, pthread_mutex_t *mutex) |
| 1199 | { |
| 1200 | while (!dev->input_reports) { |
| 1201 | int res = pthread_cond_wait(cond, mutex); |
| 1202 | if (res != 0) |
| 1203 | return res; |
| 1204 | |
| 1205 | /* A res of 0 means we may have been signaled or it may |
| 1206 | be a spurious wakeup. Check to see that there's actually |
| 1207 | data in the queue before returning, and if not, go back |
| 1208 | to sleep. See the pthread_cond_timedwait() man page for |
| 1209 | details. */ |
| 1210 | |
| 1211 | if (dev->shutdown_thread || dev->disconnected) { |
| 1212 | return -1; |
| 1213 | } |
| 1214 | } |
| 1215 | |
| 1216 | return 0; |
| 1217 | } |
| 1218 | |
| 1219 | static int cond_timedwait(hid_device *dev, pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) |
| 1220 | { |