wp: remove WpSessionBin
This is no longer used and likely not very useful now that we have a simpler design. We can re-add it in the future if necessary, but let's keep it out of the 0.4 release.
This commit is contained in:
@@ -22,7 +22,6 @@ wp_lib_sources = files(
|
||||
'proxy.c',
|
||||
'proxy-interfaces.c',
|
||||
'session.c',
|
||||
'session-bin.c',
|
||||
'session-item.c',
|
||||
'si-factory.c',
|
||||
'si-interfaces.c',
|
||||
@@ -57,7 +56,6 @@ wp_lib_headers = files(
|
||||
'proxy.h',
|
||||
'proxy-interfaces.h',
|
||||
'session.h',
|
||||
'session-bin.h',
|
||||
'session-item.h',
|
||||
'si-factory.h',
|
||||
'si-interfaces.h',
|
||||
|
@@ -1,186 +0,0 @@
|
||||
/* WirePlumber
|
||||
*
|
||||
* Copyright © 2019 Collabora Ltd.
|
||||
* @author Julian Bouzas <julian.bouzas@collabora.com>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION: session-bin
|
||||
* @title: Session Item Bin
|
||||
*/
|
||||
|
||||
#define G_LOG_DOMAIN "wp-sb"
|
||||
|
||||
#include "session-bin.h"
|
||||
|
||||
typedef struct _WpSessionBinPrivate WpSessionBinPrivate;
|
||||
struct _WpSessionBinPrivate
|
||||
{
|
||||
GPtrArray *items;
|
||||
};
|
||||
|
||||
/**
|
||||
* WpSessionBin:
|
||||
*/
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (WpSessionBin, wp_session_bin, WP_TYPE_SESSION_ITEM)
|
||||
|
||||
static void
|
||||
si_session_bin_reset (WpSessionItem * item)
|
||||
{
|
||||
WpSessionBin * self = WP_SESSION_BIN (item);
|
||||
WpSessionBinPrivate *priv = wp_session_bin_get_instance_private (self);
|
||||
|
||||
WP_SESSION_ITEM_CLASS (wp_session_bin_parent_class)->reset (item);
|
||||
|
||||
g_ptr_array_set_size (priv->items, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
wp_session_bin_finalize (GObject * object)
|
||||
{
|
||||
WpSessionBin * self = WP_SESSION_BIN (object);
|
||||
WpSessionBinPrivate *priv = wp_session_bin_get_instance_private (self);
|
||||
|
||||
g_clear_pointer (&priv->items, g_ptr_array_unref);
|
||||
|
||||
G_OBJECT_CLASS (wp_session_bin_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
wp_session_bin_init (WpSessionBin * self)
|
||||
{
|
||||
WpSessionBinPrivate *priv = wp_session_bin_get_instance_private (self);
|
||||
priv->items = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
wp_session_bin_class_init (WpSessionBinClass * klass)
|
||||
{
|
||||
GObjectClass *object_class = (GObjectClass *) klass;
|
||||
WpSessionItemClass *si_class = (WpSessionItemClass *) klass;
|
||||
|
||||
object_class->finalize = wp_session_bin_finalize;
|
||||
|
||||
si_class->reset = si_session_bin_reset;
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_session_bin_add:
|
||||
* @self: the session bin
|
||||
* @item (transfer full): the session item to be added
|
||||
*
|
||||
* Adds a session item into a session bin.
|
||||
*
|
||||
* Returns: TRUE if the item was added into the session bin, FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
wp_session_bin_add (WpSessionBin *self, WpSessionItem *item)
|
||||
{
|
||||
WpSessionBinPrivate *priv = wp_session_bin_get_instance_private (self);
|
||||
|
||||
guint index;
|
||||
if (g_ptr_array_find (priv->items, item, &index))
|
||||
return FALSE;
|
||||
|
||||
g_ptr_array_add (priv->items, item);
|
||||
wp_session_item_set_parent (item, WP_SESSION_ITEM (self));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_session_bin_remove:
|
||||
* @self: the session bin
|
||||
* @item (transfer none): the session item to be removed
|
||||
*
|
||||
* Removes a session item from a session bin.
|
||||
*
|
||||
* Returns: TRUE if the item was removed from the session bin, FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
wp_session_bin_remove (WpSessionBin *self, WpSessionItem *item)
|
||||
{
|
||||
WpSessionBinPrivate *priv = wp_session_bin_get_instance_private (self);
|
||||
wp_session_item_set_parent (item, NULL);
|
||||
return g_ptr_array_remove_fast (priv->items, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_session_bin_get_n_children:
|
||||
* @self: the session bin
|
||||
*
|
||||
* Returns: the number of child items in the bin
|
||||
*/
|
||||
guint
|
||||
wp_session_bin_get_n_children (WpSessionBin *self)
|
||||
{
|
||||
WpSessionBinPrivate *priv = wp_session_bin_get_instance_private (self);
|
||||
return priv->items->len;
|
||||
}
|
||||
|
||||
struct _WpSessionBinIterator
|
||||
{
|
||||
WpSessionBin *bin;
|
||||
guint index;
|
||||
};
|
||||
typedef struct _WpSessionBinIterator WpSessionBinIterator;
|
||||
|
||||
static void
|
||||
wp_session_bin_iterator_reset (WpIterator *iterator)
|
||||
{
|
||||
WpSessionBinIterator *self = wp_iterator_get_user_data (iterator);
|
||||
self->index = 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
wp_session_bin_iterator_next (WpIterator *iterator, GValue *item)
|
||||
{
|
||||
WpSessionBinIterator *self = wp_iterator_get_user_data (iterator);
|
||||
WpSessionBinPrivate *priv = wp_session_bin_get_instance_private (self->bin);
|
||||
|
||||
g_return_val_if_fail (item, FALSE);
|
||||
|
||||
if (self->index < priv->items->len) {
|
||||
g_value_init_from_instance (item,
|
||||
g_ptr_array_index (priv->items, self->index++));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
wp_session_bin_iterator_finalize (WpIterator *iterator)
|
||||
{
|
||||
WpSessionBinIterator *self = wp_iterator_get_user_data (iterator);
|
||||
g_clear_object (&self->bin);
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_session_bin_new_iterator:
|
||||
* @self: the session bin
|
||||
* @item (transfer none): the session item to be removed
|
||||
*
|
||||
* Gets an iterator to iterate throught all session items.
|
||||
*
|
||||
* Returns (transfer full): The session bin iterator.
|
||||
*/
|
||||
WpIterator *
|
||||
wp_session_bin_new_iterator (WpSessionBin *self)
|
||||
{
|
||||
static const WpIteratorMethods methods = {
|
||||
.version = WP_ITERATOR_METHODS_VERSION,
|
||||
.reset = wp_session_bin_iterator_reset,
|
||||
.next = wp_session_bin_iterator_next,
|
||||
.fold = NULL,
|
||||
.foreach = NULL,
|
||||
.finalize = wp_session_bin_iterator_finalize
|
||||
};
|
||||
WpIterator *ret = wp_iterator_new (&methods, sizeof (WpSessionBinIterator));
|
||||
WpSessionBinIterator *it = wp_iterator_get_user_data (ret);
|
||||
|
||||
it->bin = g_object_ref (self);
|
||||
|
||||
return ret;
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
/* WirePlumber
|
||||
*
|
||||
* Copyright © 2020 Collabora Ltd.
|
||||
* @author Julian Bouzas <julian.bouzas@collabora.com>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef __WIREPLUMBER_SESSION_BIN_H__
|
||||
#define __WIREPLUMBER_SESSION_BIN_H__
|
||||
|
||||
#include "session-item.h"
|
||||
#include "iterator.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* WP_TYPE_SESSION_BIN:
|
||||
*
|
||||
* The #WpSessionBin #GType
|
||||
*/
|
||||
#define WP_TYPE_SESSION_BIN (wp_session_bin_get_type ())
|
||||
WP_API
|
||||
G_DECLARE_DERIVABLE_TYPE (WpSessionBin, wp_session_bin, WP, SESSION_BIN,
|
||||
WpSessionItem)
|
||||
|
||||
/**
|
||||
* WpSessionBinClass:
|
||||
*/
|
||||
struct _WpSessionBinClass
|
||||
{
|
||||
WpSessionItemClass parent_class;
|
||||
};
|
||||
|
||||
WP_API
|
||||
gboolean wp_session_bin_add (WpSessionBin *self, WpSessionItem *item);
|
||||
|
||||
WP_API
|
||||
gboolean wp_session_bin_remove (WpSessionBin *self, WpSessionItem *item);
|
||||
|
||||
WP_API
|
||||
guint wp_session_bin_get_n_children (WpSessionBin *self);
|
||||
|
||||
WP_API
|
||||
WpIterator *wp_session_bin_new_iterator (WpSessionBin *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
@@ -27,7 +27,6 @@ typedef struct _WpSessionItemPrivate WpSessionItemPrivate;
|
||||
struct _WpSessionItemPrivate
|
||||
{
|
||||
guint id;
|
||||
GWeakRef parent;
|
||||
WpProperties *properties;
|
||||
};
|
||||
|
||||
@@ -57,7 +56,6 @@ wp_session_item_init (WpSessionItem * self)
|
||||
WpSessionItemPrivate *priv = wp_session_item_get_instance_private (self);
|
||||
|
||||
priv->id = get_next_id ();
|
||||
g_weak_ref_init (&priv->parent, NULL);
|
||||
priv->properties = NULL;
|
||||
}
|
||||
|
||||
@@ -81,17 +79,6 @@ wp_session_item_dispose (GObject * object)
|
||||
G_OBJECT_CLASS (wp_session_item_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
wp_session_item_finalize (GObject * object)
|
||||
{
|
||||
WpSessionItem * self = WP_SESSION_ITEM (object);
|
||||
WpSessionItemPrivate *priv = wp_session_item_get_instance_private (self);
|
||||
|
||||
g_weak_ref_clear (&priv->parent);
|
||||
|
||||
G_OBJECT_CLASS (wp_session_item_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
wp_session_item_get_property (GObject * object, guint property_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
@@ -206,7 +193,6 @@ wp_session_item_class_init (WpSessionItemClass * klass)
|
||||
GObjectClass * object_class = (GObjectClass *) klass;
|
||||
|
||||
object_class->dispose = wp_session_item_dispose;
|
||||
object_class->finalize = wp_session_item_finalize;
|
||||
object_class->get_property = wp_session_item_get_property;
|
||||
|
||||
wpobject_class->get_supported_features =
|
||||
@@ -230,44 +216,6 @@ wp_session_item_class_init (WpSessionItemClass * klass)
|
||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_session_item_get_parent:
|
||||
* @self: the session item
|
||||
*
|
||||
* Gets the item's parent, which is the #WpSessionBin this item has been added
|
||||
* to, or NULL if the item does not belong to a session bin.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): the item's parent.
|
||||
*/
|
||||
WpSessionItem *
|
||||
wp_session_item_get_parent (WpSessionItem * self)
|
||||
{
|
||||
g_return_val_if_fail (WP_IS_SESSION_ITEM (self), NULL);
|
||||
WpSessionItemPrivate *priv =
|
||||
wp_session_item_get_instance_private (self);
|
||||
|
||||
return g_weak_ref_get (&priv->parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_session_item_set_parent:
|
||||
* @self: the session item
|
||||
* @parent: (transfer none): the parent item
|
||||
*
|
||||
* Private API.
|
||||
* Sets the item's parent; used internally by #WpSessionBin.
|
||||
*/
|
||||
void
|
||||
wp_session_item_set_parent (WpSessionItem *self, WpSessionItem *parent)
|
||||
{
|
||||
WpSessionItemPrivate *priv = NULL;
|
||||
|
||||
g_return_if_fail (WP_IS_SESSION_ITEM (self));
|
||||
|
||||
priv = wp_session_item_get_instance_private (self);
|
||||
g_weak_ref_set (&priv->parent, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_session_item_get_id:
|
||||
* @self: the session item
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#include "proxy.h"
|
||||
#include "proxy-interfaces.h"
|
||||
#include "session.h"
|
||||
#include "session-bin.h"
|
||||
#include "session-item.h"
|
||||
#include "si-factory.h"
|
||||
#include "si-interfaces.h"
|
||||
|
@@ -1208,22 +1208,6 @@ static const luaL_Reg session_item_methods[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/* WpSessionBin */
|
||||
|
||||
static int
|
||||
session_bin_add (lua_State *L)
|
||||
{
|
||||
WpSessionBin *sb = wplua_checkobject (L, 1, WP_TYPE_SESSION_BIN);
|
||||
WpSessionItem *si = wplua_checkobject (L, 2, WP_TYPE_SESSION_ITEM);
|
||||
wp_session_bin_add (sb, g_object_ref (si));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const luaL_Reg session_bin_methods[] = {
|
||||
{ "add", session_bin_add },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/* WpPipewireObject */
|
||||
|
||||
static int
|
||||
@@ -1310,8 +1294,6 @@ wp_lua_scripting_api_init (lua_State *L)
|
||||
NULL, client_methods);
|
||||
wplua_register_type_methods (L, WP_TYPE_SESSION_ITEM,
|
||||
session_item_new, session_item_methods);
|
||||
wplua_register_type_methods (L, WP_TYPE_SESSION_BIN,
|
||||
NULL, session_bin_methods);
|
||||
wplua_register_type_methods (L, WP_TYPE_PIPEWIRE_OBJECT,
|
||||
NULL, pipewire_object_methods);
|
||||
|
||||
|
Reference in New Issue
Block a user