diff --git a/app/meson.build b/app/meson.build index 732cf1e..7781d77 100644 --- a/app/meson.build +++ b/app/meson.build @@ -10,7 +10,6 @@ src = [ 'src/file_handler.c', 'src/fps_counter.c', 'src/input_manager.c', - 'src/lock_util.c', 'src/net.c', 'src/receiver.c', 'src/recorder.c', diff --git a/app/src/lock_util.c b/app/src/lock_util.c deleted file mode 100644 index 3670606..0000000 --- a/app/src/lock_util.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include - -#include "log.h" - -void -mutex_lock(SDL_mutex *mutex) { - if (SDL_LockMutex(mutex)) { - LOGC("Could not lock mutex"); - abort(); - } -} - -void -mutex_unlock(SDL_mutex *mutex) { - if (SDL_UnlockMutex(mutex)) { - LOGC("Could not unlock mutex"); - abort(); - } -} - -void -cond_wait(SDL_cond *cond, SDL_mutex *mutex) { - if (SDL_CondWait(cond, mutex)) { - LOGC("Could not wait on condition"); - abort(); - } -} - -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; -} - -void -cond_signal(SDL_cond *cond) { - if (SDL_CondSignal(cond)) { - LOGC("Could not signal a condition"); - abort(); - } -} - diff --git a/app/src/lock_util.h b/app/src/lock_util.h index 6c27602..d1ca733 100644 --- a/app/src/lock_util.h +++ b/app/src/lock_util.h @@ -2,25 +2,50 @@ #define LOCKUTIL_H #include - -// forward declarations -typedef struct SDL_mutex SDL_mutex; -typedef struct SDL_cond SDL_cond; - -void -mutex_lock(SDL_mutex *mutex); - -void -mutex_unlock(SDL_mutex *mutex); - -void -cond_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); - -void -cond_signal(SDL_cond *cond); +#include + +#include "log.h" + +static inline void +mutex_lock(SDL_mutex *mutex) { + if (SDL_LockMutex(mutex)) { + LOGC("Could not lock mutex"); + abort(); + } +} + +static inline void +mutex_unlock(SDL_mutex *mutex) { + if (SDL_UnlockMutex(mutex)) { + LOGC("Could not unlock mutex"); + abort(); + } +} + +static inline void +cond_wait(SDL_cond *cond, SDL_mutex *mutex) { + if (SDL_CondWait(cond, mutex)) { + LOGC("Could not wait on condition"); + abort(); + } +} + +static inline 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; +} + +static inline void +cond_signal(SDL_cond *cond) { + if (SDL_CondSignal(cond)) { + LOGC("Could not signal a condition"); + abort(); + } +} #endif