diff --git a/src/video_display/gl.cpp b/src/video_display/gl.cpp index 3d8cdf8bd..3db1ef845 100644 --- a/src/video_display/gl.cpp +++ b/src/video_display/gl.cpp @@ -1032,9 +1032,9 @@ static void gl_render(struct state_gl *s, char *data) gl_check_error(); } -static void pop_frame(struct state_gl *s) +/// @note lk will be unlocked! +static void pop_frame(struct state_gl *s, unique_lock &lk) { - unique_lock lk(s->lock); s->frame_queue.pop(); lk.unlock(); s->frame_consumed_cv.notify_one(); @@ -1089,7 +1089,16 @@ static void gl_process_frames(struct state_gl *s) return; } frame = s->frame_queue.front(); - + if (!frame) { + pop_frame(s, lk); + return; + } + if (s->paused) { + vf_recycle(frame); + s->free_frame_queue.push(frame); + pop_frame(s, lk); + return; + } if (s->current_frame) { vf_recycle(s->current_frame); s->free_frame_queue.push(s->current_frame); @@ -1097,19 +1106,6 @@ static void gl_process_frames(struct state_gl *s) s->current_frame = frame; } - if (!frame) { - pop_frame(s); - return; - } - - if (s->paused) { - pop_frame(s); - unique_lock lk(s->lock); - vf_recycle(frame); - s->free_frame_queue.push(frame); - return; - } - if (!video_desc_eq(video_desc_from_frame(frame), s->current_display_desc)) { gl_reconfigure_screen(s, video_desc_from_frame(frame)); } @@ -1133,7 +1129,10 @@ static void gl_process_frames(struct state_gl *s) glfwSwapBuffers(s->window); } log_msg(LOG_LEVEL_DEBUG, "Render buffer %dx%d\n", frame->tiles[0].width, frame->tiles[0].height); - pop_frame(s); + { + unique_lock lk(s->lock); + pop_frame(s, lk); + } /* FPS Data, this is pretty ghetto though.... */ s->frames++;