[vlc-commits] libvlc: let the OpenGL host app change the opaque data used for the session

Steve Lhomme git at videolan.org
Mon Feb 10 09:07:02 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Feb  4 14:53:21 2020 +0100| [aab1165b99bb08bdd02342b39b98a734697b9466] | committer: Steve Lhomme

libvlc: let the OpenGL host app change the opaque data used for the session

The host may only allocate the opaque structure and the related resources when
a session happens.

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

 doc/libvlc/QtGL/qtvlcwidget.cpp   |  8 ++++----
 doc/libvlc/sdl_opengl_player.cpp  |  8 ++++----
 include/vlc/libvlc_media_player.h | 24 ++++++++++++++----------
 modules/video_output/vgl.c        |  2 +-
 4 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/doc/libvlc/QtGL/qtvlcwidget.cpp b/doc/libvlc/QtGL/qtvlcwidget.cpp
index 22483efc7c..3c85075f6b 100644
--- a/doc/libvlc/QtGL/qtvlcwidget.cpp
+++ b/doc/libvlc/QtGL/qtvlcwidget.cpp
@@ -64,14 +64,14 @@ public:
     }
 
     // This callback is called during initialisation.
-    static bool setup(void* data)
+    static bool setup(void** data)
     {
         if (!QOpenGLContext::supportsThreadedOpenGL())
             return false;
 
-        VLCVideo* that = static_cast<VLCVideo*>(data);
-        that->m_width = 0;
-        that->m_height = 0;
+        VLCVideo** that = static_cast<VLCVideo**>(data);
+        (*that)->m_width = 0;
+        (*that)->m_height = 0;
         return true;
     }
 
diff --git a/doc/libvlc/sdl_opengl_player.cpp b/doc/libvlc/sdl_opengl_player.cpp
index 6e067ccba0..acf7053a50 100644
--- a/doc/libvlc/sdl_opengl_player.cpp
+++ b/doc/libvlc/sdl_opengl_player.cpp
@@ -160,11 +160,11 @@ public:
     }
 
     // This callback is called during initialisation.
-    static bool setup(void* data)
+    static bool setup(void** data)
     {
-        VLCVideo* that = static_cast<VLCVideo*>(data);
-        that->m_width = 0;
-        that->m_height = 0;
+        VLCVideo** that = static_cast<VLCVideo**>(data);
+        (*that)->m_width = 0;
+        (*that)->m_height = 0;
         return true;
     }
 
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 1f89340a81..10a4ed75f0 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -506,17 +506,19 @@ void libvlc_video_set_format_callbacks( libvlc_media_player_t *mp,
 /**
  * Callback prototype called to initialize user data.
  *
- * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() [IN]
+ * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks()
+ *               on input. The callback can change this value on output to be
+ *               passed to all the other callbacks set on @a libvlc_video_set_output_callbacks(). [IN/OUT]
  * \return true on success
  * \version LibVLC 4.0.0 or later
  */
-typedef bool (*libvlc_video_setup_cb)(void* opaque);
+typedef bool (*libvlc_video_setup_cb)(void** opaque);
 
 
 /**
  * Callback prototype called to release user data
  *
- * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb() [IN]
  * \version LibVLC 4.0.0 or later
  */
 typedef void (*libvlc_video_output_cleanup_cb)(void* opaque);
@@ -549,8 +551,8 @@ typedef struct
  * Callback prototype called on video size changes.
  * Update the rendering output setup.
  *
- * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() or
- *         @a libvlc_video_direct3d_device_setup_cb() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb()
+ *        or @a libvlc_video_direct3d_device_setup_cb() [IN]
  * \param cfg configuration of the video that will be rendered [IN]
  * \param output configuration describing with how the rendering is setup [OUT]
  * \version LibVLC 4.0.0 or later
@@ -570,7 +572,8 @@ typedef bool (*libvlc_video_update_output_cb)(void* opaque, const libvlc_video_r
 /**
  * Callback prototype called after performing drawing calls.
  *
- * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb()
+ *        or @a libvlc_video_direct3d_device_setup_cb() [IN]
  * \version LibVLC 4.0.0 or later
  */
 typedef void (*libvlc_video_swap_cb)(void* opaque);
@@ -579,8 +582,8 @@ typedef void (*libvlc_video_swap_cb)(void* opaque);
  * Callback prototype to set up the OpenGL context for rendering.
  * Tell the host the rendering is about to start/has finished.
  *
- * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() or
- *          @a libvlc_video_direct3d_device_setup_cb() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb()
+ *        or @a libvlc_video_direct3d_device_setup_cb() [IN]
  * \param enter true to set the context as current, false to unset it [IN]
  * \return true on success
  * \version LibVLC 4.0.0 or later
@@ -605,7 +608,7 @@ typedef bool (*libvlc_video_makeCurrent_cb)(void* opaque, bool enter);
 /**
  * Callback prototype to load opengl functions
  *
- * \param opaque private pointer passed to the @a libvlc_video_set_output_callbacks() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb() [IN]
  * \param fct_name name of the opengl function to load
  * \return a pointer to the named OpenGL function the NULL otherwise
  * \version LibVLC 4.0.0 or later
@@ -754,7 +757,8 @@ typedef void( *libvlc_video_direct3d_set_resize_cb )( void *opaque,
 
 /** Tell the host the rendering for the given plane is about to start
  *
- * \param opaque private pointer set on the opaque parameter of @a libvlc_video_direct3d_device_setup_cb() [IN]
+ * \param opaque private pointer set on the opaque parameter of @a libvlc_video_setup_cb()
+ *        or @a libvlc_video_direct3d_device_setup_cb() [IN]
  * \param plane number of the rendering plane to select
  * \return true on success
  * \version LibVLC 4.0.0 or later
diff --git a/modules/video_output/vgl.c b/modules/video_output/vgl.c
index 2f17ac3e79..75dc75a79d 100644
--- a/modules/video_output/vgl.c
+++ b/modules/video_output/vgl.c
@@ -141,7 +141,7 @@ static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
     gl->destroy = Close;
 
     if( sys->setupCb )
-        if( !sys->setupCb(sys->opaque) )
+        if( !sys->setupCb(&sys->opaque) )
         {
             msg_Err( gl, "user setup failed" );
             return VLC_EGENERIC;



More information about the vlc-commits mailing list