Commit 40a45dc8 authored by Gildas Bazin's avatar Gildas Bazin

* modules/video_output/x11/glx.c: OpenGL context is initialized in pf_init()...

* modules/video_output/x11/glx.c: OpenGL context is initialized in pf_init() because of threading issues.
parent 32b211e4
...@@ -122,6 +122,7 @@ static int CreateVout( vlc_object_t *p_this ) ...@@ -122,6 +122,7 @@ static int CreateVout( vlc_object_t *p_this )
msg_Err( p_vout, "out of memory" ); msg_Err( p_vout, "out of memory" );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
vlc_object_attach( p_sys->p_vout, p_this );
p_sys->p_vout->i_window_width = p_vout->i_window_width; p_sys->p_vout->i_window_width = p_vout->i_window_width;
p_sys->p_vout->i_window_height = p_vout->i_window_height; p_sys->p_vout->i_window_height = p_vout->i_window_height;
...@@ -136,10 +137,10 @@ static int CreateVout( vlc_object_t *p_this ) ...@@ -136,10 +137,10 @@ static int CreateVout( vlc_object_t *p_this )
if( p_sys->p_vout->p_module == NULL ) if( p_sys->p_vout->p_module == NULL )
{ {
msg_Err( p_vout, "No OpenGL provider found" ); msg_Err( p_vout, "No OpenGL provider found" );
vlc_object_detach( p_sys->p_vout );
vlc_object_destroy( p_sys->p_vout ); vlc_object_destroy( p_sys->p_vout );
return VLC_ENOOBJ; return VLC_ENOOBJ;
} }
vlc_object_attach( p_sys->p_vout, p_this );
p_vout->pf_init = Init; p_vout->pf_init = Init;
p_vout->pf_end = End; p_vout->pf_end = End;
...@@ -158,6 +159,8 @@ static int Init( vout_thread_t *p_vout ) ...@@ -158,6 +159,8 @@ static int Init( vout_thread_t *p_vout )
vout_sys_t *p_sys = p_vout->p_sys; vout_sys_t *p_sys = p_vout->p_sys;
int i_pixel_pitch; int i_pixel_pitch;
p_sys->p_vout->pf_init( p_sys->p_vout );
/* No YUV textures :( */ /* No YUV textures :( */
#if VLCGL_RGB_FORMAT == GL_RGB #if VLCGL_RGB_FORMAT == GL_RGB
......
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
*****************************************************************************/ *****************************************************************************/
static int CreateOpenGL ( vlc_object_t * ); static int CreateOpenGL ( vlc_object_t * );
static void DestroyOpenGL( vlc_object_t * ); static void DestroyOpenGL( vlc_object_t * );
static int InitOpenGL ( vout_thread_t * );
static void SwapBuffers ( vout_thread_t * ); static void SwapBuffers ( vout_thread_t * );
/***************************************************************************** /*****************************************************************************
...@@ -115,28 +116,10 @@ static int CreateOpenGL( vlc_object_t *p_this ) ...@@ -115,28 +116,10 @@ static int CreateOpenGL( vlc_object_t *p_this )
} }
/* Set the function pointer */ /* Set the function pointer */
p_vout->pf_init = InitOpenGL;
p_vout->pf_swap = SwapBuffers; p_vout->pf_swap = SwapBuffers;
p_vout->p_sys->b_glx13 = b_glx13; p_vout->p_sys->b_glx13 = b_glx13;
/* Initialize GLX */
if( !b_glx13 )
{
if( InitGLX12( p_vout ) != VLC_SUCCESS )
{
return VLC_EGENERIC;
}
}
else
{
if( InitGLX13( p_vout ) != VLC_SUCCESS )
{
return VLC_EGENERIC;
}
}
/* Set the OpenGL context _for the current thread_ */
SwitchContext( p_vout );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -211,6 +194,33 @@ static int CheckGLX( vlc_object_t *p_this, vlc_bool_t *b_glx13 ) ...@@ -211,6 +194,33 @@ static int CheckGLX( vlc_object_t *p_this, vlc_bool_t *b_glx13 )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/*****************************************************************************
* InitOpenGL: initializes OpenGL provider
*****************************************************************************/
static int InitOpenGL( vout_thread_t *p_vout )
{
/* Initialize GLX */
if( !p_vout->p_sys->b_glx13 )
{
if( InitGLX12( p_vout ) != VLC_SUCCESS )
{
return VLC_EGENERIC;
}
}
else
{
if( InitGLX13( p_vout ) != VLC_SUCCESS )
{
return VLC_EGENERIC;
}
}
/* Set the OpenGL context _for the current thread_ */
SwitchContext( p_vout );
return VLC_SUCCESS;
}
int InitGLX12( vout_thread_t *p_vout ) int InitGLX12( vout_thread_t *p_vout )
{ {
vout_sys_t *p_sys = p_vout->p_sys; vout_sys_t *p_sys = p_vout->p_sys;
......
...@@ -206,6 +206,7 @@ static void Thread( vlc_object_t *p_this ) ...@@ -206,6 +206,7 @@ static void Thread( vlc_object_t *p_this )
msg_Err( p_thread, "out of memory" ); msg_Err( p_thread, "out of memory" );
return; return;
} }
vlc_object_attach( p_thread->p_opengl, p_this );
p_thread->p_opengl->i_window_width = p_thread->i_width; p_thread->p_opengl->i_window_width = p_thread->i_width;
p_thread->p_opengl->i_window_height = p_thread->i_height; p_thread->p_opengl->i_window_height = p_thread->i_height;
...@@ -218,11 +219,12 @@ static void Thread( vlc_object_t *p_this ) ...@@ -218,11 +219,12 @@ static void Thread( vlc_object_t *p_this )
if( p_thread->p_module == NULL ) if( p_thread->p_module == NULL )
{ {
msg_Err( p_thread, "No OpenGL provider found" ); msg_Err( p_thread, "No OpenGL provider found" );
vlc_object_detach( p_thread->p_opengl );
vlc_object_destroy( p_thread->p_opengl ); vlc_object_destroy( p_thread->p_opengl );
return; return;
} }
vlc_object_attach( p_thread->p_opengl, p_this ); p_thread->p_opengl->pf_init( p_thread->p_opengl );
setup_opengl( p_thread->i_width, p_thread->i_height ); setup_opengl( p_thread->i_width, p_thread->i_height );
CreateRenderTarget(512, &RenderTargetTextureID, NULL); CreateRenderTarget(512, &RenderTargetTextureID, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment