device: add new wp_spa_device_managed_object_new_iterator API

This commit is contained in:
Julian Bouzas 2022-06-16 15:27:31 -04:00 committed by George Kiagiadakis
parent c86410e708
commit 04198820f1
3 changed files with 29 additions and 0 deletions

View file

@ -638,6 +638,23 @@ wp_spa_device_get_properties (WpSpaDevice * self)
return wp_properties_ref (self->properties);
}
/*!
* \brief Iterates through all the objects managed by this device.
*
* \ingroup wpspadevice
* \param self the spa device
* \returns (transfer full): a WpIterator that iterates over all the objects
* managed by this device
* \since 0.4.11
*/
WpIterator *
wp_spa_device_new_managed_object_iterator (WpSpaDevice * self)
{
g_return_val_if_fail (WP_IS_SPA_DEVICE (self), NULL);
return wp_iterator_new_ptr_array (g_ptr_array_ref (self->managed_objs),
G_TYPE_OBJECT);
}
/*!
* \brief Gets one of the objects managed by this device.
*

View file

@ -57,6 +57,9 @@ WpSpaDevice * wp_spa_device_new_from_spa_factory (WpCore * core,
WP_API
WpProperties * wp_spa_device_get_properties (WpSpaDevice * self);
WP_API
WpIterator * wp_spa_device_new_managed_object_iterator (WpSpaDevice * self);
WP_API
GObject * wp_spa_device_get_managed_object (WpSpaDevice * self, guint id);

View file

@ -910,6 +910,14 @@ spa_device_new (lua_State *L)
return d ? 1 : 0;
}
static int
spa_device_iterate_managed_objects (lua_State *L)
{
WpSpaDevice *device = wplua_checkobject (L, 1, WP_TYPE_SPA_DEVICE);
WpIterator *it = wp_spa_device_new_managed_object_iterator (device);
return push_wpiterator (L, it);
}
static int
spa_device_get_managed_object (lua_State *L)
{
@ -934,6 +942,7 @@ spa_device_store_managed_object (lua_State *L)
}
static const luaL_Reg spa_device_methods[] = {
{ "iterate_managed_objects", spa_device_iterate_managed_objects },
{ "get_managed_object", spa_device_get_managed_object },
{ "store_managed_object", spa_device_store_managed_object },
{ NULL, NULL }