mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-19 12:45:54 +00:00
[132/906] make the plugin properly shutdown when one of the check requirements failed
This commit is contained in:
parent
9b45dcae3e
commit
d0e63e68ac
3 changed files with 153 additions and 81 deletions
|
@ -163,7 +163,7 @@ gst_gl_display_init (GstGLDisplay *display, GstGLDisplayClass *klass)
|
||||||
display->upload_width = 0;
|
display->upload_width = 0;
|
||||||
display->upload_height = 0;
|
display->upload_height = 0;
|
||||||
display->upload_video_format = 0;
|
display->upload_video_format = 0;
|
||||||
display->colorspace_conversion = GST_GL_DISPLAY_CONVERSION_GLSL;
|
display->colorspace_conversion = GST_GL_DISPLAY_CONVERSION_MESA;
|
||||||
display->upload_data_with = 0;
|
display->upload_data_with = 0;
|
||||||
display->upload_data_height = 0;
|
display->upload_data_height = 0;
|
||||||
display->upload_data = NULL;
|
display->upload_data = NULL;
|
||||||
|
@ -674,6 +674,7 @@ gst_gl_display_thread_create_context (GstGLDisplay *display)
|
||||||
|
|
||||||
g_print ("GL_VERSION: %s\n", glGetString (GL_VERSION));
|
g_print ("GL_VERSION: %s\n", glGetString (GL_VERSION));
|
||||||
g_print ("GLEW_VERSION: %s\n", glewGetString (GLEW_VERSION));
|
g_print ("GLEW_VERSION: %s\n", glewGetString (GLEW_VERSION));
|
||||||
|
if (glGetString (GL_SHADING_LANGUAGE_VERSION))
|
||||||
g_print ("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString (GL_SHADING_LANGUAGE_VERSION));
|
g_print ("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString (GL_SHADING_LANGUAGE_VERSION));
|
||||||
|
|
||||||
g_print ("GL_VENDOR: %s\n", glGetString (GL_VENDOR));
|
g_print ("GL_VENDOR: %s\n", glGetString (GL_VENDOR));
|
||||||
|
@ -687,7 +688,7 @@ gst_gl_display_thread_create_context (GstGLDisplay *display)
|
||||||
(GLEW_VERSION_MAJOR < 2 && GLEW_VERSION_MAJOR >= 1 && GLEW_VERSION_MINOR < 4) )
|
(GLEW_VERSION_MAJOR < 2 && GLEW_VERSION_MAJOR >= 1 && GLEW_VERSION_MINOR < 4) )
|
||||||
{
|
{
|
||||||
//turn off the pipeline, the old drivers are not yet supported
|
//turn off the pipeline, the old drivers are not yet supported
|
||||||
g_print ("Required OpenGL >= 1.4.0 and Glew >= 1.4.0\n");
|
g_warning ("Required OpenGL >= 1.4.0 and Glew >= 1.4.0\n");
|
||||||
display->isAlive = FALSE;
|
display->isAlive = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -773,14 +774,41 @@ gst_gl_display_thread_destroy_context (GstGLDisplay *display)
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (display->upload_fbo)
|
||||||
|
{
|
||||||
glDeleteFramebuffersEXT (1, &display->upload_fbo);
|
glDeleteFramebuffersEXT (1, &display->upload_fbo);
|
||||||
|
display->upload_fbo = 0;
|
||||||
|
}
|
||||||
|
if (display->upload_depth_buffer)
|
||||||
|
{
|
||||||
glDeleteRenderbuffersEXT(1, &display->upload_depth_buffer);
|
glDeleteRenderbuffersEXT(1, &display->upload_depth_buffer);
|
||||||
|
display->upload_depth_buffer = 0;
|
||||||
|
}
|
||||||
|
if (display->download_fbo)
|
||||||
|
{
|
||||||
glDeleteFramebuffersEXT (1, &display->download_fbo);
|
glDeleteFramebuffersEXT (1, &display->download_fbo);
|
||||||
|
display->download_fbo = 0;
|
||||||
|
}
|
||||||
|
if (display->download_depth_buffer)
|
||||||
|
{
|
||||||
glDeleteRenderbuffersEXT(1, &display->download_depth_buffer);
|
glDeleteRenderbuffersEXT(1, &display->download_depth_buffer);
|
||||||
|
display->download_depth_buffer = 0;
|
||||||
|
}
|
||||||
|
if (display->download_texture)
|
||||||
|
{
|
||||||
glDeleteTextures (1, &display->download_texture);
|
glDeleteTextures (1, &display->download_texture);
|
||||||
|
display->download_texture = 0;
|
||||||
|
}
|
||||||
|
if (display->download_texture_u)
|
||||||
|
{
|
||||||
glDeleteTextures (1, &display->download_texture_u);
|
glDeleteTextures (1, &display->download_texture_u);
|
||||||
|
display->download_texture_u = 0;
|
||||||
|
}
|
||||||
|
if (display->download_texture_v)
|
||||||
|
{
|
||||||
glDeleteTextures (1, &display->download_texture_v);
|
glDeleteTextures (1, &display->download_texture_v);
|
||||||
|
display->download_texture_v = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//clean up the texture pool
|
//clean up the texture pool
|
||||||
while (g_queue_get_length (display->texturePool))
|
while (g_queue_get_length (display->texturePool))
|
||||||
|
@ -1435,10 +1463,16 @@ gst_gl_display_thread_del_fbo (GstGLDisplay* display)
|
||||||
{
|
{
|
||||||
glutSetWindow (display->glutWinId);
|
glutSetWindow (display->glutWinId);
|
||||||
|
|
||||||
|
if (display->del_fbo)
|
||||||
|
{
|
||||||
glDeleteFramebuffersEXT (1, &display->del_fbo);
|
glDeleteFramebuffersEXT (1, &display->del_fbo);
|
||||||
glDeleteRenderbuffersEXT(1, &display->del_depth_buffer);
|
|
||||||
display->del_fbo = 0;
|
display->del_fbo = 0;
|
||||||
|
}
|
||||||
|
if (display->del_depth_buffer)
|
||||||
|
{
|
||||||
|
glDeleteRenderbuffersEXT(1, &display->del_depth_buffer);
|
||||||
display->del_depth_buffer = 0;
|
display->del_depth_buffer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
g_cond_signal (display->cond_del_fbo);
|
g_cond_signal (display->cond_del_fbo);
|
||||||
}
|
}
|
||||||
|
@ -1658,6 +1692,8 @@ void gst_gl_display_on_close (void)
|
||||||
* Called in the gl thread */
|
* Called in the gl thread */
|
||||||
void
|
void
|
||||||
gst_gl_display_glgen_texture (GstGLDisplay* display, GLuint* pTexture)
|
gst_gl_display_glgen_texture (GstGLDisplay* display, GLuint* pTexture)
|
||||||
|
{
|
||||||
|
if (display->isAlive)
|
||||||
{
|
{
|
||||||
//check if there is a texture available in the pool
|
//check if there is a texture available in the pool
|
||||||
GstGLDisplayTex* tex = g_queue_pop_head (display->texturePool);
|
GstGLDisplayTex* tex = g_queue_pop_head (display->texturePool);
|
||||||
|
@ -1672,6 +1708,9 @@ gst_gl_display_glgen_texture (GstGLDisplay* display, GLuint* pTexture)
|
||||||
else
|
else
|
||||||
glGenTextures (1, pTexture);
|
glGenTextures (1, pTexture);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
*pTexture = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Delete a texture, actually the texture is just added to the pool
|
/* Delete a texture, actually the texture is just added to the pool
|
||||||
|
@ -1803,6 +1842,8 @@ gst_gl_display_redisplay (GstGLDisplay* display, GLuint texture, gint width , gi
|
||||||
|
|
||||||
gst_gl_display_lock (display);
|
gst_gl_display_lock (display);
|
||||||
isAlive = display->isAlive;
|
isAlive = display->isAlive;
|
||||||
|
if (isAlive)
|
||||||
|
{
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
display->redisplay_texture = texture;
|
display->redisplay_texture = texture;
|
||||||
|
@ -1810,6 +1851,7 @@ gst_gl_display_redisplay (GstGLDisplay* display, GLuint texture, gint width , gi
|
||||||
display->redisplay_texture_height = height;
|
display->redisplay_texture_height = height;
|
||||||
}
|
}
|
||||||
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_REDISPLAY_CONTEXT, display);
|
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_REDISPLAY_CONTEXT, display);
|
||||||
|
}
|
||||||
gst_gl_display_unlock (display);
|
gst_gl_display_unlock (display);
|
||||||
|
|
||||||
return isAlive;
|
return isAlive;
|
||||||
|
@ -1856,19 +1898,27 @@ gst_gl_display_init_upload (GstGLDisplay* display, GstVideoFormat video_format,
|
||||||
|
|
||||||
|
|
||||||
/* Called by the first gl element of a video/x-raw-gl flow */
|
/* Called by the first gl element of a video/x-raw-gl flow */
|
||||||
void
|
gboolean
|
||||||
gst_gl_display_do_upload (GstGLDisplay* display, GLuint texture,
|
gst_gl_display_do_upload (GstGLDisplay* display, GLuint texture,
|
||||||
gint data_width, gint data_height,
|
gint data_width, gint data_height,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
gboolean isAlive = TRUE;
|
||||||
|
|
||||||
gst_gl_display_lock (display);
|
gst_gl_display_lock (display);
|
||||||
|
isAlive = display->isAlive;
|
||||||
|
if (isAlive)
|
||||||
|
{
|
||||||
display->upload_texture = texture;
|
display->upload_texture = texture;
|
||||||
display->upload_data_with = data_width;
|
display->upload_data_with = data_width;
|
||||||
display->upload_data_height = data_height;
|
display->upload_data_height = data_height;
|
||||||
display->upload_data = data;
|
display->upload_data = data;
|
||||||
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_DO_UPLOAD, display);
|
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_DO_UPLOAD, display);
|
||||||
g_cond_wait (display->cond_do_upload, display->mutex);
|
g_cond_wait (display->cond_do_upload, display->mutex);
|
||||||
|
}
|
||||||
gst_gl_display_unlock (display);
|
gst_gl_display_unlock (display);
|
||||||
|
|
||||||
|
return isAlive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1888,12 +1938,17 @@ gst_gl_display_init_download (GstGLDisplay* display, GstVideoFormat video_format
|
||||||
|
|
||||||
|
|
||||||
/* Called by the gldownload and glcolorscale element */
|
/* Called by the gldownload and glcolorscale element */
|
||||||
void
|
gboolean
|
||||||
gst_gl_display_do_download (GstGLDisplay* display, GLuint texture,
|
gst_gl_display_do_download (GstGLDisplay* display, GLuint texture,
|
||||||
gint width, gint height,
|
gint width, gint height,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
gboolean isAlive = TRUE;
|
||||||
|
|
||||||
gst_gl_display_lock (display);
|
gst_gl_display_lock (display);
|
||||||
|
isAlive = display->isAlive;
|
||||||
|
if (isAlive)
|
||||||
|
{
|
||||||
//data size is aocciated to the glcontext size
|
//data size is aocciated to the glcontext size
|
||||||
display->download_data = data;
|
display->download_data = data;
|
||||||
display->ouput_texture = texture;
|
display->ouput_texture = texture;
|
||||||
|
@ -1901,7 +1956,10 @@ gst_gl_display_do_download (GstGLDisplay* display, GLuint texture,
|
||||||
display->ouput_texture_height = height;
|
display->ouput_texture_height = height;
|
||||||
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_DO_DOWNLOAD, display);
|
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_DO_DOWNLOAD, display);
|
||||||
g_cond_wait (display->cond_do_download, display->mutex);
|
g_cond_wait (display->cond_do_download, display->mutex);
|
||||||
|
}
|
||||||
gst_gl_display_unlock (display);
|
gst_gl_display_unlock (display);
|
||||||
|
|
||||||
|
return isAlive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1911,18 +1969,21 @@ gst_gl_display_gen_fbo (GstGLDisplay* display, gint width, gint height,
|
||||||
GLuint* fbo, GLuint* depthbuffer)
|
GLuint* fbo, GLuint* depthbuffer)
|
||||||
{
|
{
|
||||||
gst_gl_display_lock (display);
|
gst_gl_display_lock (display);
|
||||||
|
if (display->isAlive)
|
||||||
|
{
|
||||||
display->gen_fbo_width = width;
|
display->gen_fbo_width = width;
|
||||||
display->gen_fbo_height = height;
|
display->gen_fbo_height = height;
|
||||||
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_GEN_FBO, display);
|
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_GEN_FBO, display);
|
||||||
g_cond_wait (display->cond_gen_fbo, display->mutex);
|
g_cond_wait (display->cond_gen_fbo, display->mutex);
|
||||||
*fbo = display->generated_fbo;
|
*fbo = display->generated_fbo;
|
||||||
*depthbuffer = display->generated_depth_buffer;
|
*depthbuffer = display->generated_depth_buffer;
|
||||||
|
}
|
||||||
gst_gl_display_unlock (display);
|
gst_gl_display_unlock (display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Called by glfilter */
|
/* Called by glfilter */
|
||||||
void
|
gboolean
|
||||||
gst_gl_display_use_fbo (GstGLDisplay* display, gint texture_fbo_width, gint texture_fbo_height,
|
gst_gl_display_use_fbo (GstGLDisplay* display, gint texture_fbo_width, gint texture_fbo_height,
|
||||||
GLuint fbo, GLuint depth_buffer, GLuint texture_fbo, GLCB cb,
|
GLuint fbo, GLuint depth_buffer, GLuint texture_fbo, GLCB cb,
|
||||||
gint input_texture_width, gint input_texture_height, GLuint input_texture,
|
gint input_texture_width, gint input_texture_height, GLuint input_texture,
|
||||||
|
@ -1930,7 +1991,12 @@ gst_gl_display_use_fbo (GstGLDisplay* display, gint texture_fbo_width, gint text
|
||||||
gdouble proj_param3, gdouble proj_param4,
|
gdouble proj_param3, gdouble proj_param4,
|
||||||
GstGLDisplayProjection projection, gpointer* stuff)
|
GstGLDisplayProjection projection, gpointer* stuff)
|
||||||
{
|
{
|
||||||
|
gboolean isAlive = TRUE;
|
||||||
|
|
||||||
gst_gl_display_lock (display);
|
gst_gl_display_lock (display);
|
||||||
|
isAlive = display->isAlive;
|
||||||
|
if (isAlive)
|
||||||
|
{
|
||||||
display->use_fbo = fbo;
|
display->use_fbo = fbo;
|
||||||
display->use_depth_buffer = depth_buffer;
|
display->use_depth_buffer = depth_buffer;
|
||||||
display->use_fbo_texture = texture_fbo;
|
display->use_fbo_texture = texture_fbo;
|
||||||
|
@ -1948,7 +2014,10 @@ gst_gl_display_use_fbo (GstGLDisplay* display, gint texture_fbo_width, gint text
|
||||||
display->input_texture = input_texture;
|
display->input_texture = input_texture;
|
||||||
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_USE_FBO, display);
|
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_USE_FBO, display);
|
||||||
g_cond_wait (display->cond_use_fbo, display->mutex);
|
g_cond_wait (display->cond_use_fbo, display->mutex);
|
||||||
|
}
|
||||||
gst_gl_display_unlock (display);
|
gst_gl_display_unlock (display);
|
||||||
|
|
||||||
|
return isAlive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -260,18 +260,18 @@ void gst_gl_display_del_texture (GstGLDisplay* display, GLuint texture);
|
||||||
|
|
||||||
void gst_gl_display_init_upload (GstGLDisplay* display, GstVideoFormat video_format,
|
void gst_gl_display_init_upload (GstGLDisplay* display, GstVideoFormat video_format,
|
||||||
guint gl_width, guint gl_height);
|
guint gl_width, guint gl_height);
|
||||||
void gst_gl_display_do_upload (GstGLDisplay* display, GLuint texture,
|
gboolean gst_gl_display_do_upload (GstGLDisplay* display, GLuint texture,
|
||||||
gint data_width, gint data_height,
|
gint data_width, gint data_height,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
void gst_gl_display_init_download (GstGLDisplay* display, GstVideoFormat video_format,
|
void gst_gl_display_init_download (GstGLDisplay* display, GstVideoFormat video_format,
|
||||||
gint width, gint height);
|
gint width, gint height);
|
||||||
void gst_gl_display_do_download (GstGLDisplay* display, GLuint texture,
|
gboolean gst_gl_display_do_download (GstGLDisplay* display, GLuint texture,
|
||||||
gint width, gint height,
|
gint width, gint height,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
void gst_gl_display_gen_fbo (GstGLDisplay* display, gint width, gint height,
|
void gst_gl_display_gen_fbo (GstGLDisplay* display, gint width, gint height,
|
||||||
GLuint* fbo, GLuint* depthbuffer);
|
GLuint* fbo, GLuint* depthbuffer);
|
||||||
void gst_gl_display_use_fbo (GstGLDisplay* display, gint texture_fbo_width, gint texture_fbo_height,
|
gboolean gst_gl_display_use_fbo (GstGLDisplay* display, gint texture_fbo_width, gint texture_fbo_height,
|
||||||
GLuint fbo, GLuint depth_buffer, GLuint texture_fbo, GLCB cb,
|
GLuint fbo, GLuint depth_buffer, GLuint texture_fbo, GLCB cb,
|
||||||
gint input_texture_width, gint input_texture_height, GLuint input_texture,
|
gint input_texture_width, gint input_texture_height, GLuint input_texture,
|
||||||
gdouble proj_param1, gdouble proj_param2,
|
gdouble proj_param1, gdouble proj_param2,
|
||||||
|
|
|
@ -260,7 +260,10 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans,
|
||||||
*buf = GST_BUFFER (gl_outbuf);
|
*buf = GST_BUFFER (gl_outbuf);
|
||||||
gst_buffer_set_caps (*buf, caps);
|
gst_buffer_set_caps (*buf, caps);
|
||||||
|
|
||||||
|
if (gl_outbuf->texture)
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
else
|
||||||
|
return GST_FLOW_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue