mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 23:58:17 +00:00
[664/906] filtershader: improve error checking
This commit is contained in:
parent
d07fb25841
commit
e55b2ae671
1 changed files with 44 additions and 33 deletions
|
@ -75,8 +75,10 @@ static void gst_gl_filtershader_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
GValue * value, GParamSpec * pspec);
|
||||||
static void gst_gl_filter_filtershader_reset (GstGLFilter * filter);
|
static void gst_gl_filter_filtershader_reset (GstGLFilter * filter);
|
||||||
|
|
||||||
static void gst_gl_filtershader_load_shader (char *filename, char **storage);
|
static gboolean gst_gl_filtershader_load_shader (GstGLFilterShader *
|
||||||
static void gst_gl_filtershader_load_variables (char *filename, char **storage);
|
filter_shader, char *filename, char **storage);
|
||||||
|
static gboolean gst_gl_filtershader_load_variables (GstGLFilterShader *
|
||||||
|
filter_shader, char *filename, char **storage);
|
||||||
static gboolean gst_gl_filtershader_init_shader (GstGLFilter * filter);
|
static gboolean gst_gl_filtershader_init_shader (GstGLFilter * filter);
|
||||||
static gboolean gst_gl_filtershader_filter_texture (GstGLFilter * filter,
|
static gboolean gst_gl_filtershader_filter_texture (GstGLFilter * filter,
|
||||||
guint in_tex, guint out_tex);
|
guint in_tex, guint out_tex);
|
||||||
|
@ -248,38 +250,38 @@ gst_gl_filtershader_get_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static gboolean
|
||||||
gst_gl_filtershader_load_file (const gchar * filename, gchar ** storage)
|
gst_gl_filtershader_load_shader (GstGLFilterShader * filter_shader,
|
||||||
|
char *filename, char **storage)
|
||||||
{
|
{
|
||||||
GError *err = NULL;
|
GError *error = NULL;
|
||||||
gchar *old_storage = *storage;
|
gsize length;
|
||||||
|
|
||||||
GST_INFO ("loading file: %s", filename);
|
g_return_val_if_fail (storage != NULL, FALSE);
|
||||||
if (!g_file_get_contents (filename, storage, NULL, &err)) {
|
|
||||||
GST_ERROR ("could not open file '%s':", filename, err->message);
|
if (!filename) {
|
||||||
g_error_free (err);
|
GST_ELEMENT_ERROR (filter_shader, RESOURCE, NOT_FOUND,
|
||||||
return -1;
|
("A shader file is required"), (NULL));
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (old_storage);
|
if (!g_file_get_contents (filename, storage, &length, &error)) {
|
||||||
GST_INFO ("read: %d bytes", (int) strlen (*storage));
|
GST_ELEMENT_ERROR (filter_shader, RESOURCE, NOT_FOUND, (error->message),
|
||||||
return 0;
|
(NULL));
|
||||||
}
|
g_error_free (error);
|
||||||
|
|
||||||
static void
|
return FALSE;
|
||||||
gst_gl_filtershader_load_shader (char *filename, char **storage)
|
|
||||||
{
|
|
||||||
g_return_if_fail (filename != NULL);
|
|
||||||
g_return_if_fail (storage != NULL);
|
|
||||||
|
|
||||||
if (gst_gl_filtershader_load_file (filename, storage)) {
|
|
||||||
exit (1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
gst_gl_filtershader_load_variables (char *filename, char **storage)
|
gst_gl_filtershader_load_variables (GstGLFilterShader * filter_shader,
|
||||||
|
char *filename, char **storage)
|
||||||
{
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
gsize length;
|
||||||
|
|
||||||
if (storage[0]) {
|
if (storage[0]) {
|
||||||
g_free (storage[0]);
|
g_free (storage[0]);
|
||||||
|
@ -287,11 +289,17 @@ gst_gl_filtershader_load_variables (char *filename, char **storage)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return;
|
return TRUE;
|
||||||
|
|
||||||
if (gst_gl_filtershader_load_file (filename, storage)) {
|
if (!g_file_get_contents (filename, storage, &length, &error)) {
|
||||||
exit (1);
|
GST_ELEMENT_ERROR (filter_shader, RESOURCE, NOT_FOUND, (error->message),
|
||||||
|
(NULL));
|
||||||
|
g_error_free (error);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -306,18 +314,21 @@ gst_gl_filtershader_init_shader (GstGLFilter * filter)
|
||||||
|
|
||||||
GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter);
|
GstGLFilterShader *filtershader = GST_GL_FILTERSHADER (filter);
|
||||||
|
|
||||||
gst_gl_filtershader_load_shader (filtershader->filename,
|
if (!gst_gl_filtershader_load_shader (filtershader, filtershader->filename,
|
||||||
&hfilter_fragment_source);
|
&hfilter_fragment_source))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
//blocking call, wait the opengl thread has compiled the shader
|
//blocking call, wait the opengl thread has compiled the shader
|
||||||
if (!gst_gl_display_gen_shader (filter->display, 0, hfilter_fragment_source,
|
if (!gst_gl_display_gen_shader (filter->display, 0, hfilter_fragment_source,
|
||||||
&filtershader->shader0))
|
&filtershader->shader0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
filtershader->compiled = 1;
|
|
||||||
|
|
||||||
gst_gl_filtershader_load_variables (filtershader->presetfile,
|
if (!gst_gl_filtershader_load_variables (filtershader,
|
||||||
&hfilter_fragment_variables[0]);
|
filtershader->presetfile, &hfilter_fragment_variables[0]))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
filtershader->compiled = 1;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue