waylandsink/wldisplay: verify that all the required interfaces have been found on...
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>
Mon, 16 Jun 2014 16:53:53 +0000 (18:53 +0200)
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>
Tue, 17 Jun 2014 11:51:30 +0000 (13:51 +0200)
This allows waylandsink to fail gracefully before going to READY
in case one of the required interfaces does not exist. Not all
interfaces are necessary for all modes of operation, but it is
better imho to fail before going to READY if at least one feature
is not supported, than to fail and/or crash at some later point.

In the future we may want to relax this restriction and allow certain
interfaces not to be present under certain circumstances, for example
if there is an alternative similar interface available (for instance,
xdg_shell instead of wl_shell), but for now let's require them all.
Weston supports them all, which is enough for us now. Other compositors
should really implement them if they don't already. I don't like the
idea of supporting many different compositors with different sets of
interfaces implemented. wl_subcompositor, wl_shm and wl_scaler are
really essential for having a nice video sink. Enough said.

ext/wayland/wldisplay.c

index 0e2e91e..46efab9 100644 (file)
@@ -237,6 +237,24 @@ gst_wl_display_new_existing (struct wl_display * display,
     }
   }
 
+  /* verify we got all the required interfaces */
+#define VERIFY_INTERFACE_EXISTS(var, interface) \
+  if (!self->var) { \
+    g_set_error (error, g_quark_from_static_string ("GstWlDisplay"), 0, \
+        "Could not bind to " interface ". Either it is not implemented in " \
+        "the compositor, or the implemented version doesn't match"); \
+    g_object_unref (self); \
+    return NULL; \
+  }
+
+  VERIFY_INTERFACE_EXISTS (compositor, "wl_compositor");
+  VERIFY_INTERFACE_EXISTS (subcompositor, "wl_subcompositor");
+  VERIFY_INTERFACE_EXISTS (shell, "wl_shell");
+  VERIFY_INTERFACE_EXISTS (shm, "wl_shm");
+  VERIFY_INTERFACE_EXISTS (scaler, "wl_scaler");
+
+#undef VERIFY_INTERFACE_EXISTS
+
   self->thread = g_thread_try_new ("GstWlDisplay", gst_wl_display_thread_run,
       self, &err);
   if (err) {