lib: object/interface: do not (transfer full) interfaces and objects

This commit is contained in:
George Kiagiadakis
2019-04-26 13:19:18 +03:00
parent b376c5d7c4
commit e16e66de2d
9 changed files with 21 additions and 24 deletions

View File

@@ -75,20 +75,20 @@ wp_interface_impl_get_object (WpInterfaceImpl * self)
* @self: the interface implementation instance * @self: the interface implementation instance
* @interface: an interface type * @interface: an interface type
* *
* Returns: (type GObject*) (nullable) (transfer full): the object * Returns: (type GObject*) (nullable) (transfer none): the object
* implementing @interface * implementing @interface
*/ */
gpointer gpointer
wp_interface_impl_get_sibling (WpInterfaceImpl * self, GType interface) wp_interface_impl_get_sibling (WpInterfaceImpl * self, GType interface)
{ {
WpInterfaceImplPrivate *priv = wp_interface_impl_get_instance_private (self); WpInterfaceImplPrivate *priv = wp_interface_impl_get_instance_private (self);
GObject *iface = NULL; gpointer iface = NULL;
g_return_val_if_fail (WP_IS_INTERFACE_IMPL (self), NULL); g_return_val_if_fail (WP_IS_INTERFACE_IMPL (self), NULL);
g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL); g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL);
if (g_type_is_a (G_TYPE_FROM_INSTANCE (self), interface)) { if (g_type_is_a (G_TYPE_FROM_INSTANCE (self), interface)) {
iface = G_OBJECT (g_object_ref (self)); iface = self;
} else if (priv->object) { } else if (priv->object) {
iface = wp_object_get_interface (priv->object, interface); iface = wp_object_get_interface (priv->object, interface);
} }

View File

@@ -94,7 +94,7 @@ wp_object_implements_interface (WpObject * self, GType interface)
* @self: the object * @self: the object
* @interface: an interface type * @interface: an interface type
* *
* Returns: (type GObject*) (nullable) (transfer full): the object * Returns: (type GObject*) (nullable) (transfer none): the object
* implementing @interface * implementing @interface
*/ */
gpointer gpointer
@@ -108,7 +108,7 @@ wp_object_get_interface (WpObject * self, GType interface)
for (i = 0; i < priv->iface_objects->len; i++) { for (i = 0; i < priv->iface_objects->len; i++) {
GObject *obj = g_array_index (priv->iface_objects, GObject*, i); GObject *obj = g_array_index (priv->iface_objects, GObject*, i);
if (g_type_is_a (G_TYPE_FROM_INSTANCE (obj), interface)) if (g_type_is_a (G_TYPE_FROM_INSTANCE (obj), interface))
return g_object_ref (obj); return obj;
} }
return NULL; return NULL;

View File

@@ -117,8 +117,8 @@ default_handle_pw_proxy (WpPlugin * self, WpProxy * proxy)
case PW_TYPE_INTERFACE_Node: case PW_TYPE_INTERFACE_Node:
{ {
WpProxyRegistry *reg;
g_autoptr (WpProxy) parent; g_autoptr (WpProxy) parent;
g_autoptr (WpProxyRegistry) reg;
reg = wp_object_get_interface (priv->core, WP_TYPE_PROXY_REGISTRY); reg = wp_object_get_interface (priv->core, WP_TYPE_PROXY_REGISTRY);
parent = wp_proxy_registry_get_proxy (reg, wp_proxy_get_parent_id (proxy)); parent = wp_proxy_registry_get_proxy (reg, wp_proxy_get_parent_id (proxy));

View File

@@ -223,7 +223,7 @@ static void
wp_proxy_constructed (GObject * object) wp_proxy_constructed (GObject * object)
{ {
WpProxy *self = WP_PROXY (object); WpProxy *self = WP_PROXY (object);
g_autoptr (WpProxyRegistry) pr = NULL; WpProxyRegistry *pr = NULL;
struct pw_registry_proxy *reg_proxy; struct pw_registry_proxy *reg_proxy;
const void *events = NULL; const void *events = NULL;
uint32_t ver = 0; uint32_t ver = 0;

View File

@@ -78,7 +78,7 @@ static void
device_node_destroyed (WpProxy * device_node, DefaultSession * session) device_node_destroyed (WpProxy * device_node, DefaultSession * session)
{ {
g_autoptr (WpObject) core = NULL; g_autoptr (WpObject) core = NULL;
g_autoptr (WpSessionRegistry) sr = NULL; WpSessionRegistry *sr = NULL;
g_info ("Proxy %u destroyed - unregistering session %u", g_info ("Proxy %u destroyed - unregistering session %u",
wp_proxy_get_id (device_node), session->session_id); wp_proxy_get_id (device_node), session->session_id);
@@ -94,9 +94,9 @@ static gboolean
handle_node (WpPlugin * self, WpProxy * proxy) handle_node (WpPlugin * self, WpProxy * proxy)
{ {
g_autoptr (WpObject) core = NULL; g_autoptr (WpObject) core = NULL;
g_autoptr (WpSessionRegistry) sr = NULL;
g_autoptr (GError) error = NULL;
g_autoptr (DefaultSession) session = NULL; g_autoptr (DefaultSession) session = NULL;
g_autoptr (GError) error = NULL;
WpSessionRegistry *sr = NULL;
const gchar *media_class, *ptr; const gchar *media_class, *ptr;
WpSessionDirection direction; WpSessionDirection direction;
guint32 media_type; guint32 media_type;
@@ -158,9 +158,9 @@ plug_dsp (WpProxy * node)
{ {
DefaultSession *session; DefaultSession *session;
g_autoptr (WpObject) core = NULL; g_autoptr (WpObject) core = NULL;
g_autoptr (WpPipewireObjects) pw_objects = NULL; WpPipewireObjects *pw_objects = NULL;
struct pw_core_proxy *core_proxy; struct pw_core_proxy *core_proxy;
g_autoptr (WpPipewireProperties) pw_props = NULL; WpPipewireProperties *pw_props = NULL;
struct pw_properties *props; struct pw_properties *props;
const char *name; const char *name;
enum pw_direction reverse_direction; enum pw_direction reverse_direction;
@@ -273,7 +273,7 @@ handle_pw_proxy (WpPlugin * self, WpProxy * proxy)
{ {
g_autoptr (WpObject) core = NULL; g_autoptr (WpObject) core = NULL;
g_autoptr (WpProxy) parent = NULL; g_autoptr (WpProxy) parent = NULL;
g_autoptr (WpProxyRegistry) reg = NULL; WpProxyRegistry *reg = NULL;
DefaultSession *session; DefaultSession *session;
if (wp_proxy_get_spa_type (proxy) != PW_TYPE_INTERFACE_Port && if (wp_proxy_get_spa_type (proxy) != PW_TYPE_INTERFACE_Port &&

View File

@@ -85,7 +85,7 @@ static gboolean
wp_core_parse_commands_file (WpCore * self, GInputStream * stream, wp_core_parse_commands_file (WpCore * self, GInputStream * stream,
GError ** error) GError ** error)
{ {
g_autoptr (WpPluginRegistry) plugin_registry = NULL; WpPluginRegistry *plugin_registry = NULL;
gchar buffer[4096]; gchar buffer[4096];
gssize bytes_read; gssize bytes_read;
gchar *cur, *linestart, *saveptr; gchar *cur, *linestart, *saveptr;
@@ -231,8 +231,8 @@ static void
wp_core_dispose (GObject * obj) wp_core_dispose (GObject * obj)
{ {
WpCore *self = WP_CORE (obj); WpCore *self = WP_CORE (obj);
g_autoptr (WpPluginRegistry) plugin_registry = NULL; WpPluginRegistry *plugin_registry = NULL;
g_autoptr (WpProxyRegistry) proxy_registry = NULL; WpProxyRegistry *proxy_registry = NULL;
/* ensure all proxies and plugins are unrefed, /* ensure all proxies and plugins are unrefed,
* so that the registries can be disposed */ * so that the registries can be disposed */

View File

@@ -139,9 +139,7 @@ wp_plugin_registry_impl_unload (WpPluginRegistryImpl * self)
static inline void static inline void
make_plugin (WpPluginRegistryImpl * self, PluginData * plugin_data) make_plugin (WpPluginRegistryImpl * self, PluginData * plugin_data)
{ {
g_autoptr (WpObject) core = WpObject *core = wp_interface_impl_get_object (WP_INTERFACE_IMPL (self));
wp_interface_impl_get_object (WP_INTERFACE_IMPL (self));
plugin_data->instance = g_object_new (plugin_data->gtype, plugin_data->instance = g_object_new (plugin_data->gtype,
"core", core, "metadata", plugin_data->metadata, NULL); "core", core, "metadata", plugin_data->metadata, NULL);
} }

View File

@@ -88,9 +88,8 @@ registry_global (void * data, uint32_t id, uint32_t parent_id,
{ {
WpProxyRegistryImpl *self = WP_PROXY_REGISTRY_IMPL (data); WpProxyRegistryImpl *self = WP_PROXY_REGISTRY_IMPL (data);
WpProxy *proxy; WpProxy *proxy;
g_autoptr (WpPluginRegistry) plugin_registry = NULL; WpPluginRegistry *plugin_registry = NULL;
g_autoptr (WpObject) core = WpObject *core = wp_interface_impl_get_object (WP_INTERFACE_IMPL (self));
wp_interface_impl_get_object (WP_INTERFACE_IMPL (self));
proxy = g_object_new (WP_TYPE_PROXY, proxy = g_object_new (WP_TYPE_PROXY,
"id", id, "id", id,

View File

@@ -104,8 +104,8 @@ register_session (WpSessionRegistry * sr,
GError ** error) GError ** error)
{ {
WpSessionRegistryImpl * self = WP_SESSION_REGISTRY_IMPL (sr); WpSessionRegistryImpl * self = WP_SESSION_REGISTRY_IMPL (sr);
g_autoptr (WpPluginRegistry) plugin_registry = NULL; WpPluginRegistry *plugin_registry = NULL;
g_autoptr (WpPipewireProperties) pw_props = NULL; WpPipewireProperties *pw_props = NULL;
const gchar *media_class = NULL; const gchar *media_class = NULL;
SessionData data; SessionData data;