[132/906] make the plugin properly shutdown when one of the check requirements failed

This commit is contained in:
Julien Isorce 2008-07-20 16:38:48 +02:00 committed by Tim-Philipp Müller
parent 9b45dcae3e
commit d0e63e68ac
3 changed files with 153 additions and 81 deletions

View file

@ -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,7 +674,8 @@ 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));
g_print ("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString (GL_SHADING_LANGUAGE_VERSION)); if (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));
g_print ("GL_RENDERER: %s\n", glGetString (GL_RENDERER)); g_print ("GL_RENDERER: %s\n", glGetString (GL_RENDERER));
@ -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 ();
} }
glDeleteFramebuffersEXT (1, &display->upload_fbo); if (display->upload_fbo)
glDeleteRenderbuffersEXT(1, &display->upload_depth_buffer); {
glDeleteFramebuffersEXT (1, &display->upload_fbo);
glDeleteFramebuffersEXT (1, &display->download_fbo); display->upload_fbo = 0;
glDeleteRenderbuffersEXT(1, &display->download_depth_buffer); }
glDeleteTextures (1, &display->download_texture); if (display->upload_depth_buffer)
glDeleteTextures (1, &display->download_texture_u); {
glDeleteTextures (1, &display->download_texture_v); glDeleteRenderbuffersEXT(1, &display->upload_depth_buffer);
display->upload_depth_buffer = 0;
}
if (display->download_fbo)
{
glDeleteFramebuffersEXT (1, &display->download_fbo);
display->download_fbo = 0;
}
if (display->download_depth_buffer)
{
glDeleteRenderbuffersEXT(1, &display->download_depth_buffer);
display->download_depth_buffer = 0;
}
if (display->download_texture)
{
glDeleteTextures (1, &display->download_texture);
display->download_texture = 0;
}
if (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);
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);
glDeleteFramebuffersEXT (1, &display->del_fbo); if (display->del_fbo)
glDeleteRenderbuffersEXT(1, &display->del_depth_buffer); {
display->del_fbo = 0; glDeleteFramebuffersEXT (1, &display->del_fbo);
display->del_depth_buffer = 0; display->del_fbo = 0;
}
if (display->del_depth_buffer)
{
glDeleteRenderbuffersEXT(1, &display->del_depth_buffer);
display->del_depth_buffer = 0;
}
g_cond_signal (display->cond_del_fbo); g_cond_signal (display->cond_del_fbo);
} }
@ -1659,18 +1693,23 @@ void gst_gl_display_on_close (void)
void void
gst_gl_display_glgen_texture (GstGLDisplay* display, GLuint* pTexture) gst_gl_display_glgen_texture (GstGLDisplay* display, GLuint* pTexture)
{ {
//check if there is a texture available in the pool if (display->isAlive)
GstGLDisplayTex* tex = g_queue_pop_head (display->texturePool);
if (tex)
{ {
*pTexture = tex->texture; //check if there is a texture available in the pool
g_free (tex); GstGLDisplayTex* tex = g_queue_pop_head (display->texturePool);
if (tex)
{
*pTexture = tex->texture;
g_free (tex);
}
//otherwise one more texture is generated
//note that this new texture is added in the pool
//only after being used
else
glGenTextures (1, pTexture);
} }
//otherwise one more texture is generated
//note that this new texture is added in the pool
//only after being used
else else
glGenTextures (1, pTexture); *pTexture = 0;
} }
@ -1803,13 +1842,16 @@ 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 (texture) if (isAlive)
{ {
display->redisplay_texture = texture; if (texture)
display->redisplay_texture_width = width; {
display->redisplay_texture_height = height; display->redisplay_texture = texture;
display->redisplay_texture_width = width;
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);
display->upload_texture = texture; isAlive = display->isAlive;
display->upload_data_with = data_width; if (isAlive)
display->upload_data_height = data_height; {
display->upload_data = data; display->upload_texture = texture;
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_DO_UPLOAD, display); display->upload_data_with = data_width;
g_cond_wait (display->cond_do_upload, display->mutex); display->upload_data_height = data_height;
display->upload_data = data;
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_DO_UPLOAD, display);
g_cond_wait (display->cond_do_upload, display->mutex);
}
gst_gl_display_unlock (display); gst_gl_display_unlock (display);
return isAlive;
} }
@ -1888,20 +1938,28 @@ 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);
//data size is aocciated to the glcontext size isAlive = display->isAlive;
display->download_data = data; if (isAlive)
display->ouput_texture = texture; {
display->ouput_texture_width = width; //data size is aocciated to the glcontext size
display->ouput_texture_height = height; display->download_data = data;
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_DO_DOWNLOAD, display); display->ouput_texture = texture;
g_cond_wait (display->cond_do_download, display->mutex); display->ouput_texture_width = width;
display->ouput_texture_height = height;
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_DO_DOWNLOAD, display);
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);
display->gen_fbo_width = width; if (display->isAlive)
display->gen_fbo_height = height; {
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_GEN_FBO, display); display->gen_fbo_width = width;
g_cond_wait (display->cond_gen_fbo, display->mutex); display->gen_fbo_height = height;
*fbo = display->generated_fbo; gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_GEN_FBO, display);
*depthbuffer = display->generated_depth_buffer; g_cond_wait (display->cond_gen_fbo, display->mutex);
*fbo = display->generated_fbo;
*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,25 +1991,33 @@ 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);
display->use_fbo = fbo; isAlive = display->isAlive;
display->use_depth_buffer = depth_buffer; if (isAlive)
display->use_fbo_texture = texture_fbo; {
display->use_fbo_width = texture_fbo_width; display->use_fbo = fbo;
display->use_fbo_height = texture_fbo_height; display->use_depth_buffer = depth_buffer;
display->use_fbo_scene_cb = cb; display->use_fbo_texture = texture_fbo;
display->use_fbo_proj_param1 = proj_param1; display->use_fbo_width = texture_fbo_width;
display->use_fbo_proj_param2 = proj_param2; display->use_fbo_height = texture_fbo_height;
display->use_fbo_proj_param3 = proj_param3; display->use_fbo_scene_cb = cb;
display->use_fbo_proj_param4 = proj_param4; display->use_fbo_proj_param1 = proj_param1;
display->use_fbo_projection = projection; display->use_fbo_proj_param2 = proj_param2;
display->use_fbo_stuff = stuff; display->use_fbo_proj_param3 = proj_param3;
display->input_texture_width = input_texture_width; display->use_fbo_proj_param4 = proj_param4;
display->input_texture_height = input_texture_height; display->use_fbo_projection = projection;
display->input_texture = input_texture; display->use_fbo_stuff = stuff;
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_USE_FBO, display); display->input_texture_width = input_texture_width;
g_cond_wait (display->cond_use_fbo, display->mutex); display->input_texture_height = input_texture_height;
display->input_texture = input_texture;
gst_gl_display_post_message (GST_GL_DISPLAY_ACTION_USE_FBO, display);
g_cond_wait (display->cond_use_fbo, display->mutex);
}
gst_gl_display_unlock (display); gst_gl_display_unlock (display);
return isAlive;
} }

View file

@ -260,23 +260,23 @@ 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,
gdouble proj_param3, gdouble proj_param4, gdouble proj_param3, gdouble proj_param4,
GstGLDisplayProjection projection, gpointer* stuff); GstGLDisplayProjection projection, gpointer* stuff);
void gst_gl_display_del_fbo (GstGLDisplay* display, GLuint fbo, void gst_gl_display_del_fbo (GstGLDisplay* display, GLuint fbo,
GLuint depth_buffer); GLuint depth_buffer);

View file

@ -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);
return GST_FLOW_OK; if (gl_outbuf->texture)
return GST_FLOW_OK;
else
return GST_FLOW_UNEXPECTED;
} }
static gboolean static gboolean