- 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);
+ 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.accept_output_port_connection;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_FILTER:
+ {
+ struct bt_component_class_filter *flt_cc = (void *) comp->class;
+
+ switch (self_port->type) {
+ case BT_PORT_TYPE_INPUT:
+ method = (method_t) flt_cc->methods.accept_input_port_connection;
+ break;
+ case BT_PORT_TYPE_OUTPUT:
+ method = (method_t) flt_cc->methods.accept_output_port_connection;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ case BT_COMPONENT_CLASS_TYPE_SINK:
+ {
+ struct bt_component_class_sink *sink_cc = (void *) comp->class;
+
+ switch (self_port->type) {
+ case BT_PORT_TYPE_INPUT:
+ method = (method_t) sink_cc->methods.accept_input_port_connection;
+ break;
+ default:
+ abort();
+ }
+
+ break;
+ }
+ default:
+ abort();
+ }
+
+ if (method) {
+ BT_LIB_LOGD("Calling user's \"accept port connection\" method: "
+ "%![comp-]+c, %![self-port-]+p, %![other-port-]+p",
+ comp, self_port, other_port);
+ status = method(comp, self_port, other_port);