- enum bt_component_status status = BT_COMPONENT_STATUS_OK;
-
- assert(comp);
- assert(self_port);
- assert(other_port);
-
- if (comp->class->methods.accept_port_connection) {
- BT_LOGD("Calling user's \"accept port connection\" method: "
- "comp-addr=%p, comp-name=\"%s\", "
- "self-port-addr=%p, self-port-name=\"%s\", "
- "other-port-addr=%p, other-port-name=\"%s\"",
- comp, bt_component_get_name(comp),
- self_port, bt_port_get_name(self_port),
- other_port, bt_port_get_name(other_port));
- status = comp->class->methods.accept_port_connection(
- bt_private_component_from_component(comp),
- bt_private_port_from_port(self_port),
- other_port);
- BT_LOGD("User method returned: status=%s",
- bt_component_status_string(status));
+ typedef enum bt_self_component_status (*method_t)(
+ void *, void *, const void *);
+
+ enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
+ method_t method = NULL;
+
+ BT_ASSERT(comp);
+ BT_ASSERT(self_port);
+ BT_ASSERT(other_port);
+
+ switch (comp->class->type) {
+ case BT_COMPONENT_CLASS_TYPE_SOURCE:
+ {
+ struct bt_component_class_source *src_cc = (void *) comp->class;
+
+ switch (self_port->type) {
+ case BT_PORT_TYPE_OUTPUT:
+ method = (method_t) src_cc->methods.output_port_connected;
+ break;
+ default:
+ abort();
+ }
+
+ break;