Handle condition variable failure

Add condition variables function wrappers to handle unexpected failure.
hidpi
Romain Vimont 7 years ago
parent c4266e487b
commit b9c9466d65

@ -24,7 +24,7 @@ static void push_frame(struct decoder *decoder) {
mutex_lock(frames->mutex);
if (!decoder->skip_frames) {
while (!frames->rendering_frame_consumed) {
SDL_CondWait(frames->rendering_frame_consumed_cond, frames->mutex);
cond_wait(frames->rendering_frame_consumed_cond, frames->mutex);
}
} else if (!frames->rendering_frame_consumed) {
SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "Skip frame");

@ -19,4 +19,18 @@ static inline void mutex_unlock(SDL_mutex *mutex) {
}
}
static inline void cond_wait(SDL_cond *cond, SDL_mutex *mutex) {
if (SDL_CondWait(cond, mutex)) {
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not wait on condition");
exit(1);
}
}
static inline void cond_signal(SDL_cond *cond) {
if (SDL_CondSignal(cond)) {
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not signal a condition");
exit(1);
}
}
#endif

@ -353,7 +353,7 @@ SDL_bool show_screen(const char *serial, Uint16 local_port) {
AVFrame *frame = frames.rendering_frame;
frames.rendering_frame_consumed = SDL_TRUE;
if (!decoder.skip_frames) {
SDL_CondSignal(frames.rendering_frame_consumed_cond);
cond_signal(frames.rendering_frame_consumed_cond);
}
struct size current_frame_size = {frame->width, frame->height};

Loading…
Cancel
Save