Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author Julian Bouzas <julian.bouzas@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#include "proxy-node.h"
#include <pipewire/pipewire.h>
struct _WpProxyNode
{
WpProxy parent;
/* The node proxy listener */
struct spa_hook listener;
/* The node info */
struct pw_node_info *info;
};
static GAsyncInitableIface *proxy_node_parent_interface = NULL;
static void wp_proxy_node_async_initable_init (gpointer iface,
gpointer iface_data);
G_DEFINE_TYPE_WITH_CODE (WpProxyNode, wp_proxy_node, WP_TYPE_PROXY,
G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE,
wp_proxy_node_async_initable_init))
static void
node_event_info(void *data, const struct pw_node_info *info)
{
WpProxyNode *self = data;
/* Update the node info */
self->info = pw_node_info_update(self->info, info);
}
static const struct pw_node_proxy_events node_events = {
PW_VERSION_NODE_PROXY_EVENTS,
.info = node_event_info,
};
static void
wp_proxy_node_finalize (GObject * object)
{
WpProxyNode *self = WP_PROXY_NODE(object);
/* Remove the listener */
spa_hook_remove (&self->listener);
/* Clear the info */
if (self->info) {
pw_node_info_free(self->info);
self->info = NULL;
}
G_OBJECT_CLASS (wp_proxy_node_parent_class)->finalize (object);
}
static void
wp_proxy_node_init_async (GAsyncInitable *initable, int io_priority,
GCancellable *cancellable, GAsyncReadyCallback callback, gpointer data)
{
WpProxyNode *self = WP_PROXY_NODE(initable);
WpProxy *wp_proxy = WP_PROXY(initable);
struct pw_node_proxy *proxy = NULL;
/* Get the proxy from the base class */
proxy = wp_proxy_get_pw_proxy(wp_proxy);
/* Add the node proxy listener */
pw_node_proxy_add_listener(proxy, &self->listener, &node_events, self);
/* Call the parent interface */
proxy_node_parent_interface->init_async (initable, io_priority, cancellable,
callback, data);
}
static void
wp_proxy_node_async_initable_init (gpointer iface, gpointer iface_data)
{
GAsyncInitableIface *ai_iface = iface;
/* Set the parent interface */
proxy_node_parent_interface = g_type_interface_peek_parent (iface);
/* Only set the init_async */
ai_iface->init_async = wp_proxy_node_init_async;
}
static void
wp_proxy_node_init (WpProxyNode * self)
{
}
static void
wp_proxy_node_class_init (WpProxyNodeClass * klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
object_class->finalize = wp_proxy_node_finalize;
}
void
wp_proxy_node_new (WpCore *core, gpointer proxy,
GAsyncReadyCallback callback, gpointer user_data)
{
g_async_initable_new_async (
WP_TYPE_PROXY_NODE, G_PRIORITY_DEFAULT, NULL, callback, user_data,
"core", (gpointer) core,
"pw-proxy", proxy,
NULL);
}
WpProxyNode *
wp_proxy_node_new_finish(GObject *initable, GAsyncResult *res, GError **error)
{
GAsyncInitable *ai = G_ASYNC_INITABLE(initable);
return WP_PROXY_NODE(g_async_initable_new_finish(ai, res, error));
}
const struct pw_node_info *
wp_proxy_node_get_info (WpProxyNode * self)
{
return self->info;
}