modules: rename config-static-nodes to config-static-objects
This commit is contained in:
@@ -80,13 +80,13 @@ shared_library(
|
||||
)
|
||||
|
||||
shared_library(
|
||||
'wireplumber-module-config-static-nodes',
|
||||
'wireplumber-module-config-static-objects',
|
||||
[
|
||||
'module-config-static-nodes/parser-node.c',
|
||||
'module-config-static-nodes/context.c',
|
||||
'module-config-static-nodes.c',
|
||||
'module-config-static-objects/parser-node.c',
|
||||
'module-config-static-objects/context.c',
|
||||
'module-config-static-objects.c',
|
||||
],
|
||||
c_args : [common_c_args, '-DG_LOG_DOMAIN="m-config-static-nodes"'],
|
||||
c_args : [common_c_args, '-DG_LOG_DOMAIN="m-config-static-objects"'],
|
||||
install : true,
|
||||
install_dir : wireplumber_module_dir,
|
||||
dependencies : [wp_dep, wptoml_dep, pipewire_dep],
|
||||
|
@@ -1,24 +0,0 @@
|
||||
/* WirePlumber
|
||||
*
|
||||
* Copyright © 2019 Collabora Ltd.
|
||||
* @author Julian Bouzas <julian.bouzas@collabora.com>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef __WIREPLUMBER_CONFIG_STATIC_NODES_CONTEXT_H__
|
||||
#define __WIREPLUMBER_CONFIG_STATIC_NODES_CONTEXT_H__
|
||||
|
||||
#include <wp/wp.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define WP_TYPE_CONFIG_STATIC_NODES_CONTEXT (wp_config_static_nodes_context_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (WpConfigStaticNodesContext, wp_config_static_nodes_context,
|
||||
WP, CONFIG_STATIC_NODES_CONTEXT, WpPlugin);
|
||||
|
||||
WpConfigStaticNodesContext * wp_config_static_nodes_context_new (WpModule * module);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
@@ -8,11 +8,11 @@
|
||||
|
||||
#include <wp/wp.h>
|
||||
|
||||
#include "module-config-static-nodes/context.h"
|
||||
#include "module-config-static-objects/context.h"
|
||||
|
||||
WP_PLUGIN_EXPORT void
|
||||
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
|
||||
{
|
||||
WpConfigStaticNodesContext *ctx = wp_config_static_nodes_context_new (module);
|
||||
WpConfigStaticObjectsContext *ctx = wp_config_static_objects_context_new (module);
|
||||
wp_plugin_register (WP_PLUGIN (ctx));
|
||||
}
|
@@ -11,43 +11,43 @@
|
||||
#include "parser-node.h"
|
||||
#include "context.h"
|
||||
|
||||
struct _WpConfigStaticNodesContext
|
||||
struct _WpConfigStaticObjectsContext
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
WpObjectManager *devices_om;
|
||||
GPtrArray *static_nodes;
|
||||
GPtrArray *static_objects;
|
||||
};
|
||||
|
||||
enum {
|
||||
SIGNAL_NODE_CREATED,
|
||||
SIGNAL_OBJECT_CREATED,
|
||||
N_SIGNALS
|
||||
};
|
||||
|
||||
static guint signals[N_SIGNALS];
|
||||
|
||||
G_DEFINE_TYPE (WpConfigStaticNodesContext, wp_config_static_nodes_context,
|
||||
G_DEFINE_TYPE (WpConfigStaticObjectsContext, wp_config_static_objects_context,
|
||||
WP_TYPE_PLUGIN)
|
||||
|
||||
static void
|
||||
on_node_created (GObject * proxy, GAsyncResult * res, gpointer user_data)
|
||||
on_object_created (GObject * proxy, GAsyncResult * res, gpointer user_data)
|
||||
{
|
||||
WpConfigStaticNodesContext *self = user_data;
|
||||
WpConfigStaticObjectsContext *self = user_data;
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
if (!wp_proxy_augment_finish (WP_PROXY (proxy), res, &error)) {
|
||||
wp_warning_object (self, "failed to export node: %s", error->message);
|
||||
wp_warning_object (self, "failed to export object: %s", error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
g_ptr_array_add (self->static_nodes, g_object_ref (proxy));
|
||||
g_ptr_array_add (self->static_objects, g_object_ref (proxy));
|
||||
|
||||
/* Emit the node-created signal */
|
||||
g_signal_emit (self, signals[SIGNAL_NODE_CREATED], 0, proxy);
|
||||
g_signal_emit (self, signals[SIGNAL_OBJECT_CREATED], 0, proxy);
|
||||
}
|
||||
|
||||
static void
|
||||
wp_config_static_nodes_context_create_node (WpConfigStaticNodesContext *self,
|
||||
wp_config_static_objects_context_create_node (WpConfigStaticObjectsContext *self,
|
||||
const struct WpParserNodeData *node_data)
|
||||
{
|
||||
g_autoptr (WpProxy) node = NULL;
|
||||
@@ -66,13 +66,14 @@ wp_config_static_nodes_context_create_node (WpConfigStaticNodesContext *self,
|
||||
}
|
||||
|
||||
/* export */
|
||||
wp_proxy_augment (node, WP_PROXY_FEATURES_STANDARD, NULL, on_node_created, self);
|
||||
wp_proxy_augment (node, WP_PROXY_FEATURES_STANDARD, NULL, on_object_created,
|
||||
self);
|
||||
}
|
||||
|
||||
static void
|
||||
on_device_added (WpObjectManager *om, WpProxy *proxy, gpointer p)
|
||||
{
|
||||
WpConfigStaticNodesContext *self = p;
|
||||
WpConfigStaticObjectsContext *self = p;
|
||||
g_autoptr (WpProperties) dev_props = NULL;
|
||||
g_autoptr (WpCore) core = wp_plugin_get_core (WP_PLUGIN (self));
|
||||
g_autoptr (WpConfiguration) config = wp_configuration_get_instance (core);
|
||||
@@ -94,18 +95,18 @@ on_device_added (WpObjectManager *om, WpProxy *proxy, gpointer p)
|
||||
return;
|
||||
|
||||
/* Create the node */
|
||||
wp_config_static_nodes_context_create_node (self, node_data);
|
||||
wp_config_static_objects_context_create_node (self, node_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parser_node_foreach_func (const struct WpParserNodeData *node_data,
|
||||
gpointer data)
|
||||
{
|
||||
WpConfigStaticNodesContext *self = data;
|
||||
WpConfigStaticObjectsContext *self = data;
|
||||
|
||||
/* Only create nodes that don't have match-device info */
|
||||
if (!node_data->has_md) {
|
||||
wp_config_static_nodes_context_create_node (self, node_data);
|
||||
wp_config_static_objects_context_create_node (self, node_data);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -113,9 +114,9 @@ parser_node_foreach_func (const struct WpParserNodeData *node_data,
|
||||
}
|
||||
|
||||
static void
|
||||
wp_config_static_nodes_context_activate (WpPlugin * plugin)
|
||||
wp_config_static_objects_context_activate (WpPlugin * plugin)
|
||||
{
|
||||
WpConfigStaticNodesContext *self = WP_CONFIG_STATIC_NODES_CONTEXT (plugin);
|
||||
WpConfigStaticObjectsContext *self = WP_CONFIG_STATIC_OBJECTS_CONTEXT (plugin);
|
||||
g_autoptr (WpCore) core = wp_plugin_get_core (plugin);
|
||||
g_autoptr (WpConfiguration) config = wp_configuration_get_instance (core);
|
||||
g_autoptr (WpConfigParser) parser = NULL;
|
||||
@@ -135,12 +136,12 @@ wp_config_static_nodes_context_activate (WpPlugin * plugin)
|
||||
}
|
||||
|
||||
static void
|
||||
wp_config_static_nodes_context_deactivate (WpPlugin *plugin)
|
||||
wp_config_static_objects_context_deactivate (WpPlugin *plugin)
|
||||
{
|
||||
WpConfigStaticNodesContext *self = WP_CONFIG_STATIC_NODES_CONTEXT (plugin);
|
||||
WpConfigStaticObjectsContext *self = WP_CONFIG_STATIC_OBJECTS_CONTEXT (plugin);
|
||||
|
||||
g_clear_object (&self->devices_om);
|
||||
g_clear_pointer (&self->static_nodes, g_ptr_array_unref);
|
||||
g_clear_pointer (&self->static_objects, g_ptr_array_unref);
|
||||
|
||||
g_autoptr (WpCore) core = wp_plugin_get_core (plugin);
|
||||
if (core) {
|
||||
@@ -150,9 +151,9 @@ wp_config_static_nodes_context_deactivate (WpPlugin *plugin)
|
||||
}
|
||||
|
||||
static void
|
||||
wp_config_static_nodes_context_init (WpConfigStaticNodesContext *self)
|
||||
wp_config_static_objects_context_init (WpConfigStaticObjectsContext *self)
|
||||
{
|
||||
self->static_nodes = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
self->static_objects = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
self->devices_om = wp_object_manager_new ();
|
||||
|
||||
/* Only handle devices */
|
||||
@@ -164,23 +165,23 @@ wp_config_static_nodes_context_init (WpConfigStaticNodesContext *self)
|
||||
}
|
||||
|
||||
static void
|
||||
wp_config_static_nodes_context_class_init (WpConfigStaticNodesContextClass *klass)
|
||||
wp_config_static_objects_context_class_init (WpConfigStaticObjectsContextClass *klass)
|
||||
{
|
||||
WpPluginClass *plugin_class = (WpPluginClass *) klass;
|
||||
|
||||
plugin_class->activate = wp_config_static_nodes_context_activate;
|
||||
plugin_class->deactivate = wp_config_static_nodes_context_deactivate;
|
||||
plugin_class->activate = wp_config_static_objects_context_activate;
|
||||
plugin_class->deactivate = wp_config_static_objects_context_deactivate;
|
||||
|
||||
/* Signals */
|
||||
signals[SIGNAL_NODE_CREATED] = g_signal_new ("node-created",
|
||||
signals[SIGNAL_OBJECT_CREATED] = g_signal_new ("object-created",
|
||||
G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1, WP_TYPE_PROXY);
|
||||
}
|
||||
|
||||
WpConfigStaticNodesContext *
|
||||
wp_config_static_nodes_context_new (WpModule * module)
|
||||
WpConfigStaticObjectsContext *
|
||||
wp_config_static_objects_context_new (WpModule * module)
|
||||
{
|
||||
return g_object_new (wp_config_static_nodes_context_get_type (),
|
||||
return g_object_new (wp_config_static_objects_context_get_type (),
|
||||
"module", module,
|
||||
NULL);
|
||||
}
|
24
modules/module-config-static-objects/context.h
Normal file
24
modules/module-config-static-objects/context.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/* WirePlumber
|
||||
*
|
||||
* Copyright © 2019 Collabora Ltd.
|
||||
* @author Julian Bouzas <julian.bouzas@collabora.com>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef __WIREPLUMBER_CONFIG_STATIC_OBJECTS_CONTEXT_H__
|
||||
#define __WIREPLUMBER_CONFIG_STATIC_OBJECTS_CONTEXT_H__
|
||||
|
||||
#include <wp/wp.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define WP_TYPE_CONFIG_STATIC_OBJECTS_CONTEXT (wp_config_static_objects_context_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (WpConfigStaticObjectsContext, wp_config_static_objects_context,
|
||||
WP, CONFIG_STATIC_OBJECTS_CONTEXT, WpPlugin);
|
||||
|
||||
WpConfigStaticObjectsContext * wp_config_static_objects_context_new (WpModule * module);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
@@ -59,8 +59,8 @@ load-module C libwireplumber-module-si-audio-softdsp-endpoint
|
||||
#implements si-monitor-endpoint session item
|
||||
load-module C libwireplumber-module-si-monitor-endpoint
|
||||
|
||||
# Implements static nodes creation based on TOML configuration files
|
||||
load-module C libwireplumber-module-config-static-nodes
|
||||
# Implements static objects creation based on TOML configuration files
|
||||
load-module C libwireplumber-module-config-static-objects
|
||||
|
||||
# Implements endpoint creation based on TOML configuration files
|
||||
load-module C libwireplumber-module-config-endpoint
|
||||
|
@@ -10,10 +10,10 @@
|
||||
|
||||
typedef struct {
|
||||
WpBaseTestFixture base;
|
||||
} TestConfigStaticNodesFixture;
|
||||
} TestConfigStaticObjectsFixture;
|
||||
|
||||
static void
|
||||
config_static_nodes_setup (TestConfigStaticNodesFixture *self,
|
||||
config_static_objects_setup (TestConfigStaticObjectsFixture *self,
|
||||
gconstpointer data)
|
||||
{
|
||||
wp_base_test_fixture_setup (&self->base, 0);
|
||||
@@ -29,40 +29,40 @@ config_static_nodes_setup (TestConfigStaticNodesFixture *self,
|
||||
/* load wireplumber module */
|
||||
g_autoptr (GError) error = NULL;
|
||||
WpModule *module = wp_module_load (self->base.core, "C",
|
||||
"libwireplumber-module-config-static-nodes", NULL, &error);
|
||||
"libwireplumber-module-config-static-objects", NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_nonnull (module);
|
||||
}
|
||||
|
||||
static void
|
||||
config_static_nodes_teardown (TestConfigStaticNodesFixture *self,
|
||||
config_static_objects_teardown (TestConfigStaticObjectsFixture *self,
|
||||
gconstpointer data)
|
||||
{
|
||||
wp_base_test_fixture_teardown (&self->base);
|
||||
}
|
||||
|
||||
static void
|
||||
on_node_created (WpPlugin *ctx, WpProxy *proxy, TestConfigStaticNodesFixture *f)
|
||||
on_object_created (WpPlugin *ctx, WpProxy *proxy, TestConfigStaticObjectsFixture *f)
|
||||
{
|
||||
g_assert_nonnull (proxy);
|
||||
g_main_loop_quit (f->base.loop);
|
||||
}
|
||||
|
||||
static void
|
||||
basic (TestConfigStaticNodesFixture *f, gconstpointer data)
|
||||
basic (TestConfigStaticObjectsFixture *f, gconstpointer data)
|
||||
{
|
||||
/* Set the configuration path */
|
||||
g_autoptr (WpConfiguration) config = wp_configuration_get_instance (f->base.core);
|
||||
g_assert_nonnull (config);
|
||||
wp_configuration_add_path (config, "config-static-nodes/basic");
|
||||
wp_configuration_add_path (config, "config-static-objects/basic");
|
||||
|
||||
/* Find the plugin context and handle the node-created callback */
|
||||
/* Find the plugin context and handle the object-created callback */
|
||||
g_autoptr (WpObjectManager) om = wp_object_manager_new ();
|
||||
wp_object_manager_add_interest (om, WP_TYPE_PLUGIN, NULL);
|
||||
wp_core_install_object_manager (f->base.core, om);
|
||||
g_autoptr (WpPlugin) ctx = wp_object_manager_lookup (om, WP_TYPE_PLUGIN, NULL);
|
||||
g_assert_nonnull (ctx);
|
||||
g_signal_connect (ctx, "node-created", (GCallback) on_node_created, f);
|
||||
g_signal_connect (ctx, "object-created", (GCallback) on_object_created, f);
|
||||
|
||||
/* Activate */
|
||||
wp_plugin_activate (ctx);
|
||||
@@ -77,9 +77,9 @@ main (int argc, char *argv[])
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
wp_init (WP_INIT_ALL);
|
||||
|
||||
g_test_add ("/modules/config-static-nodes/basic",
|
||||
TestConfigStaticNodesFixture, NULL,
|
||||
config_static_nodes_setup, basic, config_static_nodes_teardown);
|
||||
g_test_add ("/modules/config-static-objects/basic",
|
||||
TestConfigStaticObjectsFixture, NULL,
|
||||
config_static_objects_setup, basic, config_static_objects_teardown);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
@@ -21,10 +21,10 @@ test(
|
||||
)
|
||||
|
||||
test(
|
||||
'test-config-static-nodes',
|
||||
executable('test-config-static-nodes',
|
||||
'test-config-static-objects',
|
||||
executable('test-config-static-objects',
|
||||
[
|
||||
'config-static-nodes.c',
|
||||
'config-static-objects.c',
|
||||
],
|
||||
dependencies: common_deps + [wptoml_dep], c_args: common_args),
|
||||
env: common_env,
|
||||
|
Reference in New Issue
Block a user