mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
Rework dbus handling
Remove the Daemon object and remove all dbus code from the main objects. We can use the signals in a separate module to create and destroy the DBus interfaces. Move the dbus protocol in a module Move the autolink policy to a module
This commit is contained in:
parent
b9e2b1c0e3
commit
dfbfb4c9ee
28 changed files with 1122 additions and 1007 deletions
|
|
@ -27,64 +27,8 @@
|
|||
typedef struct
|
||||
{
|
||||
PinosClient this;
|
||||
|
||||
guint id;
|
||||
PinosClient1 *iface;
|
||||
|
||||
} PinosClientImpl;
|
||||
|
||||
static void
|
||||
client_name_appeared_handler (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
const gchar *name_owner,
|
||||
gpointer user_data)
|
||||
{
|
||||
PinosClientImpl *impl = user_data;
|
||||
PinosClient *this = &impl->this;
|
||||
PinosObjectSkeleton *skel;
|
||||
|
||||
pinos_log_debug ("client %p: appeared %s %s", this, name, name_owner);
|
||||
|
||||
skel = pinos_object_skeleton_new (PINOS_DBUS_OBJECT_CLIENT);
|
||||
pinos_object_skeleton_set_client1 (skel, impl->iface);
|
||||
|
||||
this->global = pinos_core_add_global (this->core,
|
||||
this->core->registry.uri.client,
|
||||
this,
|
||||
skel);
|
||||
}
|
||||
|
||||
static void
|
||||
client_name_vanished_handler (GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
gpointer user_data)
|
||||
{
|
||||
PinosClientImpl *impl = user_data;
|
||||
PinosClient *this = &impl->this;
|
||||
|
||||
pinos_log_debug ("client %p: vanished %s", this, name);
|
||||
|
||||
pinos_core_remove_global (this->core,
|
||||
this->global);
|
||||
this->global = NULL;
|
||||
|
||||
g_bus_unwatch_name (impl->id);
|
||||
}
|
||||
|
||||
static void
|
||||
client_watch_name (PinosClient *this)
|
||||
{
|
||||
PinosClientImpl *impl = SPA_CONTAINER_OF (this, PinosClientImpl, this);
|
||||
|
||||
impl->id = g_bus_watch_name_on_connection (this->core->connection,
|
||||
this->sender,
|
||||
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
||||
client_name_appeared_handler,
|
||||
client_name_vanished_handler,
|
||||
impl,
|
||||
(GDestroyNotify) pinos_client_destroy);
|
||||
}
|
||||
|
||||
PinosResource *
|
||||
pinos_client_add_resource (PinosClient *client,
|
||||
uint32_t type,
|
||||
|
|
@ -95,6 +39,7 @@ pinos_client_add_resource (PinosClient *client,
|
|||
|
||||
resource = calloc (1, sizeof (PinosResource));
|
||||
resource->core = client->core;
|
||||
resource->client = client;
|
||||
resource->id = 0;
|
||||
resource->type = type;
|
||||
resource->object = object;
|
||||
|
|
@ -109,11 +54,10 @@ pinos_client_add_resource (PinosClient *client,
|
|||
return resource;
|
||||
}
|
||||
|
||||
void
|
||||
pinos_client_remove_resource (PinosClient *client,
|
||||
PinosResource *resource)
|
||||
SpaResult
|
||||
pinos_resource_destroy (PinosResource *resource)
|
||||
{
|
||||
pinos_log_debug ("client %p: resource %p destroy", client, resource);
|
||||
pinos_log_debug ("resource %p: destroy", resource);
|
||||
pinos_signal_emit (&resource->destroy_signal, resource);
|
||||
|
||||
spa_list_remove (&resource->link);
|
||||
|
|
@ -122,29 +66,21 @@ pinos_client_remove_resource (PinosClient *client,
|
|||
resource->destroy (resource->object);
|
||||
|
||||
free (resource);
|
||||
}
|
||||
|
||||
bool
|
||||
pinos_client_has_resource (PinosClient *client,
|
||||
PinosResource *resource)
|
||||
{
|
||||
return false;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_client_new:
|
||||
* @daemon: a #PinosDaemon
|
||||
* @sender: the sender id
|
||||
* @prefix: a prefix
|
||||
* @properties: extra client properties
|
||||
*
|
||||
* Make a new #PinosClient object and register it to @daemon under the @prefix.
|
||||
* Make a new #PinosClient object and register it to @core
|
||||
*
|
||||
* Returns: a new #PinosClient
|
||||
*/
|
||||
PinosClient *
|
||||
pinos_client_new (PinosCore *core,
|
||||
const gchar *sender,
|
||||
PinosProperties *properties)
|
||||
{
|
||||
PinosClient *this;
|
||||
|
|
@ -155,18 +91,17 @@ pinos_client_new (PinosCore *core,
|
|||
|
||||
this = &impl->this;
|
||||
this->core = core;
|
||||
this->sender = strdup (sender);
|
||||
this->properties = properties;
|
||||
|
||||
spa_list_init (&this->resource_list);
|
||||
pinos_signal_init (&this->destroy_signal);
|
||||
|
||||
impl->iface = pinos_client1_skeleton_new ();
|
||||
|
||||
client_watch_name (this);
|
||||
|
||||
spa_list_insert (core->client_list.prev, &this->link);
|
||||
|
||||
this->global = pinos_core_add_global (core,
|
||||
core->registry.uri.client,
|
||||
this);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -185,16 +120,16 @@ pinos_client_destroy (PinosClient * client)
|
|||
pinos_log_debug ("client %p: destroy", client);
|
||||
pinos_signal_emit (&client->destroy_signal, client);
|
||||
|
||||
pinos_global_destroy (client->global);
|
||||
|
||||
spa_list_for_each_safe (resource, tmp, &client->resource_list, link)
|
||||
pinos_client_remove_resource (client, resource);
|
||||
pinos_resource_destroy (resource);
|
||||
|
||||
spa_list_remove (&client->link);
|
||||
|
||||
free (client->sender);
|
||||
if (client->properties)
|
||||
pinos_properties_free (client->properties);
|
||||
|
||||
g_clear_object (&impl->iface);
|
||||
free (impl);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue