Implement sink validation function
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 25 Feb 2016 17:30:04 +0000 (12:30 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 16:57:26 +0000 (12:57 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/plugin-system/sink.c

index 33295286d67ec87fdcd9561ff9c7a74ca0732a18..4f705a00134c11d68850e515ef1d3a9984c47a48 100644 (file)
@@ -35,7 +35,26 @@ BT_HIDDEN
 enum bt_component_status bt_component_sink_validate(
                struct bt_component *component)
 {
-       return BT_COMPONENT_STATUS_OK;
+       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       struct bt_component_sink *sink;
+
+       sink = container_of(component, struct bt_component_sink, parent);
+       if (sink->registered_notifications_mask == 0) {
+               /*
+                * A sink must be registered to at least one notification type.
+                */
+               printf_error("Invalid sink component; not registered to any notification");
+               ret = BT_COMPONENT_STATUS_INVALID;
+               goto end;
+       }
+
+       if (!sink->handle_notification) {
+               printf_error("Invalid sink component; no notification handling callback defined.");
+               ret = BT_COMPONENT_STATUS_INVALID;
+               goto end;
+       }
+end:
+       return ret;
 }
 
 BT_HIDDEN
This page took 0.025728 seconds and 4 git commands to generate.