return ret;
}
-static
+BT_HIDDEN
void bt_component_source_destroy(struct bt_component *component)
{
- struct bt_component_source *source = container_of(component,
- struct bt_component_source, parent);
-
- if (source->output_ports) {
- g_ptr_array_free(source->output_ports, TRUE);
- }
}
-
BT_HIDDEN
struct bt_component *bt_component_source_create(
struct bt_component_class *class, struct bt_value *params)
{
- int ret;
struct bt_component_source *source = NULL;
- enum bt_component_status status;
source = g_new0(struct bt_component_source, 1);
if (!source) {
goto end;
}
- source->parent.class = bt_get(class);
- status = bt_component_init(&source->parent, bt_component_source_destroy);
- if (status != BT_COMPONENT_STATUS_OK) {
- goto error;
- }
-
- ret = bt_component_init_output_ports(&source->parent, &source->output_ports);
- if (ret) {
- goto error;
- }
-
end:
return source ? &source->parent : NULL;
-error:
- BT_PUT(source);
- goto end;
-}
-
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_source_create_notification_iterator(
- struct bt_component *component)
-{
- return bt_component_create_iterator(component, NULL);
-}
-
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_source_create_notification_iterator_with_init_method_data(
- struct bt_component *component, void *init_method_data)
-{
- return bt_component_create_iterator(component, init_method_data);
}
enum bt_component_status bt_component_source_get_output_port_count(
struct bt_component *component, uint64_t *count)
{
enum bt_component_status status = BT_COMPONENT_STATUS_OK;
- struct bt_component_source *source;
- if (!component || !count) {
+ if (!component || !count ||
+ component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
status = BT_COMPONENT_STATUS_INVALID;
goto end;
}
- if (component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
- status = BT_COMPONENT_STATUS_INVALID;
- goto end;
- }
-
- source = container_of(component, struct bt_component_source, parent);
- *count = (uint64_t) source->output_ports->len;
+ *count = bt_component_get_output_port_count(component);
end:
return status;
}
struct bt_port *bt_component_source_get_output_port(
struct bt_component *component, const char *name)
{
- struct bt_component_source *source;
- struct bt_port *ret_port = NULL;
+ struct bt_port *port = NULL;
if (!component || !name ||
component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
goto end;
}
- source = container_of(component, struct bt_component_source, parent);
- ret_port = bt_component_get_port(source->output_ports, name);
+ port = bt_component_get_output_port(component, name);
end:
- return ret_port;
+ return port;
}
struct bt_port *bt_component_source_get_output_port_at_index(
struct bt_component *component, int index)
{
struct bt_port *port = NULL;
- struct bt_component_source *source;
if (!component ||
component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
goto end;
}
- source = container_of(component, struct bt_component_source, parent);
- port = bt_component_get_port_at_index(source->output_ports, index);
+ port = bt_component_get_output_port_at_index(component, index);
end:
return port;
}
DEFAULT_OUTPUT_PORT_NAME);
}
-struct bt_port *bt_component_source_add_output_port(
- struct bt_component *component, const char *name)
+struct bt_private_port *bt_private_component_source_get_output_private_port(
+ struct bt_private_component *private_component,
+ const char *name)
{
- struct bt_port *port;
- struct bt_component_source *source;
+ return bt_private_port_from_port(bt_component_source_get_output_port(
+ bt_component_from_private(private_component), name));
+}
- if (!component ||
- component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
- port = NULL;
- goto end;
- }
+struct bt_private_port *
+bt_private_component_source_get_output_private_port_at_index(
+ struct bt_private_component *private_component, int index)
+{
+ return bt_private_port_from_port(
+ bt_component_source_get_output_port_at_index(
+ bt_component_from_private(private_component), index));
+}
- source = container_of(component, struct bt_component_source, parent);
- port = bt_component_add_port(component, source->output_ports,
- BT_PORT_TYPE_OUTPUT, name);
-end:
- return port;
+struct bt_private_port *bt_private_component_source_get_default_output_private_port(
+ struct bt_private_component *private_component)
+{
+ return bt_private_port_from_port(
+ bt_component_source_get_default_output_port(
+ bt_component_from_private(private_component)));
}
-enum bt_component_status bt_component_source_remove_output_port(
- struct bt_component *component, const char *name)
+struct bt_private_port *bt_private_component_source_add_output_private_port(
+ struct bt_private_component *private_component,
+ const char *name)
{
- enum bt_component_status status;
- struct bt_component_source *source;
+ struct bt_port *port = NULL;
+ struct bt_component *component =
+ bt_component_from_private(private_component);
if (!component ||
component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
- status = BT_COMPONENT_STATUS_INVALID;
goto end;
}
- source = container_of(component, struct bt_component_source, parent);
- status = bt_component_remove_port(component, source->output_ports,
- name);
+ port = bt_component_add_output_port(component, name);
end:
- return status;
+ return bt_private_port_from_port(port);
}