| 1 |
/* WirePlumber |
| 2 |
* |
| 3 |
* Copyright © 2022 Collabora Ltd. |
| 4 |
* @author George Kiagiadakis <[email protected]> |
| 5 |
* |
| 6 |
* SPDX-License-Identifier: MIT |
| 7 |
*/ |
| 8 |
|
| 9 |
#include <wp/wp.h> |
| 10 |
|
| 11 |
WP_DEFINE_LOCAL_LOG_TOPIC ("m-standard-event-source") |
| 12 |
|
| 13 |
/* |
| 14 |
* Module subscribes for certain object manager events to and pushes them as |
| 15 |
* events on to the Event Stack. |
| 16 |
*/ |
| 17 |
|
| 18 |
enum { |
| 19 |
ACTION_GET_OBJECT_MANAGER, |
| 20 |
ACTION_CREATE_EVENT, |
| 21 |
ACTION_PUSH_EVENT, |
| 22 |
ACTION_SCHEDULE_RESCAN, |
| 23 |
N_SIGNALS |
| 24 |
}; |
| 25 |
|
| 26 |
typedef enum { |
| 27 |
OBJECT_TYPE_PORT, |
| 28 |
OBJECT_TYPE_LINK, |
| 29 |
OBJECT_TYPE_NODE, |
| 30 |
OBJECT_TYPE_SESSION_ITEM, |
| 31 |
OBJECT_TYPE_CLIENT, |
| 32 |
OBJECT_TYPE_DEVICE, |
| 33 |
OBJECT_TYPE_METADATA, |
| 34 |
N_OBJECT_TYPES, |
| 35 |
OBJECT_TYPE_INVALID = N_OBJECT_TYPES |
| 36 |
} ObjectType; |
| 37 |
|
| 38 |
typedef enum { |
| 39 |
RESCAN_CONTEXT_LINKING, |
| 40 |
RESCAN_CONTEXT_DEFAULT_NODES, |
| 41 |
RESCAN_CONTEXT_MEDIA_ROLE_VOLUME, |
| 42 |
N_RESCAN_CONTEXTS, |
| 43 |
} RescanContext; |
| 44 |
|
| 45 |
static GType |
| 46 |
rescan_context_get_type (void) |
| 47 |
{ |
| 48 |
static gsize gtype_id = 0; |
| 49 |
static const GEnumValue values[] = { |
| 50 |
{ RESCAN_CONTEXT_LINKING, "RESCAN_CONTEXT_LINKING", "linking" }, |
| 51 |
{ RESCAN_CONTEXT_DEFAULT_NODES, "RESCAN_CONTEXT_DEFAULT_NODES", "default-nodes" }, |
| 52 |
{ RESCAN_CONTEXT_MEDIA_ROLE_VOLUME, "RESCAN_CONTEXT_MEDIA_ROLE_VOLUME", "media-role-volume" }, |
| 53 |
{ 0, NULL, NULL } |
| 54 |
}; |
| 55 |
if (g_once_init_enter (>ype_id)) { |
| 56 |
GType new_type = g_enum_register_static ( |
| 57 |
g_intern_static_string ("WpStandardEventSource_RescanContext"), |
| 58 |
values); |
| 59 |
g_once_init_leave (>ype_id, new_type); |
| 60 |
} |
| 61 |
return (GType) gtype_id; |
| 62 |
} |
| 63 |
#define TYPE_RESCAN_CONTEXT (rescan_context_get_type ()) |
| 64 |
|
| 65 |
struct _WpStandardEventSource |
| 66 |
{ |
| 67 |
WpPlugin parent; |
| 68 |
WpObjectManager *oms[N_OBJECT_TYPES]; |
| 69 |
WpEventHook *rescan_done_hook; |
| 70 |
gboolean rescan_scheduled[N_RESCAN_CONTEXTS]; |
| 71 |
gint n_oms_installed; |
| 72 |
}; |
| 73 |
|
| 74 |
static guint signals[N_SIGNALS] = {0}; |
| 75 |
|
| 76 |
G_DECLARE_FINAL_TYPE (WpStandardEventSource, wp_standard_event_source, |
| 77 |
WP, STANDARD_EVENT_SOURCE, WpPlugin) |
| 78 |
G_DEFINE_TYPE (WpStandardEventSource, wp_standard_event_source, WP_TYPE_PLUGIN) |
| 79 |
|
| 80 |
static void |
| 81 |
wp_standard_event_source_init (WpStandardEventSource * self) |
| 82 |
{ |
| 83 |
} |
| 84 |
|
| 85 |
static GType |
| 86 |
object_type_to_gtype (ObjectType type) |
| 87 |
{ |
| 88 |
switch (type) { |
| 89 |
case OBJECT_TYPE_PORT: return WP_TYPE_PORT; |
| 90 |
case OBJECT_TYPE_LINK: return WP_TYPE_LINK; |
| 91 |
case OBJECT_TYPE_NODE: return WP_TYPE_NODE; |
| 92 |
case OBJECT_TYPE_SESSION_ITEM: return WP_TYPE_SESSION_ITEM; |
| 93 |
case OBJECT_TYPE_CLIENT: return WP_TYPE_CLIENT; |
| 94 |
case OBJECT_TYPE_DEVICE: return WP_TYPE_DEVICE; |
| 95 |
case OBJECT_TYPE_METADATA: return WP_TYPE_METADATA; |
| 96 |
default: |
| 97 |
g_assert_not_reached (); |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
static ObjectType |
| 102 |
type_str_to_object_type (const gchar * type_str) |
| 103 |
{ |
| 104 |
if (!g_strcmp0 (type_str, "port")) |
| 105 |
return OBJECT_TYPE_PORT; |
| 106 |
else if (!g_strcmp0 (type_str, "link")) |
| 107 |
return OBJECT_TYPE_LINK; |
| 108 |
else if (!g_strcmp0 (type_str, "node")) |
| 109 |
return OBJECT_TYPE_NODE; |
| 110 |
else if (!g_strcmp0 (type_str, "session-item")) |
| 111 |
return OBJECT_TYPE_SESSION_ITEM; |
| 112 |
else if (!g_strcmp0 (type_str, "client")) |
| 113 |
return OBJECT_TYPE_CLIENT; |
| 114 |
else if (!g_strcmp0 (type_str, "device")) |
| 115 |
return OBJECT_TYPE_DEVICE; |
| 116 |
else if (!g_strcmp0 (type_str, "metadata")) |
| 117 |
return OBJECT_TYPE_METADATA; |
| 118 |
else |
| 119 |
return OBJECT_TYPE_INVALID; |
| 120 |
} |
| 121 |
|
| 122 |
static const gchar * |
| 123 |
get_object_type (gpointer obj, WpProperties **properties) |
| 124 |
{ |
| 125 |
/* keeping these sorted by the frequency of events related to these objects */ |
| 126 |
if (WP_IS_PORT (obj)) |
| 127 |
return "port"; |
| 128 |
else if (WP_IS_LINK (obj)) |
| 129 |
return "link"; |
| 130 |
else if (WP_IS_NODE (obj)) |
| 131 |
return "node"; |
| 132 |
else if (WP_IS_SESSION_ITEM (obj)) { |
| 133 |
if (*properties == NULL) |
| 134 |
*properties = wp_properties_new_empty(); |
| 135 |
|
| 136 |
if (WP_IS_SI_LINKABLE (obj)) { |
| 137 |
wp_properties_set (*properties, |
| 138 |
"event.session-item.interface", "linkable"); |
| 139 |
} else if (WP_IS_SI_LINK (obj)) { |
| 140 |
wp_properties_set (*properties, |
| 141 |
"event.session-item.interface", "link"); |
| 142 |
} |
| 143 |
return "session-item"; |
| 144 |
} |
| 145 |
else if (WP_IS_CLIENT (obj)) |
| 146 |
return "client"; |
| 147 |
else if (WP_IS_DEVICE (obj)) |
| 148 |
return "device"; |
| 149 |
else if (WP_IS_METADATA (obj)) |
| 150 |
return "metadata"; |
| 151 |
|
| 152 |
wp_debug_object (obj, "Unknown global proxy type"); |
| 153 |
return G_OBJECT_TYPE_NAME (obj); |
| 154 |
} |
| 155 |
|
| 156 |
static gint |
| 157 |
get_default_event_priority (const gchar *event_type) |
| 158 |
{ |
| 159 |
if (g_str_has_prefix(event_type, "select-") || |
| 160 |
g_str_has_prefix(event_type, "create-")) |
| 161 |
return 500; |
| 162 |
if (g_str_has_prefix(event_type, "autoswitch-")) |
| 163 |
return 400; |
| 164 |
else if (!g_strcmp0 (event_type, "rescan-for-default-nodes")) |
| 165 |
return -490; |
| 166 |
else if (!g_strcmp0 (event_type, "rescan-for-linking")) |
| 167 |
return -500; |
| 168 |
else if (!g_strcmp0 (event_type, "rescan-for-media-role-volume")) |
| 169 |
return -510; |
| 170 |
else if (!g_strcmp0 (event_type, "node-state-changed")) |
| 171 |
return 50; |
| 172 |
else if (!g_strcmp0 (event_type, "metadata-changed")) |
| 173 |
return 50; |
| 174 |
else if (g_str_has_suffix (event_type, "-params-changed")) |
| 175 |
return 50; |
| 176 |
else if (g_str_has_prefix (event_type, "client-")) |
| 177 |
return 200; |
| 178 |
else if (g_str_has_prefix (event_type, "device-")) |
| 179 |
return 170; |
| 180 |
else if (g_str_has_prefix (event_type, "port-")) |
| 181 |
return 150; |
| 182 |
else if (g_str_has_prefix (event_type, "node-")) |
| 183 |
return 130; |
| 184 |
else if (g_str_has_prefix (event_type, "session-item-")) |
| 185 |
return 110; |
| 186 |
else if (g_str_has_suffix (event_type, "-added") || |
| 187 |
g_str_has_suffix (event_type, "-removed")) |
| 188 |
return 20; |
| 189 |
|
| 190 |
wp_debug ("Unknown event type: %s, using priority 0", event_type); |
| 191 |
return 0; |
| 192 |
} |
| 193 |
|
| 194 |
static WpObjectManager * |
| 195 |
wp_standard_event_get_object_manager (WpStandardEventSource *self, |
| 196 |
const gchar * type_str) |
| 197 |
{ |
| 198 |
ObjectType type = type_str_to_object_type (type_str); |
| 199 |
|
| 200 |
if (G_UNLIKELY (type == OBJECT_TYPE_INVALID)) { |
| 201 |
wp_critical_object (self, "object type '%s' is not valid", type_str); |
| 202 |
return NULL; |
| 203 |
} |
| 204 |
|
| 205 |
g_return_val_if_fail (self->oms[type], NULL); |
| 206 |
return g_object_ref (self->oms[type]); |
| 207 |
} |
| 208 |
|
| 209 |
/* Local Events are events created by WirePlumber. */ |
| 210 |
static gboolean |
| 211 |
is_it_local_event (const gchar *event_type) |
| 212 |
{ |
| 213 |
if (g_str_has_prefix(event_type, "select-") || |
| 214 |
g_str_has_prefix(event_type, "create-") || |
| 215 |
g_str_has_prefix(event_type, "autoswitch-")) |
| 216 |
return TRUE; |
| 217 |
|
| 218 |
return FALSE; |
| 219 |
} |
| 220 |
|
| 221 |
static WpEvent * |
| 222 |
wp_standard_event_source_create_event (WpStandardEventSource *self, |
| 223 |
const gchar *event_type, gpointer subject, WpProperties *misc_properties) |
| 224 |
{ |
| 225 |
g_autoptr (WpEvent) event = NULL; |
| 226 |
g_autoptr (WpProperties) properties = wp_properties_new_empty (); |
| 227 |
g_autofree gchar *full_event_type = NULL; |
| 228 |
|
| 229 |
const gchar *subject_type = |
| 230 |
subject ? get_object_type (subject, &properties) : NULL; |
| 231 |
|
| 232 |
if (subject_type) { |
| 233 |
wp_properties_set (properties, "event.subject.type", subject_type); |
| 234 |
|
| 235 |
/* prefix the event with the subject type, unless it is a local event */ |
| 236 |
if (!is_it_local_event (event_type)) { |
| 237 |
full_event_type = g_strdup_printf ("%s-%s", subject_type, event_type); |
| 238 |
event_type = full_event_type; |
| 239 |
} |
| 240 |
} |
| 241 |
if (misc_properties) |
| 242 |
wp_properties_add (properties, misc_properties); |
| 243 |
|
| 244 |
gint priority = get_default_event_priority (event_type); |
| 245 |
|
| 246 |
wp_debug_object (self, |
| 247 |
"pushing event '%s', prio %d, subject " WP_OBJECT_FORMAT " (%s)", |
| 248 |
event_type, priority, WP_OBJECT_ARGS (subject), subject_type); |
| 249 |
|
| 250 |
event = wp_event_new (event_type, priority, g_steal_pointer (&properties), |
| 251 |
G_OBJECT (self), G_OBJECT (subject)); |
| 252 |
|
| 253 |
/* watch for subject pw-proxy-destroyed and cancel event, |
| 254 |
unless this is a "removed" event, in which case we expect the proxy |
| 255 |
to be destroyed and the event should still go through */ |
| 256 |
if (subject && !g_str_has_suffix (event_type, "-removed")) { |
| 257 |
g_autoptr (WpProxy) proxy = NULL; |
| 258 |
|
| 259 |
if (WP_IS_PROXY (subject)) { |
| 260 |
proxy = g_object_ref (WP_PROXY (subject)); |
| 261 |
} |
| 262 |
else if (WP_IS_SESSION_ITEM (subject)) { |
| 263 |
/* watch the node associated with the session-item */ |
| 264 |
proxy = wp_session_item_get_associated_proxy (WP_SESSION_ITEM (subject), |
| 265 |
WP_TYPE_NODE); |
| 266 |
} |
| 267 |
|
| 268 |
if (proxy) { |
| 269 |
g_signal_connect_object (proxy, "pw-proxy-destroyed", |
| 270 |
(GCallback) g_cancellable_cancel, wp_event_get_cancellable (event), |
| 271 |
G_CONNECT_SWAPPED); |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
return g_steal_pointer (&event); |
| 276 |
} |
| 277 |
|
| 278 |
static void |
| 279 |
wp_standard_event_source_push_event (WpStandardEventSource *self, |
| 280 |
const gchar *event_type, gpointer subject, WpProperties *misc_properties) |
| 281 |
{ |
| 282 |
|
| 283 |
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (self)); |
| 284 |
|
| 285 |
/* this can happen during the core dispose sequence; the weak ref to the |
| 286 |
core is invalidated before the registered objects are destroyed */ |
| 287 |
if (!core) |
| 288 |
return; |
| 289 |
|
| 290 |
g_autoptr (WpEventDispatcher) dispatcher = |
| 291 |
wp_event_dispatcher_get_instance (core); |
| 292 |
g_return_if_fail (dispatcher); |
| 293 |
|
| 294 |
wp_event_dispatcher_push_event (dispatcher, |
| 295 |
wp_standard_event_source_create_event ( |
| 296 |
self, event_type, subject, misc_properties)); |
| 297 |
} |
| 298 |
|
| 299 |
static void |
| 300 |
wp_standard_event_source_schedule_rescan (WpStandardEventSource *self, |
| 301 |
RescanContext context) |
| 302 |
{ |
| 303 |
if (!self->rescan_scheduled[context]) { |
| 304 |
g_autoptr (GEnumClass) klass = g_type_class_ref (TYPE_RESCAN_CONTEXT); |
| 305 |
GEnumValue *value = g_enum_get_value (klass, context); |
| 306 |
g_autofree gchar *event_type = g_strdup_printf ("rescan-for-%s", |
| 307 |
value->value_nick); |
| 308 |
wp_standard_event_source_push_event (self, event_type, NULL, NULL); |
| 309 |
self->rescan_scheduled[context] = TRUE; |
| 310 |
} |
| 311 |
} |
| 312 |
|
| 313 |
static void |
| 314 |
on_metadata_changed (WpMetadata *obj, guint32 subject, |
| 315 |
const gchar *key, const gchar *spa_type, const gchar *value, |
| 316 |
WpStandardEventSource *self) |
| 317 |
{ |
| 318 |
g_autoptr (WpProperties) properties = wp_properties_new_empty (); |
| 319 |
wp_properties_setf (properties, "event.subject.id", "%u", subject); |
| 320 |
wp_properties_set (properties, "event.subject.key", key); |
| 321 |
wp_properties_set (properties, "event.subject.spa_type", spa_type); |
| 322 |
wp_properties_set (properties, "event.subject.value", value); |
| 323 |
|
| 324 |
wp_standard_event_source_push_event (self, "changed", obj, properties); |
| 325 |
} |
| 326 |
|
| 327 |
static void |
| 328 |
on_params_changed (WpPipewireObject *obj, const gchar *id, |
| 329 |
WpStandardEventSource *self) |
| 330 |
{ |
| 331 |
g_autoptr (WpProperties) properties = wp_properties_new_empty (); |
| 332 |
wp_properties_set (properties, "event.subject.param-id", id); |
| 333 |
|
| 334 |
wp_standard_event_source_push_event (self, "params-changed", obj, properties); |
| 335 |
} |
| 336 |
|
| 337 |
static void |
| 338 |
on_node_state_changed (WpNode *obj, WpNodeState old_state, |
| 339 |
WpNodeState new_state, WpStandardEventSource *self) |
| 340 |
{ |
| 341 |
g_autoptr (GEnumClass) klass = g_type_class_ref (WP_TYPE_NODE_STATE); |
| 342 |
GEnumValue *old_value = g_enum_get_value (klass, old_state); |
| 343 |
GEnumValue *new_value = g_enum_get_value (klass, new_state); |
| 344 |
|
| 345 |
g_autoptr (WpProperties) properties = wp_properties_new ( |
| 346 |
"event.subject.old-state", old_value ? old_value->value_nick : NULL, |
| 347 |
"event.subject.new-state", new_value ? new_value->value_nick : NULL, |
| 348 |
NULL); |
| 349 |
wp_standard_event_source_push_event (self, "state-changed", obj, |
| 350 |
properties); |
| 351 |
} |
| 352 |
|
| 353 |
static void |
| 354 |
on_object_added (WpObjectManager *om, WpObject *obj, WpStandardEventSource *self) |
| 355 |
{ |
| 356 |
wp_standard_event_source_push_event (self, "added", obj, NULL); |
| 357 |
|
| 358 |
if (WP_IS_PIPEWIRE_OBJECT (obj)) { |
| 359 |
g_signal_connect_object (obj, "params-changed", |
| 360 |
G_CALLBACK (on_params_changed), self, 0); |
| 361 |
} |
| 362 |
|
| 363 |
if (WP_IS_NODE (obj)) { |
| 364 |
g_signal_connect_object (obj, "state-changed", |
| 365 |
G_CALLBACK (on_node_state_changed), self, 0); |
| 366 |
} |
| 367 |
else if (WP_IS_METADATA (obj)) { |
| 368 |
g_signal_connect_object (obj, "changed", |
| 369 |
G_CALLBACK (on_metadata_changed), self, 0); |
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
static void |
| 374 |
on_object_removed (WpObjectManager *om, WpObject *obj, WpStandardEventSource *self) |
| 375 |
{ |
| 376 |
wp_standard_event_source_push_event (self, "removed", obj, NULL); |
| 377 |
} |
| 378 |
|
| 379 |
static void |
| 380 |
on_om_installed (WpObjectManager * om, WpStandardEventSource * self) |
| 381 |
{ |
| 382 |
if (++self->n_oms_installed == N_OBJECT_TYPES) |
| 383 |
wp_object_update_features (WP_OBJECT (self), WP_PLUGIN_FEATURE_ENABLED, 0); |
| 384 |
} |
| 385 |
|
| 386 |
static void |
| 387 |
on_rescan_done (WpEvent * event, WpStandardEventSource * self) |
| 388 |
{ |
| 389 |
g_autoptr (WpProperties) properties = wp_event_get_properties (event); |
| 390 |
const gchar *event_type = wp_properties_get (properties, "event.type"); |
| 391 |
|
| 392 |
/* the event type is "rescan-for-<context>" and the enum nickname is just |
| 393 |
"<context>", so we get the substring from the 12th character onwards */ |
| 394 |
g_autoptr (GEnumClass) klass = g_type_class_ref (TYPE_RESCAN_CONTEXT); |
| 395 |
GEnumValue *value = g_enum_get_value_by_nick (klass, &event_type[11]); |
| 396 |
|
| 397 |
g_return_if_fail (value != NULL && value->value_nick != NULL); |
| 398 |
self->rescan_scheduled[value->value] = FALSE; |
| 399 |
} |
| 400 |
|
| 401 |
static void |
| 402 |
wp_standard_event_source_enable (WpPlugin * plugin, WpTransition * transition) |
| 403 |
{ |
| 404 |
WpStandardEventSource * self = WP_STANDARD_EVENT_SOURCE (plugin); |
| 405 |
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (plugin)); |
| 406 |
g_return_if_fail (core); |
| 407 |
g_autoptr (WpEventDispatcher) dispatcher = |
| 408 |
wp_event_dispatcher_get_instance (core); |
| 409 |
g_return_if_fail (dispatcher); |
| 410 |
|
| 411 |
/* install object managers */ |
| 412 |
self->n_oms_installed = 0; |
| 413 |
for (gint i = 0; i < N_OBJECT_TYPES; i++) { |
| 414 |
GType gtype = object_type_to_gtype (i); |
| 415 |
self->oms[i] = wp_object_manager_new (); |
| 416 |
wp_object_manager_add_interest (self->oms[i], gtype, NULL); |
| 417 |
wp_object_manager_request_object_features (self->oms[i], |
| 418 |
gtype, WP_OBJECT_FEATURES_ALL); |
| 419 |
g_signal_connect_object (self->oms[i], "object-added", |
| 420 |
G_CALLBACK (on_object_added), self, 0); |
| 421 |
g_signal_connect_object (self->oms[i], "object-removed", |
| 422 |
G_CALLBACK (on_object_removed), self, 0); |
| 423 |
g_signal_connect_object (self->oms[i], "installed", |
| 424 |
G_CALLBACK (on_om_installed), self, 0); |
| 425 |
wp_core_install_object_manager (core, self->oms[i]); |
| 426 |
} |
| 427 |
|
| 428 |
/* install hook to restore the rescan_scheduled state just before rescanning */ |
| 429 |
self->rescan_done_hook = wp_simple_event_hook_new ( |
| 430 |
"m-standard-event-source/rescan-done", (const gchar *[]) { "*", NULL }, NULL, |
| 431 |
g_cclosure_new_object ((GCallback) on_rescan_done, G_OBJECT (self))); |
| 432 |
wp_interest_event_hook_add_interest ( |
| 433 |
WP_INTEREST_EVENT_HOOK (self->rescan_done_hook), |
| 434 |
WP_CONSTRAINT_TYPE_PW_PROPERTY, "event.type", "#s", "rescan-for-*", |
| 435 |
NULL); |
| 436 |
wp_event_dispatcher_register_hook (dispatcher, self->rescan_done_hook); |
| 437 |
} |
| 438 |
|
| 439 |
static void |
| 440 |
wp_standard_event_source_disable (WpPlugin * plugin) |
| 441 |
{ |
| 442 |
WpStandardEventSource * self = WP_STANDARD_EVENT_SOURCE (plugin); |
| 443 |
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (plugin)); |
| 444 |
g_autoptr (WpEventDispatcher) dispatcher = core ? |
| 445 |
wp_event_dispatcher_get_instance (core) : NULL; |
| 446 |
|
| 447 |
for (gint i = 0; i < N_OBJECT_TYPES; i++) |
| 448 |
g_clear_object (&self->oms[i]); |
| 449 |
|
| 450 |
if (dispatcher) |
| 451 |
wp_event_dispatcher_unregister_hook (dispatcher, self->rescan_done_hook); |
| 452 |
g_clear_object (&self->rescan_done_hook); |
| 453 |
} |
| 454 |
|
| 455 |
static void |
| 456 |
wp_standard_event_source_class_init (WpStandardEventSourceClass * klass) |
| 457 |
{ |
| 458 |
WpPluginClass *plugin_class = (WpPluginClass *) klass; |
| 459 |
|
| 460 |
plugin_class->enable = wp_standard_event_source_enable; |
| 461 |
plugin_class->disable = wp_standard_event_source_disable; |
| 462 |
|
| 463 |
signals[ACTION_GET_OBJECT_MANAGER] = g_signal_new_class_handler ( |
| 464 |
"get-object-manager", G_TYPE_FROM_CLASS (klass), |
| 465 |
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
| 466 |
(GCallback) wp_standard_event_get_object_manager, |
| 467 |
NULL, NULL, NULL, WP_TYPE_OBJECT_MANAGER, 1, G_TYPE_STRING); |
| 468 |
|
| 469 |
signals[ACTION_CREATE_EVENT] = g_signal_new_class_handler ( |
| 470 |
"create-event", G_TYPE_FROM_CLASS (klass), |
| 471 |
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
| 472 |
(GCallback) wp_standard_event_source_create_event, |
| 473 |
NULL, NULL, NULL, WP_TYPE_EVENT, 3, |
| 474 |
G_TYPE_STRING, WP_TYPE_OBJECT, WP_TYPE_PROPERTIES); |
| 475 |
|
| 476 |
signals[ACTION_PUSH_EVENT] = g_signal_new_class_handler ( |
| 477 |
"push-event", G_TYPE_FROM_CLASS (klass), |
| 478 |
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
| 479 |
(GCallback) wp_standard_event_source_push_event, |
| 480 |
NULL, NULL, NULL, G_TYPE_NONE, 3, |
| 481 |
G_TYPE_STRING, WP_TYPE_OBJECT, WP_TYPE_PROPERTIES); |
| 482 |
|
| 483 |
signals[ACTION_SCHEDULE_RESCAN] = g_signal_new_class_handler ( |
| 484 |
"schedule-rescan", G_TYPE_FROM_CLASS (klass), |
| 485 |
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
| 486 |
(GCallback) wp_standard_event_source_schedule_rescan, |
| 487 |
NULL, NULL, NULL, G_TYPE_NONE, 1, TYPE_RESCAN_CONTEXT); |
| 488 |
} |
| 489 |
|
| 490 |
WP_PLUGIN_EXPORT GObject * |
| 491 |
wireplumber__module_init (WpCore * core, WpSpaJson * args, GError ** error) |
| 492 |
{ |
| 493 |
return G_OBJECT (g_object_new (wp_standard_event_source_get_type (), |
| 494 |
"name", "standard-event-source", |
| 495 |
"core", core, |
| 496 |
NULL)); |
| 497 |
} |