[vlc-commits] libvlc: add a bool return value to the resize callback

Steve Lhomme git at videolan.org
Wed Jan 16 11:06:51 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Nov 15 12:59:35 2018 +0100| [97c5df3ad94c011f5ef8f60f331459fcf5a176f2] | committer: Steve Lhomme

libvlc: add a bool return value to the resize callback

For some reason it may be impossible to the host to provide a context with the
given size.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=97c5df3ad94c011f5ef8f60f331459fcf5a176f2
---

 doc/libvlc/sdl_opengl_player.cpp  |  5 +++--
 include/vlc/libvlc_media_player.h |  3 ++-
 modules/video_output/vgl.c        | 11 +++++++----
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/doc/libvlc/sdl_opengl_player.cpp b/doc/libvlc/sdl_opengl_player.cpp
index 6858e1fba1..eefe078ac1 100644
--- a/doc/libvlc/sdl_opengl_player.cpp
+++ b/doc/libvlc/sdl_opengl_player.cpp
@@ -116,7 +116,7 @@ public:
     }
 
     /// this callback will create the surfaces and FBO used by VLC to perform its rendering
-    static void resize(void* data, unsigned width, unsigned height)
+    static bool resize(void* data, unsigned width, unsigned height)
     {
         VLCVideo* that = static_cast<VLCVideo*>(data);
         if (width != that->m_width || height != that->m_height)
@@ -141,13 +141,14 @@ public:
         GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
 
         if (status != GL_FRAMEBUFFER_COMPLETE) {
-            return;
+            return false;
         }
 
         that->m_width = width;
         that->m_height = height;
 
         glBindFramebuffer(GL_FRAMEBUFFER, that->m_fbo[that->m_idx_render]);
+        return true;
     }
 
     // This callback is called during initialisation.
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 73dadda3ba..987fd40c9d 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -446,9 +446,10 @@ typedef void (*libvlc_gl_cleanup_cb)(void* opaque);
  * \param opaque private pointer passed to the @a libvlc_video_set_opengl_callbacks() [IN]
  * \param width video width in pixel [IN]
  * \param height video height in pixel [IN]
+ * \return true on success
  * \version LibVLC 4.0.0 or later
  */
-typedef void (*libvlc_gl_resize_cb)(void* opaque, unsigned width, unsigned height);
+typedef bool (*libvlc_gl_resize_cb)(void* opaque, unsigned width, unsigned height);
 
 
 /**
diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
index 6a69a3751e..e08ffa2916 100644
--- a/modules/video_output/vgl.c
+++ b/modules/video_output/vgl.c
@@ -33,7 +33,7 @@ struct vout_display_sys_t
 {
     void (*cleanupCb)(void* opaque);
     bool (*setupCb)(void* opaque);
-    void (*resizeCb)(void* opaque, unsigned, unsigned);
+    bool (*resizeCb)(void* opaque, unsigned, unsigned);
     void (*swapCb)(void* opaque);
     bool (*makeCurrentCb)(void* opaque, bool);
     void* (*getProcAddressCb)(void* opaque, const char *name);
@@ -79,10 +79,13 @@ static void Resize(vlc_gl_t * gl, unsigned w, unsigned h)
         return;
 
     MakeCurrent(gl);
-    sys->resizeCb(sys->opaque, w, h);
+    bool success = sys->resizeCb(sys->opaque, w, h);
     ReleaseCurrent(gl);
-    sys->width = w;
-    sys->height = h;
+    if (success)
+    {
+        sys->width = w;
+        sys->height = h;
+    }
 }
 
 static void Close(vlc_object_t *object)



More information about the vlc-commits mailing list