From 1061f43a2ffb389004fb97b969c05140061557ee Mon Sep 17 00:00:00 2001
From: wm4 <wm4@nowhere>
Date: Thu, 12 Sep 2013 01:33:33 +0200
Subject: [PATCH] gl_osd: mp_msg conversion

---
 video/out/gl_osd.c        | 12 ++++++------
 video/out/gl_osd.h        |  3 ++-
 video/out/gl_video.c      |  2 +-
 video/out/vo_corevideo.c  |  2 +-
 video/out/vo_opengl_old.c |  2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/video/out/gl_osd.c b/video/out/gl_osd.c
index 3317062311..547a8b6789 100644
--- a/video/out/gl_osd.c
+++ b/video/out/gl_osd.c
@@ -45,13 +45,14 @@ static const struct osd_fmt_entry osd_to_gl_legacy_formats[SUBBITMAP_COUNT] = {
     [SUBBITMAP_RGBA] =   {GL_RGBA,  GL_BGRA,  GL_UNSIGNED_BYTE},
 };
 
-struct mpgl_osd *mpgl_osd_init(GL *gl, bool legacy)
+struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, bool legacy)
 {
     GLint max_texture_size;
     gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
 
     struct mpgl_osd *ctx = talloc_ptrtype(NULL, ctx);
     *ctx = (struct mpgl_osd) {
+        .log = log,
         .gl = gl,
         .fmt_table = legacy ? osd_to_gl_legacy_formats : osd_to_gl3_formats,
         .scratch = talloc_zero_size(ctx, 1),
@@ -121,8 +122,8 @@ static bool upload_pbo(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
     gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
 
     if (!success) {
-        mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Error: can't upload subtitles! "
-                                    "Remove the 'pbo' suboption.\n");
+        MP_FATAL(ctx, "Error: can't upload subtitles! "
+                 "Remove the 'pbo' suboption.\n");
     }
 
     return success;
@@ -157,9 +158,8 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd,
     osd->packer->padding = ctx->scaled || imgs->scaled;
     int r = packer_pack_from_subbitmaps(osd->packer, imgs);
     if (r < 0) {
-        mp_msg(MSGT_VO, MSGL_ERR, "[gl] OSD bitmaps do not fit on "
-               "a surface with the maximum supported size %dx%d.\n",
-               osd->packer->w_max, osd->packer->h_max);
+        MP_ERR(ctx, "OSD bitmaps do not fit on a surface with the maximum "
+               "supported size %dx%d.\n", osd->packer->w_max, osd->packer->h_max);
         return false;
     }
 
diff --git a/video/out/gl_osd.h b/video/out/gl_osd.h
index 91c7a6f552..29b4584a4a 100644
--- a/video/out/gl_osd.h
+++ b/video/out/gl_osd.h
@@ -20,6 +20,7 @@ struct mpgl_osd_part {
 };
 
 struct mpgl_osd {
+    struct mp_log *log;
     GL *gl;
     bool use_pbo;
     bool scaled;
@@ -29,7 +30,7 @@ struct mpgl_osd {
     void *scratch;
 };
 
-struct mpgl_osd *mpgl_osd_init(GL *gl, bool legacy);
+struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, bool legacy);
 void mpgl_osd_destroy(struct mpgl_osd *ctx);
 
 void mpgl_osd_set_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p);
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 363c6a634e..ff5bbc7d47 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -1083,7 +1083,7 @@ static void recreate_osd(struct gl_video *p)
 {
     if (p->osd)
         mpgl_osd_destroy(p->osd);
-    p->osd = mpgl_osd_init(p->gl, false);
+    p->osd = mpgl_osd_init(p->gl, p->log, false);
     p->osd->use_pbo = p->opts.pbo;
 }
 
diff --git a/video/out/vo_corevideo.c b/video/out/vo_corevideo.c
index 2adee98b02..25b02d6627 100644
--- a/video/out/vo_corevideo.c
+++ b/video/out/vo_corevideo.c
@@ -130,7 +130,7 @@ static int init_gl(struct vo *vo, uint32_t d_width, uint32_t d_height)
     gl->TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
     if (!p->osd)
-        p->osd = mpgl_osd_init(gl, true);
+        p->osd = mpgl_osd_init(gl, vo->log, true);
 
     resize(vo);
 
diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c
index 008dc2d2a6..f3e6b96536 100644
--- a/video/out/vo_opengl_old.c
+++ b/video/out/vo_opengl_old.c
@@ -1693,7 +1693,7 @@ static int initGl(struct vo *vo, uint32_t d_width, uint32_t d_height)
     }
 
     if (gl->BindTexture) {
-        p->osd = mpgl_osd_init(gl, true);
+        p->osd = mpgl_osd_init(gl, vo->log, true);
         p->osd->scaled = p->scaled_osd;
     }