diff --git a/app/src/decoder.c b/app/src/decoder.c index 926de94f..daba0d07 100644 --- a/app/src/decoder.c +++ b/app/src/decoder.c @@ -21,7 +21,7 @@ static int read_packet(void *opaque, uint8_t *buf, int buf_size) { // set the decoded frame as ready for rendering, and notify static void push_frame(struct decoder *decoder) { struct frames *frames = decoder->frames; - lock_mutex(frames->mutex); + mutex_lock(frames->mutex); if (!decoder->skip_frames) { while (!frames->rendering_frame_consumed) { SDL_CondWait(frames->rendering_frame_consumed_cond, frames->mutex); @@ -32,7 +32,7 @@ static void push_frame(struct decoder *decoder) { frames_swap(frames); frames->rendering_frame_consumed = SDL_FALSE; - unlock_mutex(frames->mutex); + mutex_unlock(frames->mutex); static SDL_Event new_frame_event = { .type = EVENT_NEW_FRAME, diff --git a/app/src/lockutil.h b/app/src/lockutil.h index 1988eecd..a2e6f0fa 100644 --- a/app/src/lockutil.h +++ b/app/src/lockutil.h @@ -1,14 +1,18 @@ #ifndef LOCKUTIL_H #define LOCKUTIL_H -static inline void lock_mutex(SDL_mutex *mutex) { +#include +#include +#include + +static inline void mutex_lock(SDL_mutex *mutex) { if (SDL_LockMutex(mutex)) { SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not lock mutex"); exit(1); } } -static inline void unlock_mutex(SDL_mutex *mutex) { +static inline void mutex_unlock(SDL_mutex *mutex) { if (SDL_UnlockMutex(mutex)) { SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not unlock mutex"); exit(1); diff --git a/app/src/screen.c b/app/src/screen.c index 8b2adf77..0dc3265b 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -349,7 +349,7 @@ SDL_bool show_screen(const char *serial, Uint16 local_port) { case SDL_QUIT: goto screen_quit; case EVENT_NEW_FRAME: - lock_mutex(frames.mutex); + mutex_lock(frames.mutex); AVFrame *frame = frames.rendering_frame; frames.rendering_frame_consumed = SDL_TRUE; if (!decoder.skip_frames) { @@ -364,7 +364,7 @@ SDL_bool show_screen(const char *serial, Uint16 local_port) { frame_size = current_frame_size; update_texture(frame, texture); - unlock_mutex(frames.mutex); + mutex_unlock(frames.mutex); texture_empty = SDL_FALSE;