Commit cc4a2e45 authored by Julian Bouzas's avatar Julian Bouzas
Browse files

factory-proxy: make WpNode, WpDevice and WpLink subclasses

parent 68f5f61b
Pipeline #319472 passed with stages
in 1 minute and 16 seconds
......@@ -27,7 +27,7 @@
struct _WpDevice
{
WpGlobalProxy parent;
WpFactoryProxy parent;
};
static void wp_device_pw_object_mixin_priv_interface_init (
......@@ -45,9 +45,7 @@ static void wp_device_pw_object_mixin_priv_interface_init (
* wp_device_new_from_factory(), which creates a new device object
* on the remote PipeWire server by calling into a factory.
*/
G_DEFINE_TYPE_WITH_CODE (WpDevice, wp_device, WP_TYPE_GLOBAL_PROXY,
G_IMPLEMENT_INTERFACE (WP_TYPE_PIPEWIRE_OBJECT,
wp_pw_object_mixin_object_interface_init)
G_DEFINE_TYPE_WITH_CODE (WpDevice, wp_device, WP_TYPE_FACTORY_PROXY,
G_IMPLEMENT_INTERFACE (WP_TYPE_PW_OBJECT_MIXIN_PRIV,
wp_device_pw_object_mixin_priv_interface_init));
......@@ -56,36 +54,6 @@ wp_device_init (WpDevice * self)
{
}
static void
wp_device_activate_execute_step (WpObject * object,
WpFeatureActivationTransition * transition, guint step,
WpObjectFeatures missing)
{
switch (step) {
case WP_PW_OBJECT_MIXIN_STEP_BIND:
case WP_TRANSITION_STEP_ERROR:
/* base class can handle BIND and ERROR */
WP_OBJECT_CLASS (wp_device_parent_class)->
activate_execute_step (object, transition, step, missing);
break;
case WP_PW_OBJECT_MIXIN_STEP_WAIT_INFO:
/* just wait, info will be emitted anyway after binding */
break;
case WP_PW_OBJECT_MIXIN_STEP_CACHE_PARAMS:
wp_pw_object_mixin_cache_params (object, missing);
break;
default:
g_assert_not_reached ();
}
}
static void
wp_device_deactivate (WpObject * object, WpObjectFeatures features)
{
wp_pw_object_mixin_deactivate (object, features);
WP_OBJECT_CLASS (wp_device_parent_class)->deactivate (object, features);
}
static const struct pw_device_events device_events = {
PW_VERSION_DEVICE_EVENTS,
.info = (HandleEventInfoFunc(device)) wp_pw_object_mixin_handle_event_info,
......@@ -99,36 +67,14 @@ wp_device_pw_proxy_created (WpProxy * proxy, struct pw_proxy * pw_proxy)
device, &device_events);
}
static void
wp_device_pw_proxy_destroyed (WpProxy * proxy)
{
wp_pw_object_mixin_handle_pw_proxy_destroyed (proxy);
WP_PROXY_CLASS (wp_device_parent_class)->pw_proxy_destroyed (proxy);
}
static void
wp_device_class_init (WpDeviceClass * klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
WpObjectClass *wpobject_class = (WpObjectClass *) klass;
WpProxyClass *proxy_class = (WpProxyClass *) klass;
object_class->get_property = wp_pw_object_mixin_get_property;
wpobject_class->get_supported_features =
wp_pw_object_mixin_get_supported_features;
wpobject_class->activate_get_next_step =
wp_pw_object_mixin_activate_get_next_step;
wpobject_class->activate_execute_step = wp_device_activate_execute_step;
wpobject_class->deactivate = wp_device_deactivate;
proxy_class->pw_iface_type = PW_TYPE_INTERFACE_Device;
proxy_class->pw_iface_version = PW_VERSION_DEVICE;
proxy_class->pw_proxy_created = wp_device_pw_proxy_created;
proxy_class->pw_proxy_destroyed = wp_device_pw_proxy_destroyed;
wp_pw_object_mixin_class_override_properties (object_class);
}
static gint
......@@ -182,20 +128,11 @@ wp_device_new_from_factory (WpCore * core,
const gchar * factory_name, WpProperties * properties)
{
g_autoptr (WpProperties) props = properties;
WpDevice *self = NULL;
struct pw_core *pw_core = wp_core_get_pw_core (core);
if (G_UNLIKELY (!pw_core)) {
g_critical ("The WirePlumber core is not connected; "
"device cannot be created");
return NULL;
}
self = g_object_new (WP_TYPE_DEVICE, "core", core, NULL);
wp_proxy_set_pw_proxy (WP_PROXY (self), pw_core_create_object (pw_core,
factory_name, PW_TYPE_INTERFACE_Device, PW_VERSION_DEVICE,
props ? wp_properties_peek_dict (props) : NULL, 0));
return self;
return g_object_new (WP_TYPE_DEVICE,
"core", core,
"factory-name", factory_name,
"factory-props", props,
NULL);
}
......
......@@ -9,7 +9,7 @@
#ifndef __WIREPLUMBER_DEVICE_H__
#define __WIREPLUMBER_DEVICE_H__
#include "global-proxy.h"
#include "factory-proxy.h"
G_BEGIN_DECLS
......@@ -22,7 +22,7 @@ G_BEGIN_DECLS
*/
#define WP_TYPE_DEVICE (wp_device_get_type ())
WP_API
G_DECLARE_FINAL_TYPE (WpDevice, wp_device, WP, DEVICE, WpGlobalProxy)
G_DECLARE_FINAL_TYPE (WpDevice, wp_device, WP, DEVICE, WpFactoryProxy)
WP_API
WpDevice * wp_device_new_from_factory (WpCore * core,
......
......@@ -18,7 +18,7 @@
struct _WpLink
{
WpGlobalProxy parent;
WpFactoryProxy parent;
};
static void wp_link_pw_object_mixin_priv_interface_init (
......@@ -36,9 +36,7 @@ static void wp_link_pw_object_mixin_priv_interface_init (
* wp_link_new_from_factory(), which creates a new link object
* on the remote PipeWire server by calling into a factory.
*/
G_DEFINE_TYPE_WITH_CODE (WpLink, wp_link, WP_TYPE_GLOBAL_PROXY,
G_IMPLEMENT_INTERFACE (WP_TYPE_PIPEWIRE_OBJECT,
wp_pw_object_mixin_object_interface_init)
G_DEFINE_TYPE_WITH_CODE (WpLink, wp_link, WP_TYPE_FACTORY_PROXY,
G_IMPLEMENT_INTERFACE (WP_TYPE_PW_OBJECT_MIXIN_PRIV,
wp_link_pw_object_mixin_priv_interface_init))
......@@ -47,26 +45,6 @@ wp_link_init (WpLink * self)
{
}
static void
wp_link_activate_execute_step (WpObject * object,
WpFeatureActivationTransition * transition, guint step,
WpObjectFeatures missing)
{
switch (step) {
case WP_PW_OBJECT_MIXIN_STEP_BIND:
case WP_TRANSITION_STEP_ERROR:
/* base class can handle BIND and ERROR */
WP_OBJECT_CLASS (wp_link_parent_class)->
activate_execute_step (object, transition, step, missing);
break;
case WP_PW_OBJECT_MIXIN_STEP_WAIT_INFO:
/* just wait, info will be emitted anyway after binding */
break;
default:
g_assert_not_reached ();
}
}
static const struct pw_link_events link_events = {
PW_VERSION_LINK_EVENTS,
.info = (HandleEventInfoFunc(link)) wp_pw_object_mixin_handle_event_info,
......@@ -79,35 +57,14 @@ wp_link_pw_proxy_created (WpProxy * proxy, struct pw_proxy * pw_proxy)
link, &link_events);
}
static void
wp_link_pw_proxy_destroyed (WpProxy * proxy)
{
wp_pw_object_mixin_handle_pw_proxy_destroyed (proxy);
WP_PROXY_CLASS (wp_link_parent_class)->pw_proxy_destroyed (proxy);
}
static void
wp_link_class_init (WpLinkClass * klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
WpObjectClass *wpobject_class = (WpObjectClass *) klass;
WpProxyClass *proxy_class = (WpProxyClass *) klass;
object_class->get_property = wp_pw_object_mixin_get_property;
wpobject_class->get_supported_features =
wp_pw_object_mixin_get_supported_features;
wpobject_class->activate_get_next_step =
wp_pw_object_mixin_activate_get_next_step;
wpobject_class->activate_execute_step = wp_link_activate_execute_step;
proxy_class->pw_iface_type = PW_TYPE_INTERFACE_Link;
proxy_class->pw_iface_version = PW_VERSION_LINK;
proxy_class->pw_proxy_created = wp_link_pw_proxy_created;
proxy_class->pw_proxy_destroyed = wp_link_pw_proxy_destroyed;
wp_pw_object_mixin_class_override_properties (object_class);
}
static void
......@@ -141,19 +98,11 @@ wp_link_new_from_factory (WpCore * core,
const gchar * factory_name, WpProperties * properties)
{
g_autoptr (WpProperties) props = properties;
WpLink *self = NULL;
struct pw_core *pw_core = wp_core_get_pw_core (core);
if (G_UNLIKELY (!pw_core)) {
g_critical ("The WirePlumber core is not connected; link cannot be created");
return NULL;
}
self = g_object_new (WP_TYPE_LINK, "core", core, NULL);
wp_proxy_set_pw_proxy (WP_PROXY (self), pw_core_create_object (pw_core,
factory_name, PW_TYPE_INTERFACE_Link, PW_VERSION_LINK,
props ? wp_properties_peek_dict (props) : NULL, 0));
return self;
return g_object_new (WP_TYPE_LINK,
"core", core,
"factory-name", factory_name,
"factory-props", props,
NULL);
}
/**
......
......@@ -9,7 +9,7 @@
#ifndef __WIREPLUMBER_LINK_H__
#define __WIREPLUMBER_LINK_H__
#include "global-proxy.h"
#include "factory-proxy.h"
G_BEGIN_DECLS
......@@ -20,7 +20,7 @@ G_BEGIN_DECLS
*/
#define WP_TYPE_LINK (wp_link_get_type ())
WP_API
G_DECLARE_FINAL_TYPE (WpLink, wp_link, WP, LINK, WpGlobalProxy)
G_DECLARE_FINAL_TYPE (WpLink, wp_link, WP, LINK, WpFactoryProxy)
WP_API
WpLink * wp_link_new_from_factory (WpCore * core,
......
......@@ -32,7 +32,7 @@ static guint32 signals[N_SIGNALS] = {0};
struct _WpNode
{
WpGlobalProxy parent;
WpFactoryProxy parent;
WpObjectManager *ports_om;
};
......@@ -51,9 +51,7 @@ static void wp_node_pw_object_mixin_priv_interface_init (
* wp_node_new_from_factory(), which creates a new node object
* on the remote PipeWire server by calling into a factory.
*/
G_DEFINE_TYPE_WITH_CODE (WpNode, wp_node, WP_TYPE_GLOBAL_PROXY,
G_IMPLEMENT_INTERFACE (WP_TYPE_PIPEWIRE_OBJECT,
wp_pw_object_mixin_object_interface_init)
G_DEFINE_TYPE_WITH_CODE (WpNode, wp_node, WP_TYPE_FACTORY_PROXY,
G_IMPLEMENT_INTERFACE (WP_TYPE_PW_OBJECT_MIXIN_PRIV,
wp_node_pw_object_mixin_priv_interface_init))
......@@ -116,31 +114,18 @@ wp_node_activate_execute_step (WpObject * object,
WpObjectFeatures missing)
{
switch (step) {
case WP_PW_OBJECT_MIXIN_STEP_BIND:
case WP_TRANSITION_STEP_ERROR:
/* base class can handle BIND and ERROR */
WP_OBJECT_CLASS (wp_node_parent_class)->
activate_execute_step (object, transition, step, missing);
break;
case WP_PW_OBJECT_MIXIN_STEP_WAIT_INFO:
/* just wait, info will be emitted anyway after binding */
break;
case WP_PW_OBJECT_MIXIN_STEP_CACHE_PARAMS:
wp_pw_object_mixin_cache_params (object, missing);
break;
case STEP_PORTS:
wp_node_enable_feature_ports (WP_NODE (object));
break;
default:
g_assert_not_reached ();
WP_OBJECT_CLASS (wp_node_parent_class)->
activate_execute_step (object, transition, step, missing);
}
}
static void
wp_node_deactivate (WpObject * object, WpObjectFeatures features)
{
wp_pw_object_mixin_deactivate (object, features);
if (features & WP_NODE_FEATURE_PORTS) {
WpNode *self = WP_NODE (object);
g_clear_object (&self->ports_om);
......@@ -168,8 +153,6 @@ wp_node_pw_proxy_destroyed (WpProxy * proxy)
{
WpNode *self = WP_NODE (proxy);
wp_pw_object_mixin_handle_pw_proxy_destroyed (proxy);
g_clear_object (&self->ports_om);
wp_object_update_features (WP_OBJECT (self), 0, WP_NODE_FEATURE_PORTS);
......@@ -179,15 +162,10 @@ wp_node_pw_proxy_destroyed (WpProxy * proxy)
static void
wp_node_class_init (WpNodeClass * klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
WpObjectClass *wpobject_class = (WpObjectClass *) klass;
WpProxyClass *proxy_class = (WpProxyClass *) klass;
object_class->get_property = wp_pw_object_mixin_get_property;
wpobject_class->get_supported_features = wp_node_get_supported_features;
wpobject_class->activate_get_next_step =
wp_pw_object_mixin_activate_get_next_step;
wpobject_class->activate_execute_step = wp_node_activate_execute_step;
wpobject_class->deactivate = wp_node_deactivate;
......@@ -196,8 +174,6 @@ wp_node_class_init (WpNodeClass * klass)
proxy_class->pw_proxy_created = wp_node_pw_proxy_created;
proxy_class->pw_proxy_destroyed = wp_node_pw_proxy_destroyed;
wp_pw_object_mixin_class_override_properties (object_class);
/**
* WpNode::state-changed:
* @self: the node
......@@ -289,19 +265,11 @@ wp_node_new_from_factory (WpCore * core,
const gchar * factory_name, WpProperties * properties)
{
g_autoptr (WpProperties) props = properties;
WpNode *self = NULL;
struct pw_core *pw_core = wp_core_get_pw_core (core);
if (G_UNLIKELY (!pw_core)) {
g_critical ("The WirePlumber core is not connected; node cannot be created");
return NULL;
}
self = g_object_new (WP_TYPE_NODE, "core", core, NULL);
wp_proxy_set_pw_proxy (WP_PROXY (self), pw_core_create_object (pw_core,
factory_name, PW_TYPE_INTERFACE_Node, PW_VERSION_NODE,
props ? wp_properties_peek_dict (props) : NULL, 0));
return self;
return g_object_new (WP_TYPE_NODE,
"core", core,
"factory-name", factory_name,
"factory-props", props,
NULL);
}
WpNodeState
......
......@@ -9,7 +9,7 @@
#ifndef __WIREPLUMBER_NODE_H__
#define __WIREPLUMBER_NODE_H__
#include "global-proxy.h"
#include "factory-proxy.h"
#include "port.h"
#include "iterator.h"
#include "object-interest.h"
......@@ -53,7 +53,7 @@ typedef enum { /*< flags >*/
*/
#define WP_TYPE_NODE (wp_node_get_type ())
WP_API
G_DECLARE_FINAL_TYPE (WpNode, wp_node, WP, NODE, WpGlobalProxy)
G_DECLARE_FINAL_TYPE (WpNode, wp_node, WP, NODE, WpFactoryProxy)
WP_API
WpNode * wp_node_new_from_factory (WpCore * core,
......
......@@ -242,8 +242,7 @@ test_si_standard_link_main (TestFixture * f, gconstpointer user_data)
wp_object_manager_add_interest (om, WP_TYPE_LINK, NULL);
wp_object_manager_request_object_features (om, WP_TYPE_PROXY,
WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL);
test_ensure_object_manager_is_installed (om, f->base.client_core,
f->base.loop);
test_ensure_object_manager_is_installed (om, f->base.core, f->base.loop);
g_assert_nonnull (out_node = wp_object_manager_lookup (om, WP_TYPE_NODE,
WP_CONSTRAINT_TYPE_PW_PROPERTY, "node.name", "=s", "control.audiotestsrc",
......@@ -303,8 +302,7 @@ test_si_standard_link_main (TestFixture * f, gconstpointer user_data)
wp_object_manager_add_interest (om, WP_TYPE_LINK, NULL);
wp_object_manager_request_object_features (om, WP_TYPE_PROXY,
WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL);
test_ensure_object_manager_is_installed (om, f->base.client_core,
f->base.loop);
test_ensure_object_manager_is_installed (om, f->base.core, f->base.loop);
g_assert_nonnull (out_node = wp_object_manager_lookup (om, WP_TYPE_NODE,
WP_CONSTRAINT_TYPE_PW_PROPERTY, "node.name", "=s", "control.audiotestsrc",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment