mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
client-node: set parent id and owner
Make sure we set the right parent id and owner for the client node and client-stream Move the remote id in the proxy object and use it in the stream to get the node id.
This commit is contained in:
parent
fe03ec8bde
commit
79a3b594f9
11 changed files with 39 additions and 19 deletions
|
|
@ -44,7 +44,9 @@ struct factory_data {
|
||||||
struct pw_factory *this;
|
struct pw_factory *this;
|
||||||
struct pw_properties *properties;
|
struct pw_properties *properties;
|
||||||
|
|
||||||
|
struct pw_module *module;
|
||||||
struct spa_hook module_listener;
|
struct spa_hook module_listener;
|
||||||
|
|
||||||
uint32_t type_client_node;
|
uint32_t type_client_node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -55,8 +57,10 @@ static void *create_object(void *_data,
|
||||||
struct pw_properties *properties,
|
struct pw_properties *properties,
|
||||||
uint32_t new_id)
|
uint32_t new_id)
|
||||||
{
|
{
|
||||||
|
struct factory_data *d = _data;
|
||||||
void *result;
|
void *result;
|
||||||
struct pw_resource *node_resource;
|
struct pw_resource *node_resource;
|
||||||
|
struct pw_global *parent;
|
||||||
|
|
||||||
if (resource == NULL)
|
if (resource == NULL)
|
||||||
goto no_resource;
|
goto no_resource;
|
||||||
|
|
@ -66,11 +70,13 @@ static void *create_object(void *_data,
|
||||||
if (node_resource == NULL)
|
if (node_resource == NULL)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
||||||
|
parent = pw_module_get_global(d->module);
|
||||||
|
|
||||||
if (properties && pw_properties_get(properties, "node.stream") != NULL) {
|
if (properties && pw_properties_get(properties, "node.stream") != NULL) {
|
||||||
result = pw_client_stream_new(node_resource, properties);
|
result = pw_client_stream_new(node_resource, parent, properties);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = pw_client_node_new(node_resource, properties, true);
|
result = pw_client_node_new(node_resource, parent, properties, true);
|
||||||
}
|
}
|
||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
|
|
@ -134,6 +140,7 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
||||||
|
|
||||||
data = pw_factory_get_user_data(factory);
|
data = pw_factory_get_user_data(factory);
|
||||||
data->this = factory;
|
data->this = factory;
|
||||||
|
data->module = module;
|
||||||
data->properties = properties;
|
data->properties = properties;
|
||||||
data->type_client_node = type_client_node;
|
data->type_client_node = type_client_node;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1156,6 +1156,7 @@ void pw_client_node_registered(struct pw_client_node *this, uint32_t node_id)
|
||||||
{
|
{
|
||||||
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
struct impl *impl = SPA_CONTAINER_OF(this, struct impl, this);
|
||||||
|
|
||||||
|
pw_log_debug("client-node %p: %d", this, node_id);
|
||||||
pw_client_node_resource_transport(this->resource,
|
pw_client_node_resource_transport(this->resource,
|
||||||
node_id,
|
node_id,
|
||||||
impl->other_fds[0],
|
impl->other_fds[0],
|
||||||
|
|
@ -1326,6 +1327,7 @@ static const struct pw_resource_events resource_events = {
|
||||||
* \memberof pw_client_node
|
* \memberof pw_client_node
|
||||||
*/
|
*/
|
||||||
struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
|
struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
|
||||||
|
struct pw_global *parent,
|
||||||
struct pw_properties *properties,
|
struct pw_properties *properties,
|
||||||
bool do_register)
|
bool do_register)
|
||||||
{
|
{
|
||||||
|
|
@ -1360,9 +1362,10 @@ struct pw_client_node *pw_client_node_new(struct pw_resource *resource,
|
||||||
name = "client-node";
|
name = "client-node";
|
||||||
|
|
||||||
this->resource = resource;
|
this->resource = resource;
|
||||||
|
this->parent = parent;
|
||||||
this->node = pw_spa_node_new(core,
|
this->node = pw_spa_node_new(core,
|
||||||
pw_resource_get_client(this->resource),
|
pw_resource_get_client(this->resource),
|
||||||
NULL,
|
parent,
|
||||||
name,
|
name,
|
||||||
PW_SPA_NODE_FLAG_ASYNC |
|
PW_SPA_NODE_FLAG_ASYNC |
|
||||||
(do_register ? 0 : PW_SPA_NODE_FLAG_NO_REGISTER),
|
(do_register ? 0 : PW_SPA_NODE_FLAG_NO_REGISTER),
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,12 @@ struct pw_client_node {
|
||||||
struct pw_node *node;
|
struct pw_node *node;
|
||||||
|
|
||||||
struct pw_resource *resource;
|
struct pw_resource *resource;
|
||||||
|
struct pw_global *parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pw_client_node *
|
struct pw_client_node *
|
||||||
pw_client_node_new(struct pw_resource *resource,
|
pw_client_node_new(struct pw_resource *resource,
|
||||||
|
struct pw_global *parent,
|
||||||
struct pw_properties *properties,
|
struct pw_properties *properties,
|
||||||
bool do_register);
|
bool do_register);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -633,6 +633,7 @@ impl_node_port_set_io(struct spa_node *node,
|
||||||
impl = this->impl;
|
impl = this->impl;
|
||||||
t = impl->t;
|
t = impl->t;
|
||||||
|
|
||||||
|
spa_log_debug(this->log, "set io %d %d %d", id, direction, impl->direction);
|
||||||
if (direction != impl->direction)
|
if (direction != impl->direction)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
@ -1028,6 +1029,7 @@ static const struct pw_node_events node_events = {
|
||||||
* \memberof pw_client_stream
|
* \memberof pw_client_stream
|
||||||
*/
|
*/
|
||||||
struct pw_client_stream *pw_client_stream_new(struct pw_resource *resource,
|
struct pw_client_stream *pw_client_stream_new(struct pw_resource *resource,
|
||||||
|
struct pw_global *parent,
|
||||||
struct pw_properties *properties)
|
struct pw_properties *properties)
|
||||||
{
|
{
|
||||||
struct impl *impl;
|
struct impl *impl;
|
||||||
|
|
@ -1053,6 +1055,7 @@ struct pw_client_stream *pw_client_stream_new(struct pw_resource *resource,
|
||||||
|
|
||||||
impl->client_node = pw_client_node_new(
|
impl->client_node = pw_client_node_new(
|
||||||
resource,
|
resource,
|
||||||
|
parent,
|
||||||
pw_properties_copy(properties),
|
pw_properties_copy(properties),
|
||||||
false);
|
false);
|
||||||
if (impl->client_node == NULL)
|
if (impl->client_node == NULL)
|
||||||
|
|
@ -1068,7 +1071,7 @@ struct pw_client_stream *pw_client_stream_new(struct pw_resource *resource,
|
||||||
|
|
||||||
this->node = pw_spa_node_new(core,
|
this->node = pw_spa_node_new(core,
|
||||||
client,
|
client,
|
||||||
NULL,
|
parent,
|
||||||
name,
|
name,
|
||||||
PW_SPA_NODE_FLAG_ASYNC,
|
PW_SPA_NODE_FLAG_ASYNC,
|
||||||
&impl->node.node,
|
&impl->node.node,
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ struct pw_client_stream {
|
||||||
|
|
||||||
struct pw_client_stream *
|
struct pw_client_stream *
|
||||||
pw_client_stream_new(struct pw_resource *resource,
|
pw_client_stream_new(struct pw_resource *resource,
|
||||||
struct pw_properties *properties);
|
struct pw_global *parent,
|
||||||
|
struct pw_properties *properties);
|
||||||
|
|
||||||
void
|
void
|
||||||
pw_client_stream_destroy(struct pw_client_stream *stream);
|
pw_client_stream_destroy(struct pw_client_stream *stream);
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,8 @@ int pw_control_link(struct pw_control *control, struct pw_control *other)
|
||||||
port->direction, port->port_id,
|
port->direction, port->port_id,
|
||||||
other->id,
|
other->id,
|
||||||
impl->mem->ptr, control->size)) < 0) {
|
impl->mem->ptr, control->size)) < 0) {
|
||||||
|
pw_log_warn("control %p: set io failed %d %s", control,
|
||||||
|
res, spa_strerror(res));
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -185,6 +187,8 @@ int pw_control_link(struct pw_control *control, struct pw_control *other)
|
||||||
port->direction, port->port_id,
|
port->direction, port->port_id,
|
||||||
control->id,
|
control->id,
|
||||||
impl->mem->ptr, control->size)) < 0) {
|
impl->mem->ptr, control->size)) < 0) {
|
||||||
|
pw_log_warn("control %p: set io failed %d %s", control,
|
||||||
|
res, spa_strerror(res));
|
||||||
/* undo */
|
/* undo */
|
||||||
port = other->port;
|
port = other->port;
|
||||||
spa_node_port_set_io(port->node->node,
|
spa_node_port_set_io(port->node->node,
|
||||||
|
|
|
||||||
|
|
@ -426,6 +426,7 @@ struct pw_proxy {
|
||||||
struct spa_list link; /**< link in the remote */
|
struct spa_list link; /**< link in the remote */
|
||||||
|
|
||||||
uint32_t id; /**< client side id */
|
uint32_t id; /**< client side id */
|
||||||
|
uint32_t remote_id; /**< remote id */
|
||||||
|
|
||||||
struct spa_hook_list listener_list;
|
struct spa_hook_list listener_list;
|
||||||
struct spa_hook_list proxy_listener_list;
|
struct spa_hook_list proxy_listener_list;
|
||||||
|
|
@ -476,6 +477,7 @@ struct pw_stream {
|
||||||
char *error; /**< error reason when state is in error */
|
char *error; /**< error reason when state is in error */
|
||||||
|
|
||||||
struct spa_hook_list listener_list;
|
struct spa_hook_list listener_list;
|
||||||
|
struct pw_proxy *proxy;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pw_factory {
|
struct pw_factory {
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
|
||||||
spa_hook_list_init(&this->proxy_listener_list);
|
spa_hook_list_init(&this->proxy_listener_list);
|
||||||
|
|
||||||
this->id = pw_map_insert_new(&remote->objects, this);
|
this->id = pw_map_insert_new(&remote->objects, this);
|
||||||
|
this->remote_id = SPA_ID_INVALID;
|
||||||
|
|
||||||
if (user_data_size > 0)
|
if (user_data_size > 0)
|
||||||
this->user_data = SPA_MEMBER(impl, sizeof(struct proxy), void);
|
this->user_data = SPA_MEMBER(impl, sizeof(struct proxy), void);
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,6 @@ struct node_data {
|
||||||
struct pw_remote *remote;
|
struct pw_remote *remote;
|
||||||
struct pw_core *core;
|
struct pw_core *core;
|
||||||
struct pw_type *t;
|
struct pw_type *t;
|
||||||
uint32_t node_id;
|
|
||||||
|
|
||||||
int rtwritefd;
|
int rtwritefd;
|
||||||
struct spa_source *rtsocket_source;
|
struct spa_source *rtsocket_source;
|
||||||
|
|
@ -754,7 +753,7 @@ static void client_node_transport(void *object, uint32_t node_id,
|
||||||
|
|
||||||
clean_transport(data);
|
clean_transport(data);
|
||||||
|
|
||||||
data->node_id = node_id;
|
proxy->remote_id = node_id;
|
||||||
|
|
||||||
pw_log_debug("remote-node %p: create transport with fds %d %d for node %u",
|
pw_log_debug("remote-node %p: create transport with fds %d %d for node %u",
|
||||||
proxy, readfd, writefd, node_id);
|
proxy, readfd, writefd, node_id);
|
||||||
|
|
@ -1343,9 +1342,10 @@ static void clear_mix(struct node_data *data, struct mix *mix)
|
||||||
static void node_proxy_destroy(void *_data)
|
static void node_proxy_destroy(void *_data)
|
||||||
{
|
{
|
||||||
struct node_data *data = _data;
|
struct node_data *data = _data;
|
||||||
|
struct pw_proxy *proxy = (struct pw_proxy*) data->node_proxy;
|
||||||
struct mix *mix, *tmp;
|
struct mix *mix, *tmp;
|
||||||
|
|
||||||
if (data->node_id != SPA_ID_INVALID) {
|
if (proxy->remote_id != SPA_ID_INVALID) {
|
||||||
spa_list_for_each_safe(mix, tmp, &data->mix[SPA_DIRECTION_INPUT], link)
|
spa_list_for_each_safe(mix, tmp, &data->mix[SPA_DIRECTION_INPUT], link)
|
||||||
clear_mix(data, mix);
|
clear_mix(data, mix);
|
||||||
spa_list_for_each_safe(mix, tmp, &data->mix[SPA_DIRECTION_OUTPUT], link)
|
spa_list_for_each_safe(mix, tmp, &data->mix[SPA_DIRECTION_OUTPUT], link)
|
||||||
|
|
@ -1388,7 +1388,6 @@ struct pw_proxy *pw_remote_export(struct pw_remote *remote,
|
||||||
data = pw_proxy_get_user_data(proxy);
|
data = pw_proxy_get_user_data(proxy);
|
||||||
data->remote = remote;
|
data->remote = remote;
|
||||||
data->node = node;
|
data->node = node;
|
||||||
data->node_id = SPA_ID_INVALID;
|
|
||||||
data->core = pw_node_get_core(node);
|
data->core = pw_node_get_core(node);
|
||||||
data->t = pw_core_get_type(data->core);
|
data->t = pw_core_get_type(data->core);
|
||||||
data->node_proxy = (struct pw_client_node_proxy *)proxy;
|
data->node_proxy = (struct pw_client_node_proxy *)proxy;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
#include <spa/support/type-map.h>
|
#include <spa/support/type-map.h>
|
||||||
#include <spa/buffer/alloc.h>
|
#include <spa/buffer/alloc.h>
|
||||||
#include <spa/param/format-utils.h>
|
#include <spa/param/format-utils.h>
|
||||||
#include <spa/param/audio/format-utils.h>
|
|
||||||
#include <spa/param/props.h>
|
#include <spa/param/props.h>
|
||||||
#include <spa/node/io.h>
|
#include <spa/node/io.h>
|
||||||
#include <spa/utils/ringbuffer.h>
|
#include <spa/utils/ringbuffer.h>
|
||||||
|
|
@ -684,7 +683,7 @@ static int handle_connect(struct pw_stream *stream)
|
||||||
pw_node_set_active(impl->node, true);
|
pw_node_set_active(impl->node, true);
|
||||||
|
|
||||||
pw_log_debug("stream %p: export node %p", stream, impl->node);
|
pw_log_debug("stream %p: export node %p", stream, impl->node);
|
||||||
pw_remote_export(stream->remote, impl->node);
|
stream->proxy = pw_remote_export(stream->remote, impl->node);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -988,7 +987,7 @@ pw_stream_connect(struct pw_stream *stream,
|
||||||
|
|
||||||
uint32_t pw_stream_get_node_id(struct pw_stream *stream)
|
uint32_t pw_stream_get_node_id(struct pw_stream *stream)
|
||||||
{
|
{
|
||||||
return stream->node_id;
|
return stream->proxy->remote_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pw_stream_disconnect(struct pw_stream *stream)
|
int pw_stream_disconnect(struct pw_stream *stream)
|
||||||
|
|
|
||||||
|
|
@ -212,13 +212,6 @@ enum pw_stream_flags {
|
||||||
* device */
|
* device */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A time structure \memberof pw_stream */
|
|
||||||
struct pw_time {
|
|
||||||
int64_t now; /**< the monotonic time */
|
|
||||||
int64_t ticks; /**< the ticks at \a now */
|
|
||||||
struct spa_fraction rate; /**< the rate of \a ticks */
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Create a new unconneced \ref pw_stream \memberof pw_stream
|
/** Create a new unconneced \ref pw_stream \memberof pw_stream
|
||||||
* \return a newly allocated \ref pw_stream */
|
* \return a newly allocated \ref pw_stream */
|
||||||
struct pw_stream *
|
struct pw_stream *
|
||||||
|
|
@ -297,6 +290,12 @@ pw_stream_finish_format(struct pw_stream *stream, /**< a \ref pw_stream */
|
||||||
/** Activate or deactivate the stream \memberof pw_stream */
|
/** Activate or deactivate the stream \memberof pw_stream */
|
||||||
int pw_stream_set_active(struct pw_stream *stream, bool active);
|
int pw_stream_set_active(struct pw_stream *stream, bool active);
|
||||||
|
|
||||||
|
/** A time structure \memberof pw_stream */
|
||||||
|
struct pw_time {
|
||||||
|
int64_t now; /**< the monotonic time */
|
||||||
|
int64_t ticks; /**< the ticks at \a now */
|
||||||
|
struct spa_fraction rate; /**< the rate of \a ticks */
|
||||||
|
};
|
||||||
/** Query the time on the stream \memberof pw_stream */
|
/** Query the time on the stream \memberof pw_stream */
|
||||||
int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
|
int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue