From 0e752d586362b95288f1a94f7c2588016719d838 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 28 Feb 2012 03:17:25 +0200 Subject: vo: reject vo_redraw_frame() if no frames have been drawn vo_xv crashed if existing frames had been lost due to a config() call in the middle of a file and vo_redraw_frame() was called. Add checks to reject vo_redraw_frame() unless at least one frame has been flipped after the the last configuration change, so individual VOs do not have to deal with this case. --- libvo/video_out.c | 4 +++- libvo/video_out.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libvo/video_out.c b/libvo/video_out.c index 48cfb2a609..9573439882 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -285,7 +285,7 @@ int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts) int vo_redraw_frame(struct vo *vo) { - if (!vo->config_ok) + if (!vo->config_ok || !vo->hasframe) return -1; if (vo_control(vo, VOCTRL_REDRAW_FRAME, NULL) == true) { vo->redrawing = true; @@ -358,6 +358,7 @@ void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration) vo->driver->flip_page_timed(vo, pts_us, duration); else vo->driver->flip_page(vo); + vo->hasframe = true; } void vo_check_events(struct vo *vo) @@ -500,6 +501,7 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height, vo->frame_loaded = false; vo->waiting_mpi = NULL; vo->redrawing = false; + vo->hasframe = false; return ret; } diff --git a/libvo/video_out.h b/libvo/video_out.h index 06c606f4d2..554b97d207 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -265,6 +265,7 @@ struct vo { double next_pts2; // optional pts of frame after that bool want_redraw; // visible frame wrong (window resize), needs refresh bool redrawing; // between redrawing frame and flipping it + bool hasframe; // >= 1 frame has been drawn, so redraw is possible double flip_queue_offset; // queue flip events at most this much in advance -- cgit v1.2.3