Skip to content

Commit

Permalink
gl/context: fill a GError on platform-specific fill_info() error
Browse files Browse the repository at this point in the history
  • Loading branch information
ystreet authored and GStreamer Marge Bot committed Jun 21, 2021
1 parent 973f0bf commit aa8b27d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
16 changes: 14 additions & 2 deletions gst-libs/gst/gl/egl/gstglcontext_egl.c
Expand Up @@ -1415,7 +1415,7 @@ gst_gl_context_egl_request_config (GstGLContext * context,
}

gboolean
gst_gl_context_egl_fill_info (GstGLContext * context)
gst_gl_context_egl_fill_info (GstGLContext * context, GError ** error)
{
EGLContext egl_context = (EGLContext) gst_gl_context_get_gl_context (context);
GstGLDisplay *display_egl;
Expand All @@ -1426,7 +1426,8 @@ gst_gl_context_egl_fill_info (GstGLContext * context)
int attrs[3];

if (!egl_context) {
GST_ERROR_OBJECT (context, "no GLX context");
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE, "no EGL context");
return FALSE;
}

Expand All @@ -1439,6 +1440,10 @@ gst_gl_context_egl_fill_info (GstGLContext * context)
GST_WARNING_OBJECT (context,
"could not retrieve egl config id from egl context: %s",
gst_egl_get_error_string (eglGetError ()));
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
"could not retrieve egl config id from egl context: %s",
gst_egl_get_error_string (eglGetError ()));
goto failure;
}

Expand All @@ -1451,13 +1456,20 @@ gst_gl_context_egl_fill_info (GstGLContext * context)
GST_WARNING_OBJECT (context,
"could not retrieve egl config from its ID 0x%x. "
"Wrong EGLDisplay or context?", config_id);
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
"could not retrieve egl config from its ID 0x%x. "
"Wrong EGLDisplay or context?", config_id);
goto failure;
}

config = egl_config_to_structure (egl_display, egl_config);
if (!config) {
GST_WARNING_OBJECT (context, "could not transform config id 0x%x into "
"GstStructure", config_id);
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
"could not transform config id 0x%x into GstStructure", config_id);
goto failure;
}

Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/egl/gstglcontext_egl.h
Expand Up @@ -92,7 +92,7 @@ G_GNUC_INTERNAL
gpointer gst_gl_context_egl_get_proc_address (GstGLAPI gl_api, const gchar * name);

G_GNUC_INTERNAL
gboolean gst_gl_context_egl_fill_info (GstGLContext * context);
gboolean gst_gl_context_egl_fill_info (GstGLContext * context, GError ** error);

G_END_DECLS

Expand Down
4 changes: 2 additions & 2 deletions gst-libs/gst/gl/gstglcontext.c
Expand Up @@ -1546,12 +1546,12 @@ gst_gl_context_fill_info (GstGLContext * context, GError ** error)
/* XXX: vfunc? */
#if GST_GL_HAVE_PLATFORM_GLX
if (gst_gl_context_get_gl_platform (context) == GST_GL_PLATFORM_GLX
&& !gst_gl_context_glx_fill_info (context))
&& !gst_gl_context_glx_fill_info (context, error))
goto failure;
#endif
#if GST_GL_HAVE_PLATFORM_EGL
if (gst_gl_context_get_gl_platform (context) == GST_GL_PLATFORM_EGL
&& !gst_gl_context_egl_fill_info (context))
&& !gst_gl_context_egl_fill_info (context, error))
goto failure;
#endif
}
Expand Down
18 changes: 16 additions & 2 deletions gst-libs/gst/gl/x11/gstglcontext_glx.c
Expand Up @@ -969,7 +969,7 @@ gst_gl_context_glx_request_config (GstGLContext * context,
}

gboolean
gst_gl_context_glx_fill_info (GstGLContext * context)
gst_gl_context_glx_fill_info (GstGLContext * context, GError ** error)
{
GLXContext glx_context = (GLXContext) gst_gl_context_get_gl_context (context);
GstStructure *config;
Expand All @@ -980,14 +980,18 @@ gst_gl_context_glx_fill_info (GstGLContext * context)
int attrs[3];

if (!glx_context) {
GST_ERROR_OBJECT (context, "no GLX context");
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE, "No GLX context");
return FALSE;
}

device = (Display *) gst_gl_display_get_handle (context->display);

if (!glXQueryVersion (device, &glx_major, &glx_minor)) {
GST_WARNING_OBJECT (context, "could not retrieve GLX version");
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE,
"could not retrieve GLX version");
return FALSE;
}

Expand All @@ -1001,6 +1005,9 @@ gst_gl_context_glx_fill_info (GstGLContext * context)
&fbconfig_id)) {
GST_WARNING_OBJECT (context,
"could not retrieve fbconfig id from glx context");
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
"could not retrieve fbconfig id from glx context");
goto failure;
}

Expand All @@ -1014,13 +1021,20 @@ gst_gl_context_glx_fill_info (GstGLContext * context)
GST_WARNING_OBJECT (context,
"could not retrieve fbconfig from its ID 0x%x. "
"Wrong Display or Screen?", fbconfig_id);
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
"could not retrieve fbconfig from its ID 0x%x. "
"Wrong Display or Screen?", fbconfig_id);
goto failure;
}

config = fb_config_to_structure (context, device, fbconfigs[0]);
if (!config) {
GST_WARNING_OBJECT (context, "could not transform fbconfig id 0x%x into "
"GstStructure.", fbconfig_id);
g_set_error (error, GST_GL_CONTEXT_ERROR,
GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
"could not transform fbconfig id 0x%x into GstStructure.", fbconfig_id);
goto failure;
}

Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/x11/gstglcontext_glx.h
Expand Up @@ -69,7 +69,7 @@ G_GNUC_INTERNAL
gpointer gst_gl_context_glx_get_proc_address (GstGLAPI gl_api, const gchar * name);

G_GNUC_INTERNAL
gboolean gst_gl_context_glx_fill_info (GstGLContext * context);
gboolean gst_gl_context_glx_fill_info (GstGLContext * context, GError ** error);

G_END_DECLS

Expand Down

0 comments on commit aa8b27d

Please sign in to comment.