[vlc-commits] vsxu: use vlc_gl_surface_* helpers

Rémi Denis-Courmont git at videolan.org
Thu Oct 16 19:26:10 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Oct 13 19:26:16 2014 +0300| [462500e5dad38c3dab8f371e7f74d9ec2fc63845] | committer: Rémi Denis-Courmont

vsxu: use vlc_gl_surface_* helpers

This is untested because vsxu is neither in contribs nor in my distro.

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

 modules/visualization/vsxu.cpp |  124 +++++++---------------------------------
 1 file changed, 20 insertions(+), 104 deletions(-)

diff --git a/modules/visualization/vsxu.cpp b/modules/visualization/vsxu.cpp
index 0d0117b..aca7715 100644
--- a/modules/visualization/vsxu.cpp
+++ b/modules/visualization/vsxu.cpp
@@ -35,8 +35,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_aout.h>
-#include <vlc_vout.h>
-#include <vlc_vout_wrapper.h>
+#include <vlc_vout_window.h>
 #include <vlc_opengl.h>
 
 // vsxu manager include
@@ -80,8 +79,7 @@ vlc_module_end ()
 struct filter_sys_t
 {
     vlc_thread_t thread;
-
-    vlc_sem_t    ready;
+    vlc_gl_t *gl;
 
     vlc_mutex_t lock;
 
@@ -91,11 +89,8 @@ struct filter_sys_t
     // cyclic buffer to cache sound frames in
     cyclic_block_queue* vsxu_cyclic_buffer;
 
-    int i_width;
-    int i_height;
     int i_channels;
 
-    bool b_error;
     bool b_quit;
 };
 
@@ -119,26 +114,28 @@ static int Open( vlc_object_t * p_this )
     }
 
     /* Create the object for the thread */
-    vlc_sem_init( &p_sys->ready, 0 );
-    p_sys->b_error       = false;
     p_sys->b_quit        = false;
-    p_sys->i_width       = var_InheritInteger( p_filter, "vsxu-width" );
-    p_sys->i_height      = var_InheritInteger( p_filter, "vsxu-height" );
     p_sys->i_channels    = aout_FormatNbChannels( &p_filter->fmt_in.audio );
     vlc_mutex_init( &p_sys->lock );
     vlc_mutex_init( &p_sys->cyclic_block_mutex );
     p_sys->vsxu_cyclic_buffer = new cyclic_block_queue();
 
+    /* Create the openGL provider */
+    vout_window_cfg_t cfg;
 
-    /* Create the thread */
-    if( vlc_clone( &p_sys->thread, Thread, p_filter, VLC_THREAD_PRIORITY_LOW ) )
-        goto error;
+    memset( &cfg, 0, sizeof(cfg) );
+    cfg.width = var_InheritInteger( p_filter, "vsxu-width" );
+    cfg.height = var_InheritInteger( p_filter, "vsxu-height" );
 
+    p_sys->gl = vlc_gl_surface_Create( VLC_OBJECT(p_filter), &cfg, NULL );
+    if( p_sys->gl == NULL )
+        goto error;
 
-    vlc_sem_wait( &p_sys->ready );
-    if( p_sys->b_error )
+    /* Create the thread */
+    if( vlc_clone( &p_sys->thread, Thread, p_filter,
+                   VLC_THREAD_PRIORITY_LOW ) )
     {
-        vlc_join( p_sys->thread, NULL );
+        vlc_gl_surface_Destroy( p_sys->gl );
         goto error;
     }
 
@@ -151,7 +148,6 @@ static int Open( vlc_object_t * p_this )
 error:
     vlc_mutex_destroy( &p_sys->cyclic_block_mutex );
     vlc_mutex_destroy( &p_sys->lock );
-    vlc_sem_destroy( &p_sys->ready );
     free( p_sys );
     return VLC_EGENERIC;
 }
@@ -172,7 +168,7 @@ static void Close( vlc_object_t *p_this )
     vlc_join( p_sys->thread, NULL );
 
     /* Free the ressources */
-    vlc_sem_destroy( &p_sys->ready );
+    vlc_gl_surface_Destroy( p_sys->gl );
     vlc_mutex_destroy( &p_sys->cyclic_block_mutex );
     vlc_mutex_destroy( &p_sys->lock );
     delete p_sys->vsxu_cyclic_buffer;
@@ -232,22 +228,6 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
 }
 
 /**
- * Variable callback for the dummy vout
- */
-static int VoutCallback( vlc_object_t *p_vout, char const *psz_name,
-                         vlc_value_t oldv, vlc_value_t newv, void *p_data )
-{
-    VLC_UNUSED( p_vout ); VLC_UNUSED( oldv );
-    vout_display_t *p_vd = (vout_display_t*)p_data;
-
-    if( !strcmp(psz_name, "fullscreen") )
-    {
-        vout_SetDisplayFullscreen( p_vd, newv.b_bool );
-    }
-    return VLC_SUCCESS;
-}
-
-/**
  * VSXu update thread which do the rendering
  * @param p_this: the p_thread object
  */
@@ -255,6 +235,7 @@ static void *Thread( void *p_data )
 {
     filter_t  *p_filter = (filter_t*)p_data;
     filter_sys_t *p_sys = p_filter->p_sys;
+    vlc_gl_t *gl = p_sys->gl;
 
     // our abstract manager holder
     vsx_manager_abs* manager = 0;
@@ -265,74 +246,20 @@ static void *Thread( void *p_data )
     // vsxu logo intro
     vsx_logo_intro* intro = 0;
 
-    vout_display_t *p_vd;
-
-    video_format_t fmt;
-    vlc_gl_t *gl;
-
-    unsigned int i_last_width  = 0;
-    unsigned int i_last_height = 0;
     bool first = true;
     bool run = true;
 
-    /* Create the openGL provider */
-    vout_thread_t  *p_vout;
-
-    p_vout = (vout_thread_t *)vlc_object_create( p_filter, sizeof(vout_thread_t) );
-    if( !p_vout )
-        goto error;
-
-    video_format_Init( &fmt, 0 );
-    video_format_Setup( &fmt, VLC_CODEC_RGB32, p_sys->i_width, p_sys->i_height,
-                        p_sys->i_width, p_sys->i_height, 0, 1 );
-    fmt.i_sar_num = 1;
-    fmt.i_sar_den = 1;
-
-    vout_display_state_t state;
-    memset( &state, 0, sizeof(state) );
-    state.cfg.display.sar.num = 1;
-    state.cfg.display.sar.den = 1;
-    state.cfg.is_display_filled = true;
-    state.cfg.zoom.num = 1;
-    state.cfg.zoom.den = 1;
-    state.sar.num = 1;
-    state.sar.den = 1;
-
-    p_vd = vout_NewDisplay( p_vout, &fmt, &state, "opengl", 300000, 1000000 );
-    if( !p_vd )
-    {
-        vlc_object_release( p_vout );
-        goto error;
-    }
-    var_Create( p_vout, "fullscreen", VLC_VAR_BOOL );
-    var_AddCallback( p_vout, "fullscreen", VoutCallback, p_vd );
-
-    gl = vout_GetDisplayOpengl( p_vd );
-    if( !gl )
-    {
-        var_DelCallback( p_vout, "fullscreen", VoutCallback, p_vd );
-        vout_DeleteDisplay( p_vd, NULL );
-        vlc_object_release( p_vout );
-        goto error;
-    }
-
     // tell main thread we are ready
-    vlc_sem_post( &p_sys->ready );
     vlc_gl_MakeCurrent( gl );
 
     while ( run )
     {
         /* Manage the events */
-        vout_ManageDisplay( p_vd, true );
-        if( p_vd->cfg->display.width  != i_last_width ||
-            p_vd->cfg->display.height != i_last_height )
-        {
-            /* FIXME it is not perfect as we will have black bands */
-            vout_display_place_t place;
-            vout_display_PlacePicture( &place, &p_vd->source, p_vd->cfg, false );
+        unsigned width, height;
 
-            i_last_width  = p_vd->cfg->display.width;
-            i_last_height = p_vd->cfg->display.height;
+        if( vlc_gl_surface_CheckSize( p_sys->gl, &width, &height ) )
+        {
+            /* ??? */
         }
 
         // look for control commands from outside the thread
@@ -398,12 +325,6 @@ static void *Thread( void *p_data )
 
     vlc_gl_ReleaseCurrent( gl );
 
-    var_DelCallback( p_vout, "fullscreen", VoutCallback, p_vd );
-
-    // clean out vlc opengl stuff
-    vout_DeleteDisplay( p_vd, NULL );
-    vlc_object_release( p_vout );
-
     // clean up the cyclic buffer
     vlc_mutex_lock( &p_sys->cyclic_block_mutex );
         p_sys->vsxu_cyclic_buffer->reset();
@@ -411,10 +332,5 @@ static void *Thread( void *p_data )
 
     // die
     return NULL;
-
-error:
-    p_sys->b_error = true;
-    vlc_sem_post( &p_sys->ready );
-    return NULL;
 }
 



More information about the vlc-commits mailing list