mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-22 04:40:30 +00:00
GL: fixed crash if exiting with paused frame
The control flow was a bit incorrect - pause should be handled prior to current_frame update. Anyways, the whole stuff is still a bit ugly (namely the pop_frame stuff + locking). Delaying frame pop was a kind of optimization - not sure if it is worth it.
This commit is contained in:
@@ -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<mutex> &lk)
|
||||
{
|
||||
unique_lock<mutex> 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<mutex> 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<mutex> lk(s->lock);
|
||||
pop_frame(s, lk);
|
||||
}
|
||||
|
||||
/* FPS Data, this is pretty ghetto though.... */
|
||||
s->frames++;
|
||||
|
||||
Reference in New Issue
Block a user