From 9defb2e2b9da3adb7ef1d75a0f211fa08866c596 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 25 Feb 2016 12:30:04 -0500 Subject: [PATCH] Implement sink validation function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- lib/plugin-system/sink.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/plugin-system/sink.c b/lib/plugin-system/sink.c index 33295286d..4f705a001 100644 --- a/lib/plugin-system/sink.c +++ b/lib/plugin-system/sink.c @@ -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 -- 2.34.1