From 4ed3d60bd28484d65b0d3502701cd657e93d1484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 13 Sep 2012 01:07:46 +0100 Subject: [PATCH] waylandsink: fail gracefully with an error message if we can't connect to wayland g_return_val_if_fail() is not for error handling, it's for catching programming errors in public API. Fixes problem with generic/states unit test. --- ext/wayland/gstwaylandsink.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index a7053a18e3..32b695d7fb 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -307,7 +307,11 @@ create_display (void) display = malloc (sizeof *display); display->display = wl_display_connect (NULL); - g_return_val_if_fail (display->display, NULL); + + if (display->display == NULL) { + free (display); + return NULL; + } wl_display_add_global_listener (display->display, display_handle_global, display); @@ -451,6 +455,13 @@ gst_wayland_sink_start (GstBaseSink * bsink) if (!sink->display) sink->display = create_display (); + if (sink->display == NULL) { + GST_ELEMENT_ERROR (bsink, RESOURCE, OPEN_READ_WRITE, + ("Could not initialise Wayland output"), + ("Could not create Wayland display")); + return FALSE; + } + return result; }