aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/out/gl_video.c
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2015-03-23 16:32:59 +0100
committerGravatar wm4 <wm4@nowhere>2015-03-23 16:32:59 +0100
commit167b75c50c673bc477d0b18b38cd1d20292ce8b8 (patch)
tree0c3143fa9cb40e25170cff23754a2a7dce1c8920 /video/out/gl_video.c
parent67bdad9a43ba965b73e5914da2e46db8866dc14e (diff)
vo_opengl_cb: don't render OSD while VO is not created
Unlike other VOs, this rendered OSD even while no VO was created (because the renderer lives as long as the API user wants). Change this, and refactor the code so that the OSD object is accessible only while the VO is created. (There is a short time where the OSD can still be accessed even after VO destruction - this is not a race condition, though it's inelegant and unfortunately unavoidable.)
Diffstat (limited to 'video/out/gl_video.c')
-rw-r--r--video/out/gl_video.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 098e6bf737..65e8262e64 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -506,10 +506,12 @@ static inline int fbosurface_wrap(int id)
static void recreate_osd(struct gl_video *p)
{
- if (p->osd)
- mpgl_osd_destroy(p->osd);
- p->osd = mpgl_osd_init(p->gl, p->log, p->osd_state);
- mpgl_osd_set_options(p->osd, p->opts.pbo);
+ mpgl_osd_destroy(p->osd);
+ p->osd = NULL;
+ if (p->osd_state) {
+ p->osd = mpgl_osd_init(p->gl, p->log, p->osd_state);
+ mpgl_osd_set_options(p->osd, p->opts.pbo);
+ }
}
static void reinit_rendering(struct gl_video *p)
@@ -1916,7 +1918,8 @@ void gl_video_render_frame(struct gl_video *p, int fbo, struct frame_timing *t)
gl->BindFramebuffer(GL_FRAMEBUFFER, fbo);
- draw_osd(p);
+ if (p->osd)
+ draw_osd(p);
gl->UseProgram(0);
gl->BindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -2389,7 +2392,15 @@ void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b)
p->depth_g = g;
}
-struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct osd_state *osd)
+void gl_video_set_osd_source(struct gl_video *p, struct osd_state *osd)
+{
+ mpgl_osd_destroy(p->osd);
+ p->osd = NULL;
+ p->osd_state = osd;
+ recreate_osd(p);
+}
+
+struct gl_video *gl_video_init(GL *gl, struct mp_log *log)
{
if (gl->version < 210 && gl->es < 200) {
mp_err(log, "At least OpenGL 2.1 or OpenGL ES 2.0 required.\n");
@@ -2400,7 +2411,6 @@ struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct osd_state *osd
*p = (struct gl_video) {
.gl = gl,
.log = log,
- .osd_state = osd,
.opts = gl_video_opts_def,
.gl_target = GL_TEXTURE_2D,
.texture_16bit_depth = 16,