Display and control your Android device
Add cond_wait_timeout()
Romain Vimontd104d3bda91b
diff --git a/app/src/lock_util.c b/app/src/lock_util.cindex 7b70ba6b..36706063 100644--- a/app/src/lock_util.c+++ b/app/src/lock_util.c@@ -28,6 +28,16 @@ cond_wait(SDL_cond *cond, SDL_mutex *mutex) {}}+int+cond_wait_timeout(SDL_cond *cond, SDL_mutex *mutex, uint32_t ms) {+ int r = SDL_CondWaitTimeout(cond, mutex, ms);+ if (r < 0) {+ LOGC("Could not wait on condition with timeout");+ abort();+ }+ return r;+}+voidcond_signal(SDL_cond *cond) {if (SDL_CondSignal(cond)) {diff --git a/app/src/lock_util.h b/app/src/lock_util.hindex 99c1f8d6..6c27602d 100644--- a/app/src/lock_util.h+++ b/app/src/lock_util.h@@ -1,6 +1,8 @@#ifndef LOCKUTIL_H#define LOCKUTIL_H+#include <stdint.h>+// forward declarationstypedef struct SDL_mutex SDL_mutex;typedef struct SDL_cond SDL_cond;@@ -14,6 +16,10 @@ mutex_unlock(SDL_mutex *mutex);voidcond_wait(SDL_cond *cond, SDL_mutex *mutex);+// return 0 or SDL_MUTEX_TIMEDOUT+int+cond_wait_timeout(SDL_cond *cond, SDL_mutex *mutex, uint32_t ms);+voidcond_signal(SDL_cond *cond);