gstreamer-gl/{egl,x11}: Change functions from returning Option to Result

Partial work for:
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/216
This commit is contained in:
Tony Jinwoo Ahn 2019-11-24 20:55:54 +00:00 committed by Sebastian Dröge
parent a7090b2a03
commit e4adef3ba7
2 changed files with 18 additions and 6 deletions

View file

@ -14,10 +14,16 @@ use GLDisplayEGL;
use GLDisplayType;
impl GLDisplayEGL {
pub unsafe fn new_with_egl_display(display: uintptr_t) -> Option<GLDisplayEGL> {
from_glib_full(gst_gl_sys::gst_gl_display_egl_new_with_egl_display(
pub unsafe fn new_with_egl_display(
display: uintptr_t,
) -> Result<GLDisplayEGL, glib::error::BoolError> {
let result = from_glib_full(gst_gl_sys::gst_gl_display_egl_new_with_egl_display(
display as gpointer,
))
));
match result {
Some(d) => Ok(d),
None => Err(glib_bool_error!("Failed to create new EGL GL display")),
}
}
pub unsafe fn get_from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {

View file

@ -13,9 +13,15 @@ use libc::uintptr_t;
use GLDisplayX11;
impl GLDisplayX11 {
pub unsafe fn new_with_display(display: uintptr_t) -> Option<GLDisplayX11> {
from_glib_full(gst_gl_sys::gst_gl_display_x11_new_with_display(
pub unsafe fn new_with_display(
display: uintptr_t,
) -> Result<GLDisplayX11, glib::error::BoolError> {
let result = from_glib_full(gst_gl_sys::gst_gl_display_x11_new_with_display(
display as gpointer,
))
));
match result {
Some(d) => Ok(d),
None => Err(glib_bool_error!("Failed to create new X11 GL display")),
}
}
}