mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Fix proxy ids
The proxy/resource ids are generated by the client and so we need to used them as index in the client resource map instead of making our own number. Fix stream disconnect and client-node destroy Fix gstreamer device provider Make all sockets non-blocking to avoid errors with bad clients Advertise the subsystems we monitor and disable the gstreamer monitors. Implement core properties updates Make sure we send REMOVE_ID after we are done with the resource.
This commit is contained in:
parent
e579efea10
commit
4b55d7c4da
18 changed files with 222 additions and 69 deletions
|
|
@ -1041,6 +1041,9 @@ client_node_dispatch_func (void *object,
|
|||
handle_node_event (this, cne->event);
|
||||
break;
|
||||
}
|
||||
case PINOS_MESSAGE_DESTROY:
|
||||
pinos_client_node_destroy (node);
|
||||
break;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -1202,8 +1205,16 @@ client_node_resource_destroy (PinosResource *resource)
|
|||
PinosClientNode *this = resource->object;
|
||||
PinosClientNodeImpl *impl = SPA_CONTAINER_OF (this, PinosClientNodeImpl, this);
|
||||
|
||||
pinos_log_debug ("client-node %p: destroy", impl);
|
||||
pinos_signal_emit (&this->destroy_signal, this);
|
||||
|
||||
impl->proxy.resource = this->resource = NULL;
|
||||
pinos_client_node_destroy (this);
|
||||
|
||||
pinos_signal_remove (&impl->global_added);
|
||||
pinos_signal_remove (&impl->loop_changed);
|
||||
pinos_signal_remove (&impl->transport_changed);
|
||||
|
||||
pinos_node_destroy (this->node);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1307,16 +1318,7 @@ error_no_node:
|
|||
void
|
||||
pinos_client_node_destroy (PinosClientNode * this)
|
||||
{
|
||||
PinosClientNodeImpl *impl = SPA_CONTAINER_OF (this, PinosClientNodeImpl, this);
|
||||
|
||||
pinos_log_debug ("client-node %p: destroy", impl);
|
||||
pinos_signal_emit (&this->destroy_signal, this);
|
||||
|
||||
pinos_signal_remove (&impl->global_added);
|
||||
pinos_signal_remove (&impl->loop_changed);
|
||||
pinos_signal_remove (&impl->transport_changed);
|
||||
|
||||
pinos_node_destroy (this->node);
|
||||
pinos_resource_destroy (this->resource);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1339,7 +1341,7 @@ pinos_client_node_get_data_socket (PinosClientNode *this,
|
|||
#if 1
|
||||
int fd[2];
|
||||
|
||||
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, fd) != 0)
|
||||
if (socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, fd) != 0)
|
||||
return SPA_RESULT_ERRNO;
|
||||
|
||||
impl->proxy.data_source.fd = fd[0];
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ registry_dispatch_func (void *object,
|
|||
"unknown object id %u", m->id);
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
pinos_log_debug ("global %p: bind object id %d", global, m->id);
|
||||
res = pinos_global_bind (global, client, 0, m->id);
|
||||
pinos_log_debug ("global %p: bind object id %d to %d", global, m->id, m->new_id);
|
||||
res = pinos_global_bind (global, client, 0, m->new_id);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -110,7 +110,7 @@ core_dispatch_func (void *object,
|
|||
PinosResource *registry_resource;
|
||||
|
||||
registry_resource = pinos_resource_new (resource->client,
|
||||
SPA_ID_INVALID,
|
||||
m->new_id,
|
||||
this->uri.registry,
|
||||
this,
|
||||
destroy_registry_resource);
|
||||
|
|
@ -203,6 +203,7 @@ core_unbind_func (void *data)
|
|||
{
|
||||
PinosResource *resource = data;
|
||||
resource->client->core_resource = NULL;
|
||||
spa_list_remove (&resource->link);
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -228,20 +229,21 @@ core_bind_func (PinosGlobal *global,
|
|||
core_dispatch_func,
|
||||
this);
|
||||
|
||||
spa_list_insert (this->resource_list.prev, &resource->link);
|
||||
client->core_resource = resource;
|
||||
|
||||
pinos_log_debug ("core %p: bound to %d", global->object, resource->id);
|
||||
|
||||
m.info = &info;
|
||||
info.id = global->id;
|
||||
info.change_mask = ~0;
|
||||
info.change_mask = PINOS_CORE_CHANGE_MASK_ALL;
|
||||
info.user_name = pinos_get_user_name ();
|
||||
info.host_name = pinos_get_host_name ();
|
||||
info.version = "0";
|
||||
info.name = "pinos-0";
|
||||
srandom (time (NULL));
|
||||
info.cookie = random ();
|
||||
info.props = NULL;
|
||||
info.props = this->properties ? &this->properties->dict : NULL;
|
||||
|
||||
return pinos_client_send_message (resource->client,
|
||||
resource,
|
||||
|
|
@ -254,7 +256,8 @@ no_mem:
|
|||
}
|
||||
|
||||
PinosCore *
|
||||
pinos_core_new (PinosMainLoop *main_loop)
|
||||
pinos_core_new (PinosMainLoop *main_loop,
|
||||
PinosProperties *properties)
|
||||
{
|
||||
PinosCoreImpl *impl;
|
||||
PinosCore *this;
|
||||
|
|
@ -269,6 +272,7 @@ pinos_core_new (PinosMainLoop *main_loop)
|
|||
goto no_data_loop;
|
||||
|
||||
this->main_loop = main_loop;
|
||||
this->properties = properties;
|
||||
|
||||
pinos_uri_init (&this->uri);
|
||||
pinos_access_init (&this->access);
|
||||
|
|
@ -287,6 +291,7 @@ pinos_core_new (PinosMainLoop *main_loop)
|
|||
|
||||
pinos_data_loop_start (this->data_loop);
|
||||
|
||||
spa_list_init (&this->resource_list);
|
||||
spa_list_init (&this->registry_resource_list);
|
||||
spa_list_init (&this->global_list);
|
||||
spa_list_init (&this->client_list);
|
||||
|
|
@ -425,6 +430,40 @@ pinos_global_destroy (PinosGlobal *global)
|
|||
free (global);
|
||||
}
|
||||
|
||||
void
|
||||
pinos_core_update_properties (PinosCore *core,
|
||||
const SpaDict *dict)
|
||||
{
|
||||
PinosMessageCoreInfo m;
|
||||
PinosCoreInfo info;
|
||||
PinosResource *resource;
|
||||
|
||||
if (core->properties == NULL) {
|
||||
if (dict)
|
||||
core->properties = pinos_properties_new_dict (dict);
|
||||
} else if (dict != &core->properties->dict) {
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < dict->n_items; i++)
|
||||
pinos_properties_set (core->properties,
|
||||
dict->items[i].key,
|
||||
dict->items[i].value);
|
||||
}
|
||||
|
||||
m.info = &info;
|
||||
info.id = core->global->id;
|
||||
info.change_mask = PINOS_CORE_CHANGE_MASK_PROPS;
|
||||
info.props = core->properties ? &core->properties->dict : NULL;
|
||||
|
||||
spa_list_for_each (resource, &core->resource_list, link) {
|
||||
pinos_client_send_message (resource->client,
|
||||
resource,
|
||||
PINOS_MESSAGE_CORE_INFO,
|
||||
&m,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
PinosPort *
|
||||
pinos_core_find_port (PinosCore *core,
|
||||
PinosPort *other_port,
|
||||
|
|
|
|||
|
|
@ -64,11 +64,14 @@ struct _PinosGlobal {
|
|||
struct _PinosCore {
|
||||
PinosGlobal *global;
|
||||
|
||||
PinosProperties *properties;
|
||||
|
||||
PinosURI uri;
|
||||
PinosAccess access;
|
||||
|
||||
PinosMap objects;
|
||||
|
||||
SpaList resource_list;
|
||||
SpaList registry_resource_list;
|
||||
SpaList global_list;
|
||||
SpaList client_list;
|
||||
|
|
@ -93,8 +96,12 @@ struct _PinosCore {
|
|||
PinosGlobal *global));
|
||||
};
|
||||
|
||||
PinosCore * pinos_core_new (PinosMainLoop *main_loop);
|
||||
void pinos_core_destroy (PinosCore *core);
|
||||
PinosCore * pinos_core_new (PinosMainLoop *main_loop,
|
||||
PinosProperties *props);
|
||||
void pinos_core_destroy (PinosCore *core);
|
||||
|
||||
void pinos_core_update_properties (PinosCore *core,
|
||||
const SpaDict *dict);
|
||||
|
||||
PinosGlobal * pinos_core_add_global (PinosCore *core,
|
||||
PinosClient *owner,
|
||||
|
|
|
|||
|
|
@ -657,8 +657,10 @@ pinos_node_destroy (PinosNode * this)
|
|||
pinos_log_debug ("node %p: destroy", impl);
|
||||
pinos_signal_emit (&this->destroy_signal, this);
|
||||
|
||||
spa_list_remove (&this->link);
|
||||
pinos_global_destroy (this->global);
|
||||
if (!impl->async_init) {
|
||||
spa_list_remove (&this->link);
|
||||
pinos_global_destroy (this->global);
|
||||
}
|
||||
|
||||
spa_list_for_each_safe (resource, tmp, &this->resource_list, link)
|
||||
pinos_resource_destroy (resource);
|
||||
|
|
|
|||
|
|
@ -43,16 +43,20 @@ pinos_resource_new (PinosClient *client,
|
|||
return NULL;
|
||||
|
||||
this = &impl->this;
|
||||
|
||||
this->core = client->core;
|
||||
this->client = client;
|
||||
this->type = type;
|
||||
this->object = object;
|
||||
this->destroy = destroy;
|
||||
this->id = id;
|
||||
|
||||
pinos_signal_init (&this->destroy_signal);
|
||||
|
||||
this->id = pinos_map_insert_new (&client->objects, this);
|
||||
if (!pinos_map_insert_at (&client->objects, this->id, this)) {
|
||||
free (impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pinos_log_debug ("resource %p: new for client %p id %u", this, client, this->id);
|
||||
pinos_signal_emit (&client->resource_added, client, this);
|
||||
|
||||
|
|
@ -64,9 +68,15 @@ pinos_resource_destroy (PinosResource *resource)
|
|||
{
|
||||
PinosClient *client = resource->client;
|
||||
|
||||
pinos_log_debug ("resource %p: destroy", resource);
|
||||
pinos_log_debug ("resource %p: destroy %u", resource, resource->id);
|
||||
pinos_signal_emit (&resource->destroy_signal, resource);
|
||||
|
||||
pinos_map_remove (&client->objects, resource->id);
|
||||
pinos_signal_emit (&client->resource_removed, client, resource);
|
||||
|
||||
if (resource->destroy)
|
||||
resource->destroy (resource);
|
||||
|
||||
if (client->core_resource) {
|
||||
PinosMessageRemoveId m;
|
||||
m.id = resource->id;
|
||||
|
|
@ -77,12 +87,6 @@ pinos_resource_destroy (PinosResource *resource)
|
|||
true);
|
||||
}
|
||||
|
||||
pinos_map_remove (&client->objects, resource->id);
|
||||
pinos_signal_emit (&client->resource_removed, client, resource);
|
||||
|
||||
if (resource->destroy)
|
||||
resource->destroy (resource);
|
||||
|
||||
pinos_log_debug ("resource %p: free", resource);
|
||||
free (resource);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue