diff options
author | Wim Taymans <wtaymans@redhat.com> | 2019-12-11 12:24:03 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2019-12-11 12:24:03 +0100 |
commit | f62d1cb3579e97c82c761febc2fe2912cf490618 (patch) | |
tree | cc5d7f8dd40e14620964ed892069bef07f848f7e | |
parent | b88741dbb961497a07f2af0b177e1c275d5bf918 (diff) |
pw_port -> pw_impl_port
-rw-r--r-- | src/modules/module-adapter/adapter.c | 8 | ||||
-rw-r--r-- | src/modules/module-client-node/client-node.c | 32 | ||||
-rw-r--r-- | src/modules/module-client-node/remote-node.c | 28 | ||||
-rw-r--r-- | src/modules/module-link-factory.c | 12 | ||||
-rw-r--r-- | src/pipewire/context.c | 28 | ||||
-rw-r--r-- | src/pipewire/control.c | 10 | ||||
-rw-r--r-- | src/pipewire/control.h | 4 | ||||
-rw-r--r-- | src/pipewire/impl-link.c | 144 | ||||
-rw-r--r-- | src/pipewire/impl-link.h | 13 | ||||
-rw-r--r-- | src/pipewire/impl-node.c | 58 | ||||
-rw-r--r-- | src/pipewire/impl-node.h | 13 | ||||
-rw-r--r-- | src/pipewire/impl-port.c | 206 | ||||
-rw-r--r-- | src/pipewire/impl-port.h | 46 | ||||
-rw-r--r-- | src/pipewire/impl.h | 6 | ||||
-rw-r--r-- | src/pipewire/private.h | 150 |
15 files changed, 380 insertions, 378 deletions
diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index 09c12cc7..3e19b3e4 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -80,7 +80,7 @@ static void node_free(void *data) pw_properties_free(n->props); } -static void node_port_init(void *data, struct pw_port *port) +static void node_port_init(void *data, struct pw_impl_port *port) { struct node *n = data; const struct pw_properties *old; @@ -90,9 +90,9 @@ static void node_port_init(void *data, struct pw_port *port) char position[8], *prefix; bool is_monitor, is_device; - direction = pw_port_get_direction(port); + direction = pw_impl_port_get_direction(port); - old = pw_port_get_properties(port); + old = pw_impl_port_get_properties(port); is_monitor = (str = pw_properties_get(old, PW_KEY_PORT_MONITOR)) != NULL && pw_properties_parse_bool(str); @@ -145,7 +145,7 @@ static void node_port_init(void *data, struct pw_port *port) pw_properties_setf(new, PW_KEY_PORT_ALIAS, "%s:%s_%s", node_name, prefix, str); - pw_port_update_properties(port, &new->dict); + pw_impl_port_update_properties(port, &new->dict); pw_properties_free(new); } diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index 0106a9ac..df63a5e8 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -87,7 +87,7 @@ struct mix { }; struct port { - struct pw_port *port; + struct pw_impl_port *port; struct node *node; struct impl *impl; @@ -1295,7 +1295,7 @@ static void node_free(void *data) free(impl); } -static int port_init_mix(void *data, struct pw_port_mix *mix) +static int port_init_mix(void *data, struct pw_impl_port_mix *mix) { struct port *port = data; struct impl *impl = port->impl; @@ -1319,7 +1319,7 @@ static int port_init_mix(void *data, struct pw_port_mix *mix) return 0; } -static int port_release_mix(void *data, struct pw_port_mix *mix) +static int port_release_mix(void *data, struct pw_impl_port_mix *mix) { struct port *port = data; struct impl *impl = port->impl; @@ -1338,7 +1338,7 @@ static int port_release_mix(void *data, struct pw_port_mix *mix) return 0; } -static const struct pw_port_implementation port_impl = { +static const struct pw_impl_port_implementation port_impl = { PW_VERSION_PORT_IMPLEMENTATION, .init_mix = port_init_mix, .release_mix = port_release_mix, @@ -1404,9 +1404,9 @@ static int impl_mix_port_set_io(void *object, uint32_t id, void *data, size_t size) { struct port *p = object; - struct pw_port *port = p->port; + struct pw_impl_port *port = p->port; struct impl *impl = port->owner_data; - struct pw_port_mix *mix; + struct pw_impl_port_mix *mix; mix = pw_map_lookup(&port->mix_port_map, mix_id); if (mix == NULL) @@ -1448,10 +1448,10 @@ static const struct spa_node_methods impl_port_mix = { .process = impl_mix_process, }; -static void node_port_init(void *data, struct pw_port *port) +static void node_port_init(void *data, struct pw_impl_port *port) { struct impl *impl = data; - struct port *p = pw_port_get_user_data(port); + struct port *p = pw_impl_port_get_user_data(port); struct node *this = &impl->node; pw_log_debug(NAME " %p: port %p init", this, port); @@ -1478,26 +1478,26 @@ static void node_port_init(void *data, struct pw_port *port) return; } -static void node_port_added(void *data, struct pw_port *port) +static void node_port_added(void *data, struct pw_impl_port *port) { struct impl *impl = data; - struct port *p = pw_port_get_user_data(port); + struct port *p = pw_impl_port_get_user_data(port); - pw_port_set_mix(port, &p->mix_node, - PW_PORT_MIX_FLAG_MULTI | - PW_PORT_MIX_FLAG_MIX_ONLY); + pw_impl_port_set_mix(port, &p->mix_node, + PW_IMPL_PORT_MIX_FLAG_MULTI | + PW_IMPL_PORT_MIX_FLAG_MIX_ONLY); - port->flags |= PW_PORT_FLAG_NO_MIXER; + port->flags |= PW_IMPL_PORT_FLAG_NO_MIXER; port->impl = SPA_CALLBACKS_INIT(&port_impl, p); port->owner_data = impl; } -static void node_port_removed(void *data, struct pw_port *port) +static void node_port_removed(void *data, struct pw_impl_port *port) { struct impl *impl = data; struct node *this = &impl->node; - struct port *p = pw_port_get_user_data(port); + struct port *p = pw_impl_port_get_user_data(port); pw_log_debug(NAME " %p: port %p remove", this, port); diff --git a/src/modules/module-client-node/remote-node.c b/src/modules/module-client-node/remote-node.c index 8eddb20d..096d2371 100644 --- a/src/modules/module-client-node/remote-node.c +++ b/src/modules/module-client-node/remote-node.c @@ -53,9 +53,9 @@ struct buffer { struct mix { struct spa_list link; - struct pw_port *port; + struct pw_impl_port *port; uint32_t mix_id; - struct pw_port_mix mix; + struct pw_impl_port_mix mix; struct pw_array buffers; bool active; }; @@ -144,11 +144,11 @@ static void clean_transport(struct node_data *data) data->have_transport = false; } -static void mix_init(struct mix *mix, struct pw_port *port, uint32_t mix_id) +static void mix_init(struct mix *mix, struct pw_impl_port *port, uint32_t mix_id) { mix->port = port; mix->mix_id = mix_id; - pw_port_init_mix(port, &mix->mix); + pw_impl_port_init_mix(port, &mix->mix); mix->active = false; pw_array_init(&mix->buffers, 32); pw_array_ensure_size(&mix->buffers, sizeof(struct buffer) * 64); @@ -214,7 +214,7 @@ static struct mix *ensure_mix(struct node_data *data, enum spa_direction direction, uint32_t port_id, uint32_t mix_id) { struct mix *mix; - struct pw_port *port; + struct pw_impl_port *port; if ((mix = find_mix(data, direction, port_id, mix_id))) return mix; @@ -328,7 +328,7 @@ static int add_node_update(struct pw_proxy *proxy, uint32_t change_mask) return res; } -static int add_port_update(struct pw_proxy *proxy, struct pw_port *port, uint32_t change_mask) +static int add_port_update(struct pw_proxy *proxy, struct pw_impl_port *port, uint32_t change_mask) { struct node_data *data = proxy->user_data; struct spa_port_info pi = SPA_PORT_INFO_INIT(); @@ -510,13 +510,13 @@ client_node_remove_port(void *object, enum spa_direction direction, uint32_t por static int clear_buffers(struct node_data *data, struct mix *mix) { - struct pw_port *port = mix->port; + struct pw_impl_port *port = mix->port; struct buffer *b; int res; pw_log_debug("port %p: clear buffers mix:%d %zd", port, mix->mix_id, mix->buffers.size); - if ((res = pw_port_use_buffers(port, &mix->mix, 0, NULL, 0)) < 0) { + if ((res = pw_impl_port_use_buffers(port, &mix->mix, 0, NULL, 0)) < 0) { pw_log_error("port %p: error clear buffers %s", port, spa_strerror(res)); return res; } @@ -539,7 +539,7 @@ client_node_port_set_param(void *object, { struct pw_proxy *proxy = object; struct node_data *data = proxy->user_data; - struct pw_port *port; + struct pw_impl_port *port; int res; port = pw_node_find_port(data->node, direction, port_id); @@ -558,7 +558,7 @@ client_node_port_set_param(void *object, } } - res = pw_port_set_param(port, id, flags, param); + res = pw_impl_port_set_param(port, id, flags, param); if (res < 0) goto error_exit; @@ -690,7 +690,7 @@ client_node_port_use_buffers(void *object, bufs[i] = b; } - if ((res = pw_port_use_buffers(mix->port, &mix->mix, flags, bufs, n_buffers)) < 0) + if ((res = pw_impl_port_use_buffers(mix->port, &mix->mix, flags, bufs, n_buffers)) < 0) goto error_exit_cleanup; if (flags & SPA_NODE_BUFFERS_FLAG_ALLOC) { @@ -888,7 +888,7 @@ static const struct pw_client_node_proxy_events client_node_events = { static void do_node_init(struct pw_proxy *proxy) { struct node_data *data = proxy->user_data; - struct pw_port *port; + struct pw_impl_port *port; pw_log_debug("%p: init", data); add_node_update(proxy, PW_CLIENT_NODE_UPDATE_PARAMS | @@ -968,7 +968,7 @@ static void node_info_changed(void *data, const struct pw_node_info *info) add_node_update((struct pw_proxy*)d->client_node, change_mask); } -static void node_port_info_changed(void *data, struct pw_port *port, +static void node_port_info_changed(void *data, struct pw_impl_port *port, const struct pw_port_info *info) { struct node_data *d = data; @@ -1057,7 +1057,7 @@ static int node_ready(void *d, int status) struct pw_node *node = data->node; struct pw_node_activation *a = node->rt.activation; struct timespec ts; - struct pw_port *p; + struct pw_impl_port *p; uint64_t cmd = 1; pw_log_trace("node %p: ready driver:%d exported:%d status:%d", node, diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c index 4178d25d..1d1ff688 100644 --- a/src/modules/module-link-factory.c +++ b/src/modules/module-link-factory.c @@ -142,25 +142,25 @@ static const struct pw_impl_link_events link_events = { .initialized = link_initialized }; -static struct pw_port *get_port(struct pw_node *node, enum spa_direction direction) +static struct pw_impl_port *get_port(struct pw_node *node, enum spa_direction direction) { - struct pw_port *p; + struct pw_impl_port *p; int res; p = pw_node_find_port(node, direction, SPA_ID_INVALID); - if (p == NULL || pw_port_is_linked(p)) { + if (p == NULL || pw_impl_port_is_linked(p)) { uint32_t port_id; port_id = pw_node_get_free_port_id(node, direction); if (port_id == SPA_ID_INVALID) return NULL; - p = pw_port_new(direction, port_id, NULL, 0); + p = pw_impl_port_new(direction, port_id, NULL, 0); if (p == NULL) return NULL; - if ((res = pw_port_add(p, node)) < 0) { + if ((res = pw_impl_port_add(p, node)) < 0) { pw_log_warn("can't add port: %s", spa_strerror(res)); errno = -res; return NULL; @@ -180,7 +180,7 @@ static void *create_object(void *_data, struct factory_data *d = _data; struct pw_impl_client *client = NULL; struct pw_node *output_node, *input_node; - struct pw_port *outport, *inport; + struct pw_impl_port *outport, *inport; struct pw_context *context; struct pw_global *global; struct pw_impl_link *link; diff --git a/src/pipewire/context.c b/src/pipewire/context.c index c4b0f19f..70ec784f 100644 --- a/src/pipewire/context.c +++ b/src/pipewire/context.c @@ -834,15 +834,15 @@ struct pw_global *pw_context_find_global(struct pw_context *context, uint32_t id * * \memberof pw_context */ -struct pw_port *pw_context_find_port(struct pw_context *context, - struct pw_port *other_port, +struct pw_impl_port *pw_context_find_port(struct pw_context *context, + struct pw_impl_port *other_port, uint32_t id, struct pw_properties *props, uint32_t n_format_filters, struct spa_pod **format_filters, char **error) { - struct pw_port *best = NULL; + struct pw_impl_port *best = NULL; bool have_id; struct pw_node *n; @@ -875,7 +875,7 @@ struct pw_port *pw_context_find_port(struct pw_context *context, break; } } else { - struct pw_port *p, *pin, *pout; + struct pw_impl_port *p, *pin, *pout; uint8_t buf[4096]; struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf)); struct spa_pod *dummy; @@ -933,8 +933,8 @@ struct pw_port *pw_context_find_port(struct pw_context *context, * \memberof pw_context */ int pw_context_find_format(struct pw_context *context, - struct pw_port *output, - struct pw_port *input, + struct pw_impl_port *output, + struct pw_impl_port *input, struct pw_properties *props, uint32_t n_format_filters, struct spa_pod **format_filters, @@ -955,14 +955,14 @@ int pw_context_find_format(struct pw_context *context, pw_log_debug(NAME" %p: finding best format %d %d", context, out_state, in_state); /* when a port is configured but the node is idle, we can reconfigure with a different format */ - if (out_state > PW_PORT_STATE_CONFIGURE && output->node->info.state == PW_NODE_STATE_IDLE) - out_state = PW_PORT_STATE_CONFIGURE; - if (in_state > PW_PORT_STATE_CONFIGURE && input->node->info.state == PW_NODE_STATE_IDLE) - in_state = PW_PORT_STATE_CONFIGURE; + if (out_state > PW_IMPL_PORT_STATE_CONFIGURE && output->node->info.state == PW_NODE_STATE_IDLE) + out_state = PW_IMPL_PORT_STATE_CONFIGURE; + if (in_state > PW_IMPL_PORT_STATE_CONFIGURE && input->node->info.state == PW_NODE_STATE_IDLE) + in_state = PW_IMPL_PORT_STATE_CONFIGURE; pw_log_debug(NAME" %p: states %d %d", context, out_state, in_state); - if (in_state == PW_PORT_STATE_CONFIGURE && out_state > PW_PORT_STATE_CONFIGURE) { + if (in_state == PW_IMPL_PORT_STATE_CONFIGURE && out_state > PW_IMPL_PORT_STATE_CONFIGURE) { /* only input needs format */ spa_pod_builder_init(&fb, fbuf, sizeof(fbuf)); if ((res = spa_node_port_enum_params_sync(output->node->node, @@ -989,7 +989,7 @@ int pw_context_find_format(struct pw_context *context, asprintf(error, "no input formats"); goto error; } - } else if (out_state >= PW_PORT_STATE_CONFIGURE && in_state > PW_PORT_STATE_CONFIGURE) { + } else if (out_state >= PW_IMPL_PORT_STATE_CONFIGURE && in_state > PW_IMPL_PORT_STATE_CONFIGURE) { /* only output needs format */ spa_pod_builder_init(&fb, fbuf, sizeof(fbuf)); if ((res = spa_node_port_enum_params_sync(input->node->node, @@ -1016,7 +1016,7 @@ int pw_context_find_format(struct pw_context *context, asprintf(error, "no output format"); goto error; } - } else if (in_state == PW_PORT_STATE_CONFIGURE && out_state == PW_PORT_STATE_CONFIGURE) { + } else if (in_state == PW_IMPL_PORT_STATE_CONFIGURE && out_state == PW_IMPL_PORT_STATE_CONFIGURE) { again: /* both ports need a format */ pw_log_debug(NAME" %p: do enum input %d", context, iidx); @@ -1094,7 +1094,7 @@ static int collect_nodes(struct pw_node *driver) { struct spa_list queue; struct pw_node *n, *t; - struct pw_port *p; + struct pw_impl_port *p; struct pw_impl_link *l; uint32_t max_quantum = 0; uint32_t min_quantum = 0; diff --git a/src/pipewire/control.c b/src/pipewire/control.c index 79b52fb7..04e25739 100644 --- a/src/pipewire/control.c +++ b/src/pipewire/control.c @@ -38,7 +38,7 @@ struct impl { struct pw_control * pw_control_new(struct pw_context *context, - struct pw_port *port, + struct pw_impl_port *port, uint32_t id, uint32_t size, size_t user_data_size) { @@ -83,7 +83,7 @@ pw_control_new(struct pw_context *context, spa_list_append(&context->control_list[direction], &this->link); if (port) { spa_list_append(&port->control_list[direction], &this->port_link); - pw_port_emit_control_added(port, this); + pw_impl_port_emit_control_added(port, this); } return this; @@ -113,7 +113,7 @@ void pw_control_destroy(struct pw_control *control) if (control->port) { spa_list_remove(&control->port_link); - pw_port_emit_control_removed(control->port, control); + pw_impl_port_emit_control_removed(control->port, control); } pw_log_debug(NAME" %p: free", control); @@ -127,7 +127,7 @@ void pw_control_destroy(struct pw_control *control) } SPA_EXPORT -struct pw_port *pw_control_get_port(struct pw_control *control) +struct pw_impl_port *pw_control_get_port(struct pw_control *control) { return control->port; } @@ -141,7 +141,7 @@ void pw_control_add_listener(struct pw_control *control, spa_hook_list_append(&control->listener_list, listener, events, data); } -static int port_set_io(struct pw_port *port, uint32_t mix, uint32_t id, void *data, uint32_t size) +static int port_set_io(struct pw_impl_port *port, uint32_t mix, uint32_t id, void *data, uint32_t size) { int res; diff --git a/src/pipewire/control.h b/src/pipewire/control.h index 4f10742f..925cc7ae 100644 --- a/src/pipewire/control.h +++ b/src/pipewire/control.h @@ -47,7 +47,7 @@ struct pw_control; /** Port events, use \ref pw_control_add_listener */ struct pw_control_events { -#define PW_VERSION_PORT_EVENTS 0 +#define PW_VERSION_CONTROL_EVENTS 0 uint32_t version; /** The control is destroyed */ @@ -64,7 +64,7 @@ struct pw_control_events { }; /** Get the control parent port or NULL when not set */ -struct pw_port *pw_control_get_port(struct pw_control *control); +struct pw_impl_port *pw_control_get_port(struct pw_control *control); /** Add an event listener on the control */ void pw_control_add_listener(struct pw_control *control, diff --git a/src/pipewire/impl-link.c b/src/pipewire/impl-link.c index 4300a9de..83e9e6e0 100644 --- a/src/pipewire/impl-link.c +++ b/src/pipewire/impl-link.c @@ -155,34 +155,34 @@ static void pw_impl_link_update_state(struct pw_impl_link *link, enum pw_link_st static void complete_ready(void *obj, void *data, int res, uint32_t id) { - struct pw_port *port = obj; + struct pw_impl_port *port = obj; struct pw_impl_link *this = data; pw_log_debug(NAME" %p: obj:%p port %p complete READY: %s", this, obj, port, spa_strerror(res)); if (SPA_RESULT_IS_OK(res)) { - pw_port_update_state(port, PW_PORT_STATE_READY, NULL); + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_READY, NULL); } else { - pw_port_update_state(port, PW_PORT_STATE_ERROR, NULL); + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_ERROR, NULL); } - if (this->input->state >= PW_PORT_STATE_READY && - this->output->state >= PW_PORT_STATE_READY) + if (this->input->state >= PW_IMPL_PORT_STATE_READY && + this->output->state >= PW_IMPL_PORT_STATE_READY) pw_impl_link_update_state(this, PW_LINK_STATE_ALLOCATING, NULL); } static void complete_paused(void *obj, void *data, int res, uint32_t id) { - struct pw_port *port = obj; + struct pw_impl_port *port = obj; struct pw_impl_link *this = data; - struct pw_port_mix *mix = port == this->input ? &this->rt.in_mix : &this->rt.out_mix; + struct pw_impl_port_mix *mix = port == this->input ? &this->rt.in_mix : &this->rt.out_mix; pw_log_debug(NAME" %p: obj:%p port %p complete PAUSED: %s", this, obj, port, spa_strerror(res)); if (SPA_RESULT_IS_OK(res)) { - pw_port_update_state(port, PW_PORT_STATE_PAUSED, NULL); + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_PAUSED, NULL); mix->have_buffers = true; } else { - pw_port_update_state(port, PW_PORT_STATE_ERROR, NULL); + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_ERROR, NULL); mix->have_buffers = false; } if (this->rt.in_mix.have_buffers && this->rt.out_mix.have_buffers) @@ -196,7 +196,7 @@ static int do_negotiate(struct pw_impl_link *this) struct spa_pod *format = NULL, *current; char *error = NULL; bool changed = true; - struct pw_port *input, *output; + struct pw_impl_port *input, *output; uint8_t buffer[4096]; struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); uint32_t index; @@ -213,7 +213,7 @@ static int do_negotiate(struct pw_impl_link *this) pw_log_debug(NAME" %p: in_state:%d out_state:%d", this, in_state, out_state); - if (in_state != PW_PORT_STATE_CONFIGURE && out_state != PW_PORT_STATE_CONFIGURE) + if (in_state != PW_IMPL_PORT_STATE_CONFIGURE && out_state != PW_IMPL_PORT_STATE_CONFIGURE) return 0; pw_impl_link_update_state(this, PW_LINK_STATE_NEGOTIATING, NULL); @@ -233,7 +233,7 @@ static int do_negotiate(struct pw_impl_link *this) spa_pod_builder_init(&b, buffer, sizeof(buffer)); /* if output port had format and is idle, check if it changed. If so, renegotiate */ - if (out_state > PW_PORT_STATE_CONFIGURE && output->node->info.state == PW_NODE_STATE_IDLE) { + if (out_state > PW_IMPL_PORT_STATE_CONFIGURE && output->node->info.state == PW_NODE_STATE_IDLE) { index = 0; res = spa_node_port_enum_params_sync(output->node->node, output->direction, output->port_id, @@ -261,7 +261,7 @@ static int do_negotiate(struct pw_impl_link *this) spa_debug_pod(2, NULL, format); } pw_node_set_state(output->node, PW_NODE_STATE_SUSPENDED); - out_state = PW_PORT_STATE_CONFIGURE; + out_state = PW_IMPL_PORT_STATE_CONFIGURE; } else { pw_log_debug(NAME" %p: format was already set", this); @@ -269,7 +269,7 @@ static int do_negotiate(struct pw_impl_link *this) } } /* if input port had format and is idle, check if it changed. If so, renegotiate */ - if (in_state > PW_PORT_STATE_CONFIGURE && input->node->info.state == PW_NODE_STATE_IDLE) { + if (in_state > PW_IMPL_PORT_STATE_CONFIGURE && input->node->info.state == PW_NODE_STATE_IDLE) { index = 0; res = spa_node_port_enum_params_sync(input->node->node, input->direction, input->port_id, @@ -297,7 +297,7 @@ static int do_negotiate(struct pw_impl_link *this) spa_debug_pod(2, NULL, format); } pw_node_set_state(input->node, PW_NODE_STATE_SUSPENDED); - in_state = PW_PORT_STATE_CONFIGURE; + in_state = PW_IMPL_PORT_STATE_CONFIGURE; } else { pw_log_debug(NAME" %p: format was already set", this); @@ -309,9 +309,9 @@ static int do_negotiate(struct pw_impl_link *this) if (pw_log_level_enabled(SPA_LOG_LEVEL_DEBUG)) spa_debug_format(2, NULL, format); - if (out_state == PW_PORT_STATE_CONFIGURE) { + if (out_state == PW_IMPL_PORT_STATE_CONFIGURE) { pw_log_debug(NAME" %p: doing set format on output", this); - if ((res = pw_port_set_param(output, + if ((res = pw_impl_port_set_param(output, SPA_PARAM_Format, SPA_NODE_PARAM_FLAG_NEAREST, format)) < 0) { asprintf(&error, "error set output format: %d (%s)", res, spa_strerror(res)); @@ -325,9 +325,9 @@ static int do_negotiate(struct pw_impl_link *this) complete_ready(output, this, res, 0); } } - if (in_state == PW_PORT_STATE_CONFIGURE) { + if (in_state == PW_IMPL_PORT_STATE_CONFIGURE) { pw_log_debug(NAME" %p: doing set format on input", this); - if ((res2 = pw_port_set_param(input, + if ((res2 = pw_impl_port_set_param(input, SPA_PARAM_Format, SPA_NODE_PARAM_FLAG_NEAREST, format)) < 0) { asprintf(&error, "error set input format: %d (%s)", res2, spa_strerror(res2)); @@ -360,8 +360,8 @@ error: return res; } -static int port_set_io(struct pw_impl_link *this, struct pw_port *port, uint32_t id, - void *data, size_t size, struct pw_port_mix *mix) +static int port_set_io(struct pw_impl_link *this, struct pw_impl_port *port, uint32_t id, + void *data, size_t size, struct pw_impl_port_mix *mix) { int res = 0; @@ -408,7 +408,7 @@ static int do_allocation(struct pw_impl_link *this) int res; uint32_t in_flags, out_flags; char *error = NULL; - struct pw_port *input, *output; + struct pw_impl_port *input, *output; if (this->info.state > PW_LINK_STATE_ALLOCATING) return 0; @@ -459,7 +459,7 @@ static int do_allocation(struct pw_impl_link *this) pw_log_debug(NAME" %p: allocating %d buffers %p", this, output->buffers.n_buffers, output->buffers.buffers); - if ((res = pw_port_use_buffers(output, &this->rt.out_mix, flags, + if ((res = pw_impl_port_use_buffers(output, &this->rt.out_mix, flags, output->buffers.buffers, output->buffers.n_buffers)) < 0) { asprintf(&error, "error use output buffers: %d (%s)", res, @@ -480,7 +480,7 @@ static int do_allocation(struct pw_impl_link *this) pw_log_debug(NAME" %p: using %d buffers %p on input port", this, output->buffers.n_buffers, output->buffers.buffers); - if ((res = pw_port_use_buffers(input, &this->rt.in_mix, 0, + if ((res = pw_impl_port_use_buffers(input, &this->rt.in_mix, 0, output->buffers.buffers, output->buffers.n_buffers)) < 0) { asprintf(&error, "error use input buffers: %d (%s)", res, @@ -562,7 +562,7 @@ static void check_states(void *obj, void *user_data, int res, uint32_t id) struct pw_impl_link *this = obj; struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this); int in_state, out_state; - struct pw_port *input, *output; + struct pw_impl_port *input, *output; if (this->info.state == PW_LINK_STATE_ERROR) return; @@ -592,14 +592,14 @@ static void check_states(void *obj, void *user_data, int res, uint32_t id) pw_log_debug(NAME" %p: output state %d, input state %d", this, out_state, in_state); - if (out_state == PW_PORT_STATE_ERROR || in_state == PW_PORT_STATE_ERROR) { + if (out_state == PW_IMPL_PORT_STATE_ERROR || in_state == PW_IMPL_PORT_STATE_ERROR) { pw_impl_link_update_state(this, PW_LINK_STATE_ERROR, strdup("ports are in error")); return; } - if (PW_PORT_IS_CONTROL(output) && PW_PORT_IS_CONTROL(input)) { - pw_port_update_state(output, PW_PORT_STATE_PAUSED, NULL); - pw_port_update_state(input, PW_PORT_STATE_PAUSED, NULL); + if (PW_IMPL_PORT_IS_CONTROL(output) && PW_IMPL_PORT_IS_CONTROL(input)) { + pw_impl_port_update_state(output, PW_IMPL_PORT_STATE_PAUSED, NULL); + pw_impl_port_update_state(input, PW_IMPL_PORT_STATE_PAUSED, NULL); pw_impl_link_update_state(this, PW_LINK_STATE_PAUSED, NULL); } @@ -619,10 +619,10 @@ exit: this, -EBUSY, (pw_work_func_t) check_states, this); } -static void input_remove(struct pw_impl_link *this, struct pw_port *port) +static void input_remove(struct pw_impl_link *this, struct pw_impl_port *port) { struct impl *impl = (struct impl *) this; - struct pw_port_mix *mix = &this->rt.in_mix; + struct pw_impl_port_mix *mix = &this->rt.in_mix; int res; pw_log_debug(NAME" %p: remove input port %p", this, port); @@ -631,19 +631,19 @@ static void input_remove(struct pw_impl_link *this, struct pw_port *port) spa_hook_remove(&impl->input_global_listener); spa_list_remove(&this->input_link); - pw_port_emit_link_removed(this->input, this); + pw_impl_port_emit_link_removed(this->input, this); - if ((res = pw_port_use_buffers(port, mix, 0, NULL, 0)) < 0) { + if ((res = pw_impl_port_use_buffers(port, mix, 0, NULL, 0)) < 0) { pw_log_warn(NAME" %p: port %p clear error %s", this, port, spa_strerror(res)); } - pw_port_release_mix(port, mix); + pw_impl_port_release_mix(port, mix); this->input = NULL; } -static void output_remove(struct pw_impl_link *this, struct pw_port *port) +static void output_remove(struct pw_impl_link *this, struct pw_impl_port *port) { struct impl *impl = (struct impl *) this; - struct pw_port_mix *mix = &this->rt.out_mix; + struct pw_impl_port_mix *mix = &this->rt.out_mix; pw_log_debug(NAME" %p: remove output port %p", this, port); spa_hook_remove(&impl->output_port_listener); @@ -651,16 +651,16 @@ static void output_remove(struct pw_impl_link *this, struct pw_port *port) spa_hook_remove(&impl->output_global_listener); spa_list_remove(&this->output_link); - pw_port_emit_link_removed(this->output, this); + pw_impl_port_emit_link_removed(this->output, this); /* we don't clear output buffers when the link goes away. They will get * cleared when the node goes to suspend */ - pw_port_release_mix(port, mix); + pw_impl_port_release_mix(port, mix); this->output = NULL; } -static void on_port_destroy(struct pw_impl_link *this, struct pw_port *port) +static void on_port_destroy(struct pw_impl_link *this, struct pw_impl_port *port) { pw_log_debug(NAME" %p: port %p", this, port); pw_impl_link_emit_port_unlinked(this, port); @@ -773,7 +773,7 @@ int pw_impl_link_deactivate(struct pw_impl_link *this) input_node->info.state > PW_NODE_STATE_IDLE) { pw_node_set_state(input_node, PW_NODE_STATE_IDLE); pw_log_debug(NAME" %p: input port %p state %d -> %d", this, - this->input, this->input->state, PW_PORT_STATE_PAUSED); + this->input, this->input->state, PW_IMPL_PORT_STATE_PAUSED); } if (output_node->n_used_input_links <= output_node->idle_used_input_links && @@ -781,7 +781,7 @@ int pw_impl_link_deactivate(struct pw_impl_link *this) output_node->info.state > PW_NODE_STATE_IDLE) { pw_node_set_state(output_node, PW_NODE_STATE_IDLE); pw_log_debug(NAME" %p: output port %p state %d -> %d", this, - this->output, this->output->state, PW_PORT_STATE_PAUSED); + this->output, this->output->state, PW_IMPL_PORT_STATE_PAUSED); } pw_impl_link_update_state(this, PW_LINK_STATE_INIT, NULL); @@ -832,11 +832,11 @@ error_resource: return -errno; } -static void port_state_changed(struct pw_impl_link *this, struct pw_port *port, struct pw_port *other, - enum pw_port_state state, const char *error) +static void port_state_changed(struct pw_impl_link *this, struct pw_impl_port *port, struct pw_impl_port *other, + enum pw_impl_port_state state, const char *error) { switch (state) { - case PW_PORT_STATE_ERROR: + case PW_IMPL_PORT_STATE_ERROR: pw_impl_link_update_state(this, PW_LINK_STATE_ERROR, error ? strdup(error) : NULL); break; default: @@ -844,35 +844,35 @@ static void port_state_changed(struct pw_impl_link *this, struct pw_port *port, } } -static void input_port_state_changed(void *data, enum pw_port_state old, - enum pw_port_state state, const char *error) +static void input_port_state_changed(void *data, enum pw_impl_port_state old, + enum pw_impl_port_state state, const char *error) { struct impl *impl = data; struct pw_impl_link *this = &impl->this; port_state_changed(this, this->input, this->output, state, error); } -static void output_port_state_changed(void *data, enum pw_port_state old, - enum pw_port_state state, const char *error) +static void output_port_state_changed(void *data, enum pw_impl_port_state old, + enum pw_impl_port_state state, const char *error) { struct impl *impl = data; struct pw_impl_link *this = &impl->this; port_state_changed(this, this->output, this->input, state, error); } -static const struct pw_port_events input_port_events = { - PW_VERSION_PORT_EVENTS, +static const struct pw_impl_port_events input_port_events = { + PW_VERSION_IMPL_PORT_EVENTS, .state_changed = input_port_state_changed, .destroy = input_port_destroy, }; -static const struct pw_port_events output_port_events = { - PW_VERSION_PORT_EVENTS, +static const struct pw_impl_port_events output_port_events = { + PW_VERSION_IMPL_PORT_EVENTS, .state_changed = output_port_state_changed, .destroy = output_port_destroy, }; -static void node_result(struct impl *impl, struct pw_port *port, +static void node_result(struct impl *impl, struct pw_impl_port *port, int seq, int res, uint32_t type, const void *result) { if (SPA_RESULT_IS_ASYNC(seq)) @@ -882,7 +882,7 @@ static void node_result(struct impl *impl, struct pw_port *port, static void input_node_result(void *data, int seq, int res, uint32_t type, const void *result) { struct impl *impl = data; - struct pw_port *port = impl->this.input; + struct pw_impl_port *port = impl->this.input; pw_log_trace(NAME" %p: input port %p result seq:%d res:%d type:%u", impl, port, seq, res, type); node_result(impl, port, seq, res, type, result); @@ -891,7 +891,7 @@ static void input_node_result(void *data, int seq, int res, uint32_t type, const static void output_node_result(void *data, int seq, int res, uint32_t type, const void *result) { struct impl *impl = data; - struct pw_port *port = impl->this.output; + struct pw_impl_port *port = impl->this.output; pw_log_trace(NAME" %p: output port %p result seq:%d res:%d type:%u", impl, port, seq, res, type); @@ -910,7 +910,7 @@ static const struct pw_node_events output_node_events = { static bool pw_node_can_reach(struct pw_node *output, struct pw_node *input) { - struct pw_port *p; + struct pw_impl_port *p; if (output == input) return true; @@ -934,7 +934,7 @@ static bool pw_node_can_reach(struct pw_node *output, struct pw_node *input) return false; } -static void try_link_controls(struct impl *impl, struct pw_port *output, struct pw_port *input) +static void try_link_controls(struct impl *impl, struct pw_impl_port *output, struct pw_impl_port *input) { struct pw_control *cin, *cout; struct pw_impl_link *this = &impl->this; @@ -963,7 +963,7 @@ static void try_link_controls(struct impl *impl, struct pw_port *output, struct } } -static void try_unlink_controls(struct impl *impl, struct pw_port *output, struct pw_port *input) +static void try_unlink_controls(struct impl *impl, struct pw_impl_port *output, struct pw_impl_port *input) { struct pw_impl_link *this = &impl->this; int res; @@ -983,14 +983,14 @@ static void try_unlink_controls(struct impl *impl, struct pw_port *output, struc static int check_permission(struct pw_context *context, - struct pw_port *output, - struct pw_port *input, + struct pw_impl_port *output, + struct pw_impl_port *input, struct pw_properties *properties) { return 0; } -static void permissions_changed(struct pw_impl_link *this, struct pw_port *other, +static void permissions_changed(struct pw_impl_link *this, struct pw_impl_port *other, struct pw_impl_client *client, uint32_t old, uint32_t new) { uint32_t perm; @@ -1033,8 +1033,8 @@ static const struct pw_global_events input_global_events = { SPA_EXPORT struct pw_impl_link *pw_impl_link_new(struct pw_context *context, - struct pw_port *output, - struct pw_port *input, + struct pw_impl_port *output, + struct pw_impl_port *input, struct spa_pod *format_filter, struct pw_properties *properties, size_t user_data_size) @@ -1094,10 +1094,10 @@ struct pw_impl_link *pw_impl_link_new(struct pw_context *context, impl->format_filter = format_filter; - pw_port_add_listener(input, &impl->input_port_listener, &input_port_events, impl); + pw_impl_port_add_listener(input, &impl->input_port_listener, &input_port_events, impl); pw_node_add_listener(input_node, &impl->input_node_listener, &input_node_events, impl); pw_global_add_listener(input->global, &impl->input_global_listener, &input_global_events, impl); - pw_port_add_listener(output, &impl->output_port_listener, &output_port_events, impl); + pw_impl_port_add_listener(output, &impl->output_port_listener, &output_port_events, impl); pw_node_add_listener(output_node, &impl->output_node_listener, &output_node_events, impl); pw_global_add_listener(output->global, &impl->output_global_listener, &output_global_events, impl); @@ -1115,8 +1115,8 @@ struct pw_impl_link *pw_impl_link_new(struct pw_context *context, impl->io.buffer_id = SPA_ID_INVALID; impl->io.status = SPA_STATUS_NEED_DATA; - pw_port_init_mix(output, &this->rt.out_mix); - pw_port_init_mix(input, &this->rt.in_mix); + pw_impl_port_init_mix(output, &this->rt.out_mix); + pw_impl_port_init_mix(input, &this->rt.in_mix); if ((res = select_io(this)) < 0) goto error_no_io; @@ -1137,8 +1137,8 @@ struct pw_impl_link *pw_impl_link_new(struct pw_context *context, output_node, output->port_id, this->rt.out_mix.port.port_id, input_node, input->port_id, this->rt.in_mix.port.port_id); - pw_port_emit_link_added(output, this); - pw_port_emit_link_added(input, this); + pw_impl_port_emit_link_added(output, this); + pw_impl_port_emit_link_added(input, this); try_link_controls(impl, output, input); @@ -1312,7 +1312,7 @@ void pw_impl_link_add_listener(struct pw_impl_link *link, spa_hook_list_append(&link->listener_list, listener, events, data); } -struct pw_impl_link *pw_impl_link_find(struct pw_port *output_port, struct pw_port *input_port) +struct pw_impl_link *pw_impl_link_find(struct pw_impl_port *output_port, struct pw_impl_port *input_port) { struct pw_impl_link *pl; @@ -1348,13 +1348,13 @@ struct pw_global *pw_impl_link_get_global(struct pw_impl_link *link) } SPA_EXPORT -struct pw_port *pw_impl_link_get_output(struct pw_impl_link *link) +struct pw_impl_port *pw_impl_link_get_output(struct pw_impl_link *link) { return link->output; } SPA_EXPORT -struct pw_port *pw_impl_link_get_input(struct pw_impl_link *link) +struct pw_impl_port *pw_impl_link_get_input(struct pw_impl_link *link) { return link->input; } diff --git a/src/pipewire/impl-link.h b/src/pipewire/impl-link.h index ea0abba2..08869ac5 100644 --- a/src/pipewire/impl-link.h +++ b/src/pipewire/impl-link.h @@ -34,6 +34,7 @@ extern "C" { * PipeWire link object. */ struct pw_impl_link; +struct pw_impl_port; #include <pipewire/impl.h> @@ -71,7 +72,7 @@ struct pw_impl_link_events { enum pw_link_state state, const char *error); /** A port is unlinked */ - void (*port_unlinked) (void *data, struct pw_port *port); + void (*port_unlinked) (void *data, struct pw_impl_port *port); }; @@ -79,8 +80,8 @@ struct pw_impl_link_events { * \return a newly allocated link */ struct pw_impl_link * pw_impl_link_new(struct pw_context *context, /**< the context object */ - struct pw_port *output, /**< an output port */ - struct pw_port *input, /**< an input port */ + struct pw_impl_port *output, /**< an output port */ + struct pw_impl_port *input, /**< an input port */ struct spa_pod *format_filter, /**< an optional format filter */ struct pw_properties *properties /**< extra properties */, size_t user_data_size /**< extra user data size */); @@ -112,13 +113,13 @@ const struct pw_link_info *pw_impl_link_get_info(struct pw_impl_link *link); struct pw_global *pw_impl_link_get_global(struct pw_impl_link *link); /** Get the output port of the link */ -struct pw_port *pw_impl_link_get_output(struct pw_impl_link *link); +struct pw_impl_port *pw_impl_link_get_output(struct pw_impl_link *link); /** Get the input port of the link */ -struct pw_port *pw_impl_link_get_input(struct pw_impl_link *link); +struct pw_impl_port *pw_impl_link_get_input(struct pw_impl_link *link); /** Find the link between 2 ports \memberof pw_impl_link */ -struct pw_impl_link *pw_impl_link_find(struct pw_port *output, struct pw_port *input); +struct pw_impl_link *pw_impl_link_find(struct pw_impl_port *output, struct pw_impl_port *input); #ifdef __cplusplus } diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index 8f4bae74..f4335e30 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -74,7 +74,7 @@ struct resource_data { static void node_deactivate(struct pw_node *this) { - struct pw_port *port; + struct pw_impl_port *port; struct pw_impl_link *link; pw_log_debug(NAME" %p: deactivate", this); @@ -314,7 +314,7 @@ static void node_update_state(struct pw_node *node, enum pw_node_state state, ch static int suspend_node(struct pw_node *this) { int res = 0; - struct pw_port *p; + struct pw_impl_port *p; pw_log_debug(NAME" %p: suspend node state:%s", this, pw_node_state_as_string(this->info.state)); @@ -322,19 +322,19 @@ static int suspend_node(struct pw_node *this) pause_node(this); spa_list_for_each(p, &this->input_ports, link) { - if ((res = pw_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0) + if ((res = pw_impl_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0) pw_log_warn(NAME" %p: error unset format input: %s", this, spa_strerror(res)); /* force CONFIGURE in case of async */ - p->state = PW_PORT_STATE_CONFIGURE; + p->state = PW_IMPL_PORT_STATE_CONFIGURE; } spa_list_for_each(p, &this->output_ports, link) { - if ((res = pw_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0) + if ((res = pw_impl_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0) pw_log_warn(NAME" %p: error unset format output: %s", this, spa_strerror(res)); /* force CONFIGURE in case of async */ - p->state = PW_PORT_STATE_CONFIGURE; + p->state = PW_IMPL_PORT_STATE_CONFIGURE; } res = spa_node_send_command(this->node, @@ -557,7 +557,7 @@ int pw_node_register(struct pw_node *this, struct pw_properties *properties) { struct pw_context *context = this->context; - struct pw_port *port; + struct pw_impl_port *port; const char *keys[] = { PW_KEY_OBJECT_PATH, PW_KEY_MODULE_ID, @@ -613,9 +613,9 @@ int pw_node_register(struct pw_node *this, pw_global_register(this->global); spa_list_for_each(port, &this->input_ports, link) - pw_port_register(port, NULL); + pw_impl_port_register(port, NULL); spa_list_for_each(port, &this->output_ports, link) - pw_port_register(port, NULL); + pw_impl_port_register(port, NULL); pw_context_recalc_graph(context); @@ -844,7 +844,7 @@ static inline int process_node(void *data) { struct pw_node *this = data; struct timespec ts; - struct pw_port *p; + struct pw_impl_port *p; struct pw_node_activation *a = this->rt.activation; struct spa_system *data_system = this->context->data_system; int status; @@ -1150,13 +1150,13 @@ static void node_port_info(void *data, enum spa_direction direction, uint32_t po const struct spa_port_info *info) { struct pw_node *node = data; - struct pw_port *port = pw_node_find_port(node, direction, port_id); + struct pw_impl_port *port = pw_node_find_port(node, direction, port_id); if (info == NULL) { if (port) { pw_log_debug(NAME" %p: %s port %d removed", node, pw_direction_as_string(direction), port_id); - pw_port_destroy(port); + pw_impl_port_destroy(port); } else { pw_log_warn(NAME" %p: %s port %d unknown", node, pw_direction_as_string(direction), port_id); @@ -1164,19 +1164,19 @@ static void node_port_info(void *data, enum spa_direction direction, uint32_t po } else if (port) { pw_log_debug(NAME" %p: %s port %d changed", node, pw_direction_as_string(direction), port_id); - pw_port_update_info(port, info); + pw_impl_port_update_info(port, info); } else { int res; pw_log_debug(NAME" %p: %s port %d added", node, pw_direction_as_string(direction), port_id); - if ((port = pw_port_new(direction, port_id, info, + if ((port = pw_impl_port_new(direction, port_id, info, node->port_user_data_size))) { - if ((res = pw_port_add(port, node)) < 0) { + if ((res = pw_impl_port_add(port, node)) < 0) { pw_log_error(NAME" %p: can't add port %p: %d, %s", node, port, res, spa_strerror(res)); - pw_port_destroy(port); + pw_impl_port_destroy(port); } } } @@ -1307,7 +1307,7 @@ static int node_ready(void *data, int status) struct pw_node *node = data, *reposition_node = NULL; struct pw_node *driver = node->driver_node; struct pw_node_target *t; - struct pw_port *p; + struct pw_impl_port *p; pw_log_trace_fp(NAME" %p: ready driver:%d exported:%d %p status:%d", node, node->driver, node->exported, driver, status); @@ -1378,7 +1378,7 @@ static int node_ready(void *data, int status) static int node_reuse_buffer(void *data, uint32_t port_id, uint32_t buffer_id) { struct pw_node *node = data; - struct pw_port *p; + struct pw_impl_port *p; spa_list_for_each(p, &node->rt.input_mix, rt.node_link) { if (p->port_id != port_id) @@ -1476,7 +1476,7 @@ SPA_EXPORT void pw_node_destroy(struct pw_node *node) { struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this); - struct pw_port *port; + struct pw_impl_port *port; struct pw_node *slave; node->active = false; @@ -1510,15 +1510,15 @@ void pw_node_destroy(struct pw_node *node) pw_log_debug(NAME" %p: unlink ports", node); spa_list_for_each(port, &node->input_ports, link) - pw_port_unlink(port); + pw_impl_port_unlink(port); spa_list_for_each(port, &node->output_ports, link) - pw_port_unlink(port); + pw_impl_port_unlink(port); pw_log_debug(NAME" %p: destroy ports", node); spa_list_consume(port, &node->input_ports, link) - pw_port_destroy(port); + pw_impl_port_destroy(port); spa_list_consume(port, &node->output_ports, link) - pw_port_destroy(port); + pw_impl_port_destroy(port); if (node->global) { spa_hook_remove(&node->global_listener); @@ -1548,11 +1548,11 @@ void pw_node_destroy(struct pw_node *node) SPA_EXPORT int pw_node_for_each_port(struct pw_node *node, enum pw_direction direction, - int (*callback) (void *data, struct pw_port *port), + int (*callback) (void *data, struct pw_impl_port *port), void *data) { struct spa_list *ports; - struct pw_port *p, *t; + struct pw_impl_port *p, *t; int res; if (direction == PW_DIRECTION_INPUT) @@ -1635,10 +1635,10 @@ int pw_node_set_param(struct pw_node *node, } SPA_EXPORT -struct pw_port * +struct pw_impl_port * pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t port_id) { - struct pw_port *port, *p; + struct pw_impl_port *port, *p; struct pw_map *portmap; struct spa_list *ports; @@ -1661,7 +1661,7 @@ pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t po break; } /* We can use this port if it can multiplex */ - if (SPA_FLAG_IS_SET(p->mix_flags, PW_PORT_MIX_FLAG_MULTI)) + if (SPA_FLAG_IS_SET(p->mix_flags, PW_IMPL_PORT_MIX_FLAG_MULTI)) port = p; } } @@ -1730,7 +1730,7 @@ static void on_state_complete(void *obj, void *data, int res, uint32_t seq) static void node_activate(struct pw_node *this) { - struct pw_port *port; + struct pw_impl_port *port; pw_log_debug(NAME" %p: activate", this); spa_list_for_each(port, &this->input_ports, link) { diff --git a/src/pipewire/impl-node.h b/src/pipewire/impl-node.h index 433a59bd..b192166c 100644 --- a/src/pipewire/impl-node.h +++ b/src/pipewire/impl-node.h @@ -42,6 +42,7 @@ extern "C" { * PipeWire node class. */ struct pw_node; +struct pw_impl_port; #include <spa/node/node.h> #include <spa/node/event.h> @@ -61,16 +62,16 @@ struct pw_node_events { void (*initialized) (void *data); /** a port is being initialized on the node */ - void (*port_init) (void *data, struct pw_port *port); + void (*port_init) (void *data, struct pw_impl_port *port); /** a port was added */ - void (*port_added) (void *data, struct pw_port *port); + void (*port_added) (void *data, struct pw_impl_port *port); /** a port was removed */ - void (*port_removed) (void *data, struct pw_port *port); + void (*port_removed) (void *data, struct pw_impl_port *port); /** the node info changed */ void (*info_changed) (void *data, const struct pw_node_info *info); /** a port on the node changed info */ - void (*port_info_changed) (void *data, struct pw_port *port, + void (*port_info_changed) (void *data, struct pw_impl_port *port, const struct pw_port_info *info); /** the node active state changed */ void (*active_changed) (void *data, bool active); @@ -145,7 +146,7 @@ void pw_node_add_listener(struct pw_node *node, * items are iterated. */ int pw_node_for_each_port(struct pw_node *node, enum pw_direction direction, - int (*callback) (void *data, struct pw_port *port), + int (*callback) (void *data, struct pw_impl_port *port), void *data); int pw_node_for_each_param(struct pw_node *node, @@ -159,7 +160,7 @@ int pw_node_for_each_param(struct pw_node *node, /** Find the port with direction and port_id or NULL when not found. Passing * SPA_ID_INVALID for port_id will return any port, preferably an unlinked one. */ -struct pw_port * +struct pw_impl_port * pw_node_find_port(struct pw_node *node, enum pw_direction direction, uint32_t port_id); /** Get a free unused port_id from the node */ diff --git a/src/pipewire/impl-port.c b/src/pipewire/impl-port.c index 417144b2..bc04e252 100644 --- a/src/pipewire/impl-port.c +++ b/src/pipewire/impl-port.c @@ -39,7 +39,7 @@ /** \cond */ struct impl { - struct pw_port this; + struct pw_impl_port this; struct spa_node mix_node; /**< mix node implementation */ }; @@ -48,7 +48,7 @@ struct impl { #define pw_port_resource_param(r,...) pw_port_resource(r,param,0,__VA_ARGS__) struct resource_data { - struct pw_port *port; + struct pw_impl_port *port; struct pw_resource *resource; struct spa_hook resource_listener; @@ -60,14 +60,14 @@ struct resource_data { /** \endcond */ -static void emit_info_changed(struct pw_port *port) +static void emit_info_changed(struct pw_impl_port *port) { struct pw_resource *resource; if (port->info.change_mask == 0) return; - pw_port_emit_info_changed(port, &port->info); + pw_impl_port_emit_info_changed(port, &port->info); if (port->node) pw_node_emit_port_info_changed(port->node, port, &port->info); @@ -78,29 +78,29 @@ static void emit_info_changed(struct pw_port *port) port->info.change_mask = 0; } -static const char *port_state_as_string(enum pw_port_state state) +static const char *port_state_as_string(enum pw_impl_port_state state) { switch (state) { - case PW_PORT_STATE_ERROR: + case PW_IMPL_PORT_STATE_ERROR: return "error"; - case PW_PORT_STATE_INIT: + case PW_IMPL_PORT_STATE_INIT: return "init"; - case PW_PORT_STATE_CONFIGURE: + case PW_IMPL_PORT_STATE_CONFIGURE: return "configure"; - case PW_PORT_STATE_READY: + case PW_IMPL_PORT_STATE_READY: return "ready"; - case PW_PORT_STATE_PAUSED: + case PW_IMPL_PORT_STATE_PAUSED: return "paused"; } return "invalid-state"; } -void pw_port_update_state(struct pw_port *port, enum pw_port_state state, char *error) +void pw_impl_port_update_state(struct pw_impl_port *port, enum pw_impl_port_state state, char *error) { - enum pw_port_state old = port->state; + enum pw_impl_port_state old = port->state; if (old != state) { - pw_log(state == PW_PORT_STATE_ERROR ? + pw_log(state == PW_IMPL_PORT_STATE_ERROR ? SPA_LOG_LEVEL_ERROR : SPA_LOG_LEVEL_DEBUG, NAME" %p: state %s -> %s (%s)", port, port_state_as_string(old), port_state_as_string(state), error); @@ -108,15 +108,15 @@ void pw_port_update_state(struct pw_port *port, enum pw_port_state state, char * port->state = state; free((void*)port->error); port->error = error; - pw_port_emit_state_changed(port, old, state, error); + pw_impl_port_emit_state_changed(port, old, state, error); } } static int tee_process(void *object) { struct impl *impl = object; - struct pw_port *this = &impl->this; - struct pw_port_mix *mix; + struct pw_impl_port *this = &impl->this; + struct pw_impl_port_mix *mix; struct spa_io_buffers *io = &this->rt.io; pw_log_trace_fp(NAME" %p: tee input %d %d", this, io->status, io->buffer_id); @@ -133,7 +133,7 @@ static int tee_process(void *object) static int tee_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id) { struct impl *impl = object; - struct pw_port *this = &impl->this; + struct pw_impl_port *this = &impl->this; pw_log_trace_fp(NAME" %p: tee reuse buffer %d %d", this, port_id, buffer_id); spa_node_port_reuse_buffer(this->node->node, this->port_id, buffer_id); @@ -150,11 +150,11 @@ static const struct spa_node_methods schedule_tee_node = { static int schedule_mix_input(void *object) { struct impl *impl = object; - struct pw_port *this = &impl->this; + struct pw_impl_port *this = &impl->this; struct spa_io_buffers *io = &this->rt.io; - struct pw_port_mix *mix; + struct pw_impl_port_mix *mix; - if (PW_PORT_IS_CONTROL(this)) + if (PW_IMPL_PORT_IS_CONTROL(this)) return SPA_STATUS_HAVE_DATA | SPA_STATUS_NEED_DATA; spa_list_for_each(mix, &this->rt.mix_list, rt_link) { @@ -170,8 +170,8 @@ static int schedule_mix_input(void *object) static int schedule_mix_reuse_buffer(void *object, uint32_t port_id, uint32_t buffer_id) { struct impl *impl = object; - struct pw_port *this = &impl->this; - struct pw_port_mix *mix; + struct pw_impl_port *this = &impl->this; + struct pw_impl_port_mix *mix; spa_list_for_each(mix, &this->rt.mix_list, rt_link) { pw_log_trace_fp(NAME" %p: reuse buffer %d %d", this, port_id, buffer_id); @@ -187,7 +187,7 @@ static const struct spa_node_methods schedule_mix_node = { }; SPA_EXPORT -int pw_port_init_mix(struct pw_port *port, struct pw_port_mix *mix) +int pw_impl_port_init_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix) { uint32_t port_id; int res = 0; @@ -205,7 +205,7 @@ int pw_port_init_mix(struct pw_port *port, struct pw_port_mix *mix) spa_node_add_port(port->mix, port->direction, port_id, NULL); - res = pw_port_call_init_mix(port, mix); + res = pw_impl_port_call_init_mix(port, mix); /* set the same format on the mixer as on the port if any */ { @@ -232,7 +232,7 @@ int pw_port_init_mix(struct pw_port *port, struct pw_port_mix *mix) } SPA_EXPORT -int pw_port_release_mix(struct pw_port *port, struct pw_port_mix *mix) +int pw_impl_port_release_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix) { int res = 0; uint32_t port_id = mix->port.port_id; @@ -241,7 +241,7 @@ int pw_port_release_mix(struct pw_port *port, struct pw_port_mix *mix) spa_list_remove(&mix->link); port->n_mix--; - res = pw_port_call_release_mix(port, mix); + res = pw_impl_port_call_release_mix(port, mix); spa_node_remove_port(port->mix, port->direction, port_id); @@ -251,7 +251,7 @@ int pw_port_release_mix(struct pw_port *port, struct pw_port_mix *mix) return res; } -static int update_properties(struct pw_port *port, const struct spa_dict *dict) +static int update_properties(struct pw_impl_port *port, const struct spa_dict *dict) { int changed; @@ -280,7 +280,7 @@ static int resource_is_subscribed(struct pw_resource *resource, uint32_t id) static int notify_param(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param) { - struct pw_port *port = data; + struct pw_impl_port *port = data; struct pw_resource *resource; spa_list_for_each(resource, &port->global->resource_list, link) { @@ -293,7 +293,7 @@ static int notify_param(void *data, int seq, uint32_t id, return 0; } -static void emit_params(struct pw_port *port, uint32_t *changed_ids, uint32_t n_changed_ids) +static void emit_params(struct pw_impl_port *port, uint32_t *changed_ids, uint32_t n_changed_ids) { uint32_t i; int res; @@ -315,14 +315,14 @@ static void emit_params(struct pw_port *port, uint32_t *changed_ids, uint32_t n_ if (!subscribed) continue; - if ((res = pw_port_for_each_param(port, 1, changed_ids[i], 0, UINT32_MAX, + if ((res = pw_impl_port_for_each_param(port, 1, changed_ids[i], 0, UINT32_MAX, NULL, notify_param, port)) < 0) { pw_log_error(NAME" %p: error %d (%s)", port, res, spa_strerror(res)); } } } -static void update_info(struct pw_port *port, const struct spa_port_info *info) +static void update_info(struct pw_impl_port *port, const struct spa_port_info *info) { uint32_t changed_ids[MAX_PARAMS], n_changed_ids = 0; @@ -354,13 +354,13 @@ static void update_info(struct pw_port *port, const struct spa_port_info *info) } SPA_EXPORT -struct pw_port *pw_port_new(enum pw_direction direction, +struct pw_impl_port *pw_impl_port_new(enum pw_direction direction, uint32_t port_id, const struct spa_port_info *info, size_t user_data_size) { struct impl *impl; - struct pw_port *this; + struct pw_impl_port *this; struct pw_properties *properties; const struct spa_node_methods *mix_methods; int res; @@ -394,7 +394,7 @@ struct pw_port *pw_port_new(enum pw_direction direction, this->direction = direction; this->port_id = port_id; this->properties = properties; - this->state = PW_PORT_STATE_INIT; + this->state = PW_IMPL_PORT_STATE_INIT; this->rt.io = SPA_IO_BUFFERS_INIT; if (user_data_size > 0) @@ -423,7 +423,7 @@ struct pw_port *pw_port_new(enum pw_direction direction, SPA_VERSION_NODE, mix_methods, impl); - pw_port_set_mix(this, NULL, 0); + pw_impl_port_set_mix(this, NULL, 0); pw_map_init(&this->mix_port_map, 64, 64); @@ -442,10 +442,10 @@ error_no_mem: } SPA_EXPORT -int pw_port_set_mix(struct pw_port *port, struct spa_node *node, uint32_t flags) +int pw_impl_port_set_mix(struct pw_impl_port *port, struct spa_node *node, uint32_t flags) { struct impl *impl = SPA_CONTAINER_OF(port, struct impl, this); - struct pw_port_mix *mix; + struct pw_impl_port_mix *mix; if (node == NULL) { node = &impl->mix_node; @@ -482,7 +482,7 @@ int pw_port_set_mix(struct pw_port *port, struct spa_node *node, uint32_t flags) return 0; } -static int setup_mixer(struct pw_port *port, const struct spa_pod *param) +static int setup_mixer(struct pw_impl_port *port, const struct spa_pod *param) { uint32_t media_type, media_subtype; int res; @@ -547,34 +547,34 @@ static int setup_mixer(struct pw_port *port, const struct spa_pod *param) } pw_log_debug("mix node %p", iface); - pw_port_set_mix(port, (struct spa_node*)iface, - PW_PORT_MIX_FLAG_MULTI | - PW_PORT_MIX_FLAG_NEGOTIATE); + pw_impl_port_set_mix(port, (struct spa_node*)iface, + PW_IMPL_PORT_MIX_FLAG_MULTI | + PW_IMPL_PORT_MIX_FLAG_NEGOTIATE); port->mix_handle = handle; return 0; } SPA_EXPORT -enum pw_direction pw_port_get_direction(struct pw_port *port) +enum pw_direction pw_impl_port_get_direction(struct pw_impl_port *port) { return port->direction; } SPA_EXPORT -uint32_t pw_port_get_id(struct pw_port *port) +uint32_t pw_impl_port_get_id(struct pw_impl_port *port) { return port->port_id; } SPA_EXPORT -const struct pw_properties *pw_port_get_properties(struct pw_port *port) +const struct pw_properties *pw_impl_port_get_properties(struct pw_impl_port *port) { return port->properties; } SPA_EXPORT -int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict) +int pw_impl_port_update_properties(struct pw_impl_port *port, const struct spa_dict *dict) { int changed = update_properties(port, dict); @@ -583,29 +583,29 @@ int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict) return changed; } -void pw_port_update_info(struct pw_port *port, const struct spa_port_info *info) +void pw_impl_port_update_info(struct pw_impl_port *port, const struct spa_port_info *info) { update_info(port, info); emit_info_changed(port); } SPA_EXPORT -struct pw_node *pw_port_get_node(struct pw_port *port) +struct pw_node *pw_impl_port_get_node(struct pw_impl_port *port) { return port->node; } SPA_EXPORT -void pw_port_add_listener(struct pw_port *port, +void pw_impl_port_add_listener(struct pw_impl_port *port, struct spa_hook *listener, - const struct pw_port_events *events, + const struct pw_impl_port_events *events, void *data) { spa_hook_list_append(&port->listener_list, listener, events, data); } SPA_EXPORT -void * pw_port_get_user_data(struct pw_port *port) +void * pw_impl_port_get_user_data(struct pw_impl_port *port) { return port->user_data; } @@ -613,7 +613,7 @@ void * pw_port_get_user_data(struct pw_port *port) static int do_add_port(struct spa_loop *loop, bool async, uint32_t seq, const void *data, size_t size, void *user_data) { - struct pw_port *this = user_data; + struct pw_impl_port *this = user_data; if (this->direction == PW_DIRECTION_INPUT) spa_list_append(&this->node->rt.input_mix, &this->rt.node_link); @@ -626,7 +626,7 @@ static int do_add_port(struct spa_loop *loop, static int check_param_io(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param) { - struct pw_port *port = data; + struct pw_impl_port *port = data; struct pw_node *node = port->node; uint32_t pid, psize; @@ -643,10 +643,10 @@ static int check_param_io(void *data, int seq, uint32_t id, case SPA_IO_Control: case SPA_IO_Notify: pw_control_new(node->context, port, pid, psize, 0); - SPA_FLAG_SET(port->flags, PW_PORT_FLAG_CONTROL); + SPA_FLAG_SET(port->flags, PW_IMPL_PORT_FLAG_CONTROL); break; case SPA_IO_Buffers: - SPA_FLAG_SET(port->flags, PW_PORT_FLAG_BUFFERS); + SPA_FLAG_SET(port->flags, PW_IMPL_PORT_FLAG_BUFFERS); break; default: break; @@ -681,14 +681,14 @@ static int port_enum_params(void *object, int seq, uint32_t id, uint32_t index, { struct pw_resource *resource = object; struct resource_data *data = pw_resource_get_user_data(resource); - struct pw_port *port = data->port; + struct pw_impl_port *port = data->port; int res; pw_log_debug(NAME" %p: resource %p enum params %d %s %u %u", port, resource, seq, spa_debug_type_find_name(spa_type_param, id), index, num); - if ((res = pw_port_for_each_param(port, seq, id, index, num, filter, + if ((res = pw_impl_port_for_each_param(port, seq, id, index, num, filter, reply_param, data)) < 0) pw_core_resource_error(resource->client->core_resource, resource->id, seq, res, spa_strerror(res)); @@ -723,7 +723,7 @@ static int global_bind(void *_data, struct pw_impl_client *client, uint32_t permissions, uint32_t version, uint32_t id) { - struct pw_port *this = _data; + struct pw_impl_port *this = _data; struct pw_global *global = this->global; struct pw_resource *resource; struct resource_data *data; @@ -763,10 +763,10 @@ error_resource: static void global_destroy(void *object) { - struct pw_port *port = object; + struct pw_impl_port *port = object; spa_hook_remove(&port->global_listener); port->global = NULL; - pw_port_destroy(port); + pw_impl_port_destroy(port); } static const struct pw_global_events global_events = { @@ -774,7 +774,7 @@ static const struct pw_global_events global_events = { .destroy = global_destroy, }; -int pw_port_register(struct pw_port *port, +int pw_impl_port_register(struct pw_impl_port *port, struct pw_properties *properties) { struct pw_node *node = port->node; @@ -817,18 +817,18 @@ int pw_port_register(struct pw_port *port, pw_properties_setf(port->properties, PW_KEY_OBJECT_ID, "%d", port->info.id); port->info.props = &port->properties->dict; - pw_port_emit_initialized(port); + pw_impl_port_emit_initialized(port); return pw_global_register(port->global); } SPA_EXPORT -int pw_port_add(struct pw_port *port, struct pw_node *node) +int pw_impl_port_add(struct pw_impl_port *port, struct pw_node *node) { uint32_t port_id = port->port_id; struct spa_list *ports; struct pw_map *portmap; - struct pw_port *find; + struct pw_impl_port *find; bool control; const char *str, *dir; int res; @@ -855,9 +855,9 @@ int pw_port_add(struct pw_port *port, struct pw_node *node) pw_node_emit_port_init(node, port); - pw_port_for_each_param(port, 0, SPA_PARAM_IO, 0, 0, NULL, check_param_io, port); + pw_impl_port_for_each_param(port, 0, SPA_PARAM_IO, 0, 0, NULL, check_param_io, port); - control = PW_PORT_IS_CONTROL(port); + control = PW_IMPL_PORT_IS_CONTROL(port); if (control) { dir = port->direction == PW_DIRECTION_INPUT ? "control" : "notify"; pw_properties_set(port->properties, PW_KEY_PORT_CONTROL, "1"); @@ -906,12 +906,12 @@ int pw_port_add(struct pw_port *port, struct pw_node *node) } if (node->global) - pw_port_register(port, NULL); + pw_impl_port_register(port, NULL); pw_loop_invoke(node->data_loop, do_add_port, SPA_ID_INVALID, NULL, 0, false, port); - if (port->state <= PW_PORT_STATE_INIT) - pw_port_update_state(port, PW_PORT_STATE_CONFIGURE, NULL); + if (port->state <= PW_IMPL_PORT_STATE_INIT) + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_CONFIGURE, NULL); pw_node_emit_port_added(node, port); emit_info_changed(port); @@ -925,22 +925,22 @@ static int do_destroy_link(void *data, struct pw_impl_link *link) return 0; } -void pw_port_unlink(struct pw_port *port) +void pw_impl_port_unlink(struct pw_impl_port *port) { - pw_port_for_each_link(port, do_destroy_link, port); + pw_impl_port_for_each_link(port, do_destroy_link, port); } static int do_remove_port(struct spa_loop *loop, bool async, uint32_t seq, const void *data, size_t size, void *user_data) { - struct pw_port *this = user_data; + struct pw_impl_port *this = user_data; spa_list_remove(&this->rt.node_link); return 0; } -static void pw_port_remove(struct pw_port *port) +static void pw_impl_port_remove(struct pw_impl_port *port) { struct pw_node *node = port->node; int res; @@ -953,7 +953,7 @@ static void pw_port_remove(struct pw_port *port) pw_loop_invoke(port->node->data_loop, do_remove_port, SPA_ID_INVALID, NULL, 0, true, port); - if (SPA_FLAG_IS_SET(port->flags, PW_PORT_FLAG_TO_REMOVE)) { + if (SPA_FLAG_IS_SET(port->flags, PW_IMPL_PORT_FLAG_TO_REMOVE)) { if ((res = spa_node_remove_port(node->node, port->direction, port->port_id)) < 0) pw_log_warn(NAME" %p: can't remove: %s", port, spa_strerror(res)); } @@ -966,20 +966,20 @@ static void pw_port_remove(struct pw_port *port) node->info.n_output_ports--; } - pw_port_set_mix(port, NULL, 0); + pw_impl_port_set_mix(port, NULL, 0); spa_list_remove(&port->link); pw_node_emit_port_removed(node, port); port->node = NULL; } -void pw_port_destroy(struct pw_port *port) +void pw_impl_port_destroy(struct pw_impl_port *port) { struct pw_control *control; pw_log_debug(NAME" %p: destroy", port); - pw_port_emit_destroy(port); + pw_impl_port_emit_destroy(port); pw_log_debug(NAME" %p: control destroy", port); spa_list_consume(control, &port->control_list[0], port_link) @@ -987,7 +987,7 @@ void pw_port_destroy(struct pw_port *port) spa_list_consume(control, &port->control_list[1], port_link) pw_control_destroy(control); - pw_port_remove(port); + pw_impl_port_remove(port); if (port->global) { spa_hook_remove(&port->global_listener); @@ -995,7 +995,7 @@ void pw_port_destroy(struct pw_port *port) } pw_log_debug(NAME" %p: free", port); - pw_port_emit_free(port); + pw_impl_port_emit_free(port); pw_buffers_clear(&port->buffers); pw_buffers_clear(&port->mix_buffers); @@ -1032,7 +1032,7 @@ static void result_port_params(void *data, int seq, int res, uint32_t type, cons } } -int pw_port_for_each_param(struct pw_port *port, +int pw_impl_port_for_each_param(struct pw_impl_port *port, int seq, uint32_t param_id, uint32_t index, uint32_t max, @@ -1071,8 +1071,8 @@ int pw_port_for_each_param(struct pw_port *port, } struct param_filter { - struct pw_port *in_port; - struct pw_port *out_port; + struct pw_impl_port *in_port; + struct pw_impl_port *out_port; int seq; uint32_t in_param_id; uint32_t out_param_id; @@ -1086,11 +1086,11 @@ static int do_filter(void *data, int seq, uint32_t id, uint32_t index, uint32_t { struct param_filter *f = data; f->n_params++; - return pw_port_for_each_param(f->out_port, seq, f->out_param_id, 0, 0, param, f->callback, f->data); + return pw_impl_port_for_each_param(f->out_port, seq, f->out_param_id, 0, 0, param, f->callback, f->data); } -int pw_port_for_each_filtered_param(struct pw_port *in_port, - struct pw_port *out_port, +int pw_impl_port_for_each_filtered_param(struct pw_impl_port *in_port, + struct pw_impl_port *out_port, int seq, uint32_t in_param_id, uint32_t out_param_id, @@ -1103,7 +1103,7 @@ int pw_port_for_each_filtered_param(struct pw_port *in_port, int res; struct param_filter fd = { in_port, out_port, seq, in_param_id, out_param_id, callback, data, 0 }; - if ((res = pw_port_for_each_param(in_port, seq, in_param_id, 0, 0, filter, do_filter, &fd)) < 0) + if ((res = pw_impl_port_for_each_param(in_port, seq, in_param_id, 0, 0, filter, do_filter, &fd)) < 0) return res; if (fd.n_params == 0) @@ -1112,7 +1112,7 @@ int pw_port_for_each_filtered_param(struct pw_port *in_port, return res; } -int pw_port_for_each_link(struct pw_port *port, +int pw_impl_port_for_each_link(struct pw_impl_port *port, int (*callback) (void *data, struct pw_impl_link *link), void *data) { @@ -1132,13 +1132,13 @@ int pw_port_for_each_link(struct pw_port *port, } SPA_EXPORT -int pw_port_is_linked(struct pw_port *port) +int pw_impl_port_is_linked(struct pw_impl_port *port) { return spa_list_is_empty(&port->links) ? 0 : 1; } SPA_EXPORT -int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags, +int pw_impl_port_set_param(struct pw_impl_port *port, uint32_t id, uint32_t flags, const struct spa_pod *param) { int res; @@ -1157,11 +1157,11 @@ int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags, /* set the parameters on all ports of the mixer node if possible */ if (res >= 0) { - struct pw_port_mix *mix; + struct pw_impl_port_mix *mix; if (port->direction == PW_DIRECTION_INPUT && id == SPA_PARAM_Format && param != NULL && - !SPA_FLAG_IS_SET(port->flags, PW_PORT_FLAG_NO_MIXER)) { + !SPA_FLAG_IS_SET(port->flags, PW_IMPL_PORT_FLAG_NO_MIXER)) { setup_mixer(port, param); } @@ -1183,25 +1183,25 @@ int pw_port_set_param(struct pw_port *port, uint32_t id, uint32_t flags, pw_buffers_clear(&port->mix_buffers); if (param == NULL || res < 0) { - pw_port_update_state(port, PW_PORT_STATE_CONFIGURE, NULL); + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_CONFIGURE, NULL); } else if (!SPA_RESULT_IS_ASYNC(res)) { - pw_port_update_state(port, PW_PORT_STATE_READY, NULL); + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_READY, NULL); } } return res; } -static int negotiate_mixer_buffers(struct pw_port *port, uint32_t flags, +static int negotiate_mixer_buffers(struct pw_impl_port *port, uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { int res; struct pw_node *node = port->node; - if (SPA_FLAG_IS_SET(port->mix_flags, PW_PORT_MIX_FLAG_MIX_ONLY)) + if (SPA_FLAG_IS_SET(port->mix_flags, PW_IMPL_PORT_MIX_FLAG_MIX_ONLY)) return 0; - if (SPA_FLAG_IS_SET(port->mix_flags, PW_PORT_MIX_FLAG_NEGOTIATE)) { + if (SPA_FLAG_IS_SET(port->mix_flags, PW_IMPL_PORT_MIX_FLAG_NEGOTIATE)) { int alloc_flags; /* try dynamic data */ @@ -1242,7 +1242,7 @@ static int negotiate_mixer_buffers(struct pw_port *port, uint32_t flags, SPA_EXPORT -int pw_port_use_buffers(struct pw_port *port, struct pw_port_mix *mix, uint32_t flags, +int pw_impl_port_use_buffers(struct pw_impl_port *port, struct pw_impl_port_mix *mix, uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers) { int res = 0, res2; @@ -1251,34 +1251,34 @@ int pw_port_use_buffers(struct pw_port *port, struct pw_port_mix *mix, uint32_t port->direction, port->port_id, mix->id, n_buffers, flags, port->state, port->n_mix); - if (n_buffers == 0 && port->state <= PW_PORT_STATE_READY) + if (n_buffers == 0 && port->state <= PW_IMPL_PORT_STATE_READY) return 0; - if (n_buffers > 0 && port->state < PW_PORT_STATE_READY) + if (n_buffers > 0 && port->state < PW_IMPL_PORT_STATE_READY) return -EIO; if (n_buffers == 0) { if (port->n_mix == 1) - pw_port_update_state(port, PW_PORT_STATE_READY, NULL); + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_READY, NULL); } /* first negotiate with the node, this makes it possible to let the * node allocate buffer memory if needed */ - if (port->state == PW_PORT_STATE_READY) { + if (port->state == PW_IMPL_PORT_STATE_READY) { res = negotiate_mixer_buffers(port, flags, buffers, n_buffers); if (res < 0) { pw_log_error(NAME" %p: negotiate buffers on node: %d (%s)", port, res, spa_strerror(res)); - pw_port_update_state(port, PW_PORT_STATE_ERROR, + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_ERROR, "can't negotiate buffers on port"); } else if (n_buffers > 0 && !SPA_RESULT_IS_ASYNC(res)) { - pw_port_update_state(port, PW_PORT_STATE_PAUSED, NULL); + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_PAUSED, NULL); } } /* then use the buffers on the mixer */ - if (!SPA_FLAG_IS_SET(port->mix_flags, PW_PORT_MIX_FLAG_MIX_ONLY)) + if (!SPA_FLAG_IS_SET(port->mix_flags, PW_IMPL_PORT_MIX_FLAG_MIX_ONLY)) flags &= ~SPA_NODE_BUFFERS_FLAG_ALLOC; res2 = spa_node_port_use_buffers(port->mix, diff --git a/src/pipewire/impl-port.h b/src/pipewire/impl-port.h index 5547fd06..386d29cb 100644 --- a/src/pipewire/impl-port.h +++ b/src/pipewire/impl-port.h @@ -22,8 +22,8 @@ * DEALINGS IN THE SOFTWARE. */ -#ifndef PIPEWIRE_PORT_H -#define PIPEWIRE_PORT_H +#ifndef PIPEWIRE_IMPL_PORT_H +#define PIPEWIRE_IMPL_PORT_H #ifdef __cplusplus extern "C" { @@ -37,27 +37,27 @@ extern "C" { * * A port can be used to link two nodes. */ -/** \class pw_port +/** \class pw_impl_port * * The port object */ -struct pw_port; +struct pw_impl_port; struct pw_impl_link; struct pw_control; #include <pipewire/impl.h> -enum pw_port_state { - PW_PORT_STATE_ERROR = -1, /**< the port is in error */ - PW_PORT_STATE_INIT = 0, /**< the port is being created */ - PW_PORT_STATE_CONFIGURE = 1, /**< the port is ready for format negotiation */ - PW_PORT_STATE_READY = 2, /**< the port is ready for buffer allocation */ - PW_PORT_STATE_PAUSED = 3, /**< the port is paused */ +enum pw_impl_port_state { + PW_IMPL_PORT_STATE_ERROR = -1, /**< the port is in error */ + PW_IMPL_PORT_STATE_INIT = 0, /**< the port is being created */ + PW_IMPL_PORT_STATE_CONFIGURE = 1, /**< the port is ready for format negotiation */ + PW_IMPL_PORT_STATE_READY = 2, /**< the port is ready for buffer allocation */ + PW_IMPL_PORT_STATE_PAUSED = 3, /**< the port is paused */ }; -/** Port events, use \ref pw_port_add_listener */ -struct pw_port_events { -#define PW_VERSION_PORT_EVENTS 0 +/** Port events, use \ref pw_impl_port_add_listener */ +struct pw_impl_port_events { +#define PW_VERSION_IMPL_PORT_EVENTS 0 uint32_t version; /** The port is destroyed */ @@ -79,8 +79,8 @@ struct pw_port_events { void (*link_removed) (void *data, struct pw_impl_link *link); /** the state of the port changed */ - void (*state_changed) (void *data, enum pw_port_state old, - enum pw_port_state state, const char *error); + void (*state_changed) (void *data, enum pw_impl_port_state old, + enum pw_impl_port_state state, const char *error); /** a control was added to the port */ void (*control_added) (void *data, struct pw_control *control); @@ -90,28 +90,28 @@ struct pw_port_events { }; /** Get the port direction */ -enum pw_direction pw_port_get_direction(struct pw_port *port); +enum pw_direction pw_impl_port_get_direction(struct pw_impl_port *port); /** Get the port properties */ -const struct pw_properties *pw_port_get_properties(struct pw_port *port); +const struct pw_properties *pw_impl_port_get_properties(struct pw_impl_port *port); /** Update the port properties */ -int pw_port_update_properties(struct pw_port *port, const struct spa_dict *dict); +int pw_impl_port_update_properties(struct pw_impl_port *port, const struct spa_dict *dict); /** Get the port id */ -uint32_t pw_port_get_id(struct pw_port *port); +uint32_t pw_impl_port_get_id(struct pw_impl_port *port); /** Get the port parent node or NULL when not yet set */ -struct pw_node *pw_port_get_node(struct pw_port *port); +struct pw_node *pw_impl_port_get_node(struct pw_impl_port *port); /** Add an event listener on the port */ -void pw_port_add_listener(struct pw_port *port, +void pw_impl_port_add_listener(struct pw_impl_port *port, struct spa_hook *listener, - const struct pw_port_events *events, + const struct pw_impl_port_events *events, void *data); #ifdef __cplusplus } #endif -#endif /* PIPEWIRE_PORT_H */ +#endif /* PIPEWIRE_IMPL_PORT_H */ diff --git a/src/pipewire/impl.h b/src/pipewire/impl.h index 957cd1db..fce1cac7 100644 --- a/src/pipewire/impl.h +++ b/src/pipewire/impl.h @@ -29,11 +29,11 @@ extern "C" { #endif -struct pw_client; -struct pw_module; +struct pw_impl_client; +struct pw_impl_module; struct pw_global; struct pw_node; -struct pw_port; +struct pw_impl_port; struct pw_resource; #include <pipewire/pipewire.h> diff --git a/src/pipewire/private.h b/src/pipewire/private.h index a794fe52..0e394197 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -510,10 +510,10 @@ struct pw_node { void *user_data; /**< extra user data */ }; -struct pw_port_mix { +struct pw_impl_port_mix { struct spa_list link; struct spa_list rt_link; - struct pw_port *p; + struct pw_impl_port *p; struct { enum spa_direction direction; uint32_t port_id; @@ -523,59 +523,59 @@ struct pw_port_mix { unsigned int have_buffers:1; }; -struct pw_port_implementation { +struct pw_impl_port_implementation { #define PW_VERSION_PORT_IMPLEMENTATION 0 uint32_t version; - int (*init_mix) (void *data, struct pw_port_mix *mix); - int (*release_mix) (void *data, struct pw_port_mix *mix); + int (*init_mix) (void *data, struct pw_impl_port_mix *mix); + int (*release_mix) (void *data, struct pw_impl_port_mix *mix); }; -#define pw_port_call(p,m,v,...) \ -({ \ - int _res = 0; \ - spa_callbacks_call_res(&(p)->impl, \ - struct pw_port_implementation, \ - _res, m, v, ## __VA_ARGS__); \ - _res; \ +#define pw_impl_port_call(p,m,v,...) \ +({ \ + int _res = 0; \ + spa_callbacks_call_res(&(p)->impl, \ + struct pw_impl_port_implementation, \ + _res, m, v, ## __VA_ARGS__); \ + _res; \ }) -#define pw_port_call_init_mix(p,m) pw_port_call(p,init_mix,0,m) -#define pw_port_call_release_mix(p,m) pw_port_call(p,release_mix,0,m) - -#define pw_port_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_port_events, m, v, ##__VA_ARGS__) -#define pw_port_emit_destroy(p) pw_port_emit(p, destroy, 0) -#define pw_port_emit_free(p) pw_port_emit(p, free, 0) -#define pw_port_emit_initialized(p) pw_port_emit(p, initialized, 0) -#define pw_port_emit_info_changed(p,i) pw_port_emit(p, info_changed, 0, i) -#define pw_port_emit_link_added(p,l) pw_port_emit(p, link_added, 0, l) -#define pw_port_emit_link_removed(p,l) pw_port_emit(p, link_removed, 0, l) -#define pw_port_emit_state_changed(p,o,s,e) pw_port_emit(p, state_changed, 0, o, s, e) -#define pw_port_emit_control_added(p,c) pw_port_emit(p, control_added, 0, c) -#define pw_port_emit_control_removed(p,c) pw_port_emit(p, control_removed, 0, c) - -#define PW_PORT_IS_CONTROL(port) SPA_FLAG_MASK(port->flags, \ - PW_PORT_FLAG_BUFFERS|PW_PORT_FLAG_CONTROL,\ - PW_PORT_FLAG_CONTROL) -struct pw_port { +#define pw_impl_port_call_init_mix(p,m) pw_impl_port_call(p,init_mix,0,m) +#define pw_impl_port_call_release_mix(p,m) pw_impl_port_call(p,release_mix,0,m) + +#define pw_impl_port_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_impl_port_events, m, v, ##__VA_ARGS__) +#define pw_impl_port_emit_destroy(p) pw_impl_port_emit(p, destroy, 0) +#define pw_impl_port_emit_free(p) pw_impl_port_emit(p, free, 0) +#define pw_impl_port_emit_initialized(p) pw_impl_port_emit(p, initialized, 0) +#define pw_impl_port_emit_info_changed(p,i) pw_impl_port_emit(p, info_changed, 0, i) +#define pw_impl_port_emit_link_added(p,l) pw_impl_port_emit(p, link_added, 0, l) +#define pw_impl_port_emit_link_removed(p,l) pw_impl_port_emit(p, link_removed, 0, l) +#define pw_impl_port_emit_state_changed(p,o,s,e) pw_impl_port_emit(p, state_changed, 0, o, s, e) +#define pw_impl_port_emit_control_added(p,c) pw_impl_port_emit(p, control_added, 0, c) +#define pw_impl_port_emit_control_removed(p,c) pw_impl_port_emit(p, control_removed, 0, c) + +#define PW_IMPL_PORT_IS_CONTROL(port) SPA_FLAG_MASK(port->flags, \ + PW_IMPL_PORT_FLAG_BUFFERS|PW_IMPL_PORT_FLAG_CONTROL,\ + PW_IMPL_PORT_FLAG_CONTROL) +struct pw_impl_port { struct spa_list link; /**< link in node port_list */ struct pw_node *node; /**< owner node */ struct pw_global *global; /**< global for this port */ struct spa_hook global_listener; -#define PW_PORT_FLAG_TO_REMOVE (1<<0) /**< if the port should be removed from the +#define PW_IMPL_PORT_FLAG_TO_REMOVE (1<<0) /**< if the port should be removed from the * implementation when destroyed */ -#define PW_PORT_FLAG_BUFFERS (1<<1) /**< port has data */ -#define PW_PORT_FLAG_CONTROL (1<<2) /**< port has control */ -#define PW_PORT_FLAG_NO_MIXER (1<<3) /**< don't try to add mixer to port */ +#define PW_IMPL_PORT_FLAG_BUFFERS (1<<1) /**< port has data */ +#define PW_IMPL_PORT_FLAG_CONTROL (1<<2) /**< port has control */ +#define PW_IMPL_PORT_FLAG_NO_MIXER (1<<3) /**< don't try to add mixer to port */ uint32_t flags; uint32_t spa_flags; enum pw_direction direction; /**< port direction */ uint32_t port_id; /**< port id */ - enum pw_port_state state; /**< state of the port */ + enum pw_impl_port_state state; /**< state of the port */ const char *error; /**< error state */ struct pw_properties *properties; /**< properties of the port */ @@ -594,14 +594,14 @@ struct pw_port { struct spa_callbacks impl; struct spa_node *mix; /**< port buffer mix/split */ -#define PW_PORT_MIX_FLAG_MULTI (1<<0) /**< multi input or output */ -#define PW_PORT_MIX_FLAG_MIX_ONLY (1<<1) /**< only negotiate mix ports */ -#define PW_PORT_MIX_FLAG_NEGOTIATE (1<<2) /**< negotiate buffers */ +#define PW_IMPL_PORT_MIX_FLAG_MULTI (1<<0) /**< multi input or output */ +#define PW_IMPL_PORT_MIX_FLAG_MIX_ONLY (1<<1) /**< only negotiate mix ports */ +#define PW_IMPL_PORT_MIX_FLAG_NEGOTIATE (1<<2) /**< negotiate buffers */ uint32_t mix_flags; /**< flags for the mixing */ struct spa_handle *mix_handle; /**< mix plugin handle */ struct pw_buffers mix_buffers; /**< buffers between mixer and node */ - struct spa_list mix_list; /**< list of \ref pw_port_mix */ + struct spa_list mix_list; /**< list of \ref pw_impl_port_mix */ struct pw_map mix_port_map; /**< map from port_id from mixer */ uint32_t n_mix; @@ -645,9 +645,9 @@ struct pw_impl_link { struct spa_io_buffers *io; /**< link io area */ - struct pw_port *output; /**< output port */ + struct pw_impl_port *output; /**< output port */ struct spa_list output_link; /**< link in output port links */ - struct pw_port *input; /**< input port */ + struct pw_impl_port *input; /**< input port */ struct spa_list input_link; /**< link in input port links */ struct spa_hook_list listener_list; @@ -656,8 +656,8 @@ struct pw_impl_link { struct pw_control_link notify; struct { - struct pw_port_mix out_mix; /**< port added to the output mixer */ - struct pw_port_mix in_mix; /**< port added to the input mixer */ + struct pw_impl_port_mix out_mix; /**< port added to the output mixer */ + struct pw_impl_port_mix in_mix; /**< port added to the input mixer */ struct pw_node_target target; /**< target to trigger the input node */ } rt; @@ -859,7 +859,7 @@ struct pw_control { struct spa_list link; /**< link in context control_list */ struct pw_context *context; /**< the context */ - struct pw_port *port; /**< owner port or NULL */ + struct pw_impl_port *port; /**< owner port or NULL */ struct spa_list port_link; /**< link in port control_list */ enum spa_direction direction; /**< the direction */ @@ -875,8 +875,8 @@ struct pw_control { /** Find a good format between 2 ports */ int pw_context_find_format(struct pw_context *context, - struct pw_port *output, - struct pw_port *input, + struct pw_impl_port *output, + struct pw_impl_port *input, struct pw_properties *props, uint32_t n_format_filters, struct spa_pod **format_filters, @@ -885,9 +885,9 @@ int pw_context_find_format(struct pw_context *context, char **error); /** Find a ports compatible with \a other_port and the format filters */ -struct pw_port * +struct pw_impl_port * pw_context_find_port(struct pw_context *context, - struct pw_port *other_port, + struct pw_impl_port *other_port, uint32_t id, struct pw_properties *props, uint32_t n_format_filters, @@ -906,42 +906,42 @@ void pw_resource_remove(struct pw_resource *resource); int pw_context_recalc_graph(struct pw_context *context); -/** Create a new port \memberof pw_port +/** Create a new port \memberof pw_impl_port * \return a newly allocated port */ -struct pw_port * -pw_port_new(enum pw_direction direction, +struct pw_impl_port * +pw_impl_port_new(enum pw_direction direction, uint32_t port_id, const struct spa_port_info *info, size_t user_data_size); -void pw_port_update_info(struct pw_port *port, const struct spa_port_info *info); +void pw_impl_port_update_info(struct pw_impl_port *port, const struct spa_port_info *info); -int pw_port_register(struct pw_port *port, +int pw_impl_port_register(struct pw_impl_port *port, struct pw_properties *properties); -/** Get the user data of a port, the size of the memory was given \ref in pw_port_new */ -void * pw_port_get_user_data(struct pw_port *port); +/** Get the user data of a port, the size of the memory was given \ref in pw_impl_port_new */ +void * pw_impl_port_get_user_data(struct pw_impl_port *port); -int pw_port_set_mix(struct pw_port *port, struct spa_node *node, uint32_t flags); +int pw_impl_port_set_mix(struct pw_impl_port *port, struct spa_node *node, uint32_t flags); -/** Add a port to a node \memberof pw_port */ -int pw_port_add(struct pw_port *port, struct pw_node *node); +/** Add a port to a node \memberof pw_impl_port */ +int pw_impl_port_add(struct pw_impl_port *port, struct pw_node *node); -int pw_port_init_mix(struct pw_port *port, struct pw_port_mix *mix); -int pw_port_release_mix(struct pw_port *port, struct pw_port_mix *mix); +int pw_impl_port_init_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix); +int pw_impl_port_release_mix(struct pw_impl_port *port, struct pw_impl_port_mix *mix); -void pw_port_update_state(struct pw_port *port, enum pw_port_state state, char *error); +void pw_impl_port_update_state(struct pw_impl_port *port, enum pw_impl_port_state state, char *error); -/** Unlink a port \memberof pw_port */ -void pw_port_unlink(struct pw_port *port); +/** Unlink a port \memberof pw_impl_port */ +void pw_impl_port_unlink(struct pw_impl_port *port); -/** Destroy a port \memberof pw_port */ -void pw_port_destroy(struct pw_port *port); +/** Destroy a port \memberof pw_impl_port */ +void pw_impl_port_destroy(struct pw_impl_port *port); /** Iterate the params of the given port. The callback should return * 1 to fetch the next item, 0 to stop iteration or <0 on error. * The function returns 0 on success or the error returned by the callback. */ -int pw_port_for_each_param(struct pw_port *port, +int pw_impl_port_for_each_param(struct pw_impl_port *port, int seq, uint32_t param_id, uint32_t index, uint32_t max, const struct spa_pod *filter, @@ -950,8 +950,8 @@ int pw_port_for_each_param(struct pw_port *port, struct spa_pod *param), void *data); -int pw_port_for_each_filtered_param(struct pw_port *in_port, - struct pw_port *out_port, +int pw_impl_port_for_each_filtered_param(struct pw_impl_port *in_port, + struct pw_impl_port *out_port, int seq, uint32_t in_param_id, uint32_t out_param_id, @@ -965,20 +965,20 @@ int pw_port_for_each_filtered_param(struct pw_port *in_port, * 0 to fetch the next item, any other value stops the iteration and returns * the value. When all callbacks return 0, this function returns 0 when all * items are iterated. */ -int pw_port_for_each_link(struct pw_port *port, +int pw_impl_port_for_each_link(struct pw_impl_port *port, int (*callback) (void *data, struct pw_impl_link *link), void *data); /** check is a port has links, return 0 if not, 1 if it is linked */ -int pw_port_is_linked(struct pw_port *port); +int pw_impl_port_is_linked(struct pw_impl_port *port); -/** Set a param on a port \memberof pw_port, use SPA_ID_INVALID for mix_id to set +/** Set a param on a port \memberof pw_impl_port, use SPA_ID_INVALID for mix_id to set * the param on all mix ports */ -int pw_port_set_param(struct pw_port *port, +int pw_impl_port_set_param(struct pw_impl_port *port, uint32_t id, uint32_t flags, const struct spa_pod *param); -/** Use buffers on a port \memberof pw_port */ -int pw_port_use_buffers(struct pw_port *port, struct pw_port_mix *mix, uint32_t flags, +/** Use buffers on a port \memberof pw_impl_port */ +int pw_impl_port_use_buffers(struct pw_impl_port *port, struct pw_impl_port_mix *mix, uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers); /** Change the state of the node */ @@ -1004,7 +1004,7 @@ int pw_impl_link_deactivate(struct pw_impl_link *link); struct pw_control * pw_control_new(struct pw_context *context, - struct pw_port *owner, /**< can be NULL */ + struct pw_impl_port *owner, /**< can be NULL */ uint32_t id, uint32_t size, size_t user_data_size /**< extra user data */); |