Skip to content

Commit cd2214d

Browse files
committed
wireplumber: add more properties
closes #280
1 parent ee91402 commit cd2214d

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

lib/wireplumber/include/astal/wireplumber/endpoint.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ const gchar *astal_wp_endpoint_get_description(AstalWpEndpoint *self);
3737
const gchar *astal_wp_endpoint_get_name(AstalWpEndpoint *self);
3838
const gchar *astal_wp_endpoint_get_icon(AstalWpEndpoint *self);
3939
const gchar *astal_wp_endpoint_get_volume_icon(AstalWpEndpoint *self);
40+
guint astal_wp_endpoint_get_serial(AstalWpEndpoint *self);
41+
const gchar *astal_wp_endpoint_get_path(AstalWpEndpoint *self);
42+
4043

4144
G_END_DECLS
4245

lib/wireplumber/src/endpoint.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ struct _AstalWpEndpoint {
1515
gboolean mute;
1616
gchar *description;
1717
gchar *name;
18+
guint serial;
19+
gchar *path;
20+
1821
AstalWpMediaClass type;
1922
gboolean is_default;
2023
gboolean lock_channels;
@@ -59,6 +62,8 @@ typedef enum {
5962
ASTAL_WP_ENDPOINT_PROP_ICON,
6063
ASTAL_WP_ENDPOINT_PROP_VOLUME_ICON,
6164
ASTAL_WP_ENDPOINT_PROP_LOCK_CHANNELS,
65+
ASTAL_WP_ENDPOINT_PROP_SERIAL,
66+
ASTAL_WP_ENDPOINT_PROP_PATH,
6267
ASTAL_WP_ENDPOINT_N_PROPERTIES,
6368
} AstalWpEndpointProperties;
6469

@@ -276,6 +281,23 @@ const gchar *astal_wp_endpoint_get_volume_icon(AstalWpEndpoint *self) {
276281
}
277282
}
278283

284+
/**
285+
* astal_wp_endpoint_get_serial:
286+
* @self: the AstalWpEndpoint instance.
287+
*
288+
* gets the serial number of this endpoint
289+
*/
290+
guint astal_wp_endpoint_get_serial(AstalWpEndpoint *self) { return self->serial; }
291+
292+
/**
293+
* astal_wp_endpoint_get_path:
294+
* @self: the AstalWpEndpoint instance.
295+
*
296+
* gets the object path of this endpoint
297+
*/
298+
const gchar *astal_wp_endpoint_get_path(AstalWpEndpoint *self) { return self->path; }
299+
300+
279301
static void astal_wp_endpoint_get_property(GObject *object, guint property_id, GValue *value,
280302
GParamSpec *pspec) {
281303
AstalWpEndpoint *self = ASTAL_WP_ENDPOINT(object);
@@ -311,6 +333,12 @@ static void astal_wp_endpoint_get_property(GObject *object, guint property_id, G
311333
case ASTAL_WP_ENDPOINT_PROP_LOCK_CHANNELS:
312334
g_value_set_boolean(value, self->lock_channels);
313335
break;
336+
case ASTAL_WP_ENDPOINT_PROP_SERIAL:
337+
g_value_set_uint(value, self->serial);
338+
break;
339+
case ASTAL_WP_ENDPOINT_PROP_PATH:
340+
g_value_set_string(value, self->path);
341+
break;
314342
default:
315343
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
316344
break;
@@ -405,14 +433,26 @@ static void astal_wp_endpoint_update_properties(AstalWpEndpoint *self) {
405433
default:
406434
icon = "audio-card-symbolic";
407435
}
436+
408437
g_free(self->icon);
409438
self->icon = g_strdup(icon);
410439

440+
const gchar *serial = wp_pipewire_object_get_property(WP_PIPEWIRE_OBJECT(priv->node), "object.serial");
441+
if (serial != NULL) {
442+
self->serial = g_ascii_strtoull(serial, NULL, 10);
443+
}
444+
445+
const gchar* path = wp_pipewire_object_get_property(WP_PIPEWIRE_OBJECT(priv->node), "object.path");
446+
g_free(self->path);
447+
self->path = g_strdup(path);
448+
411449
g_object_notify(G_OBJECT(self), "id");
412450
g_object_notify(G_OBJECT(self), "description");
413451
g_object_notify(G_OBJECT(self), "name");
414452
g_object_notify(G_OBJECT(self), "icon");
415453
g_object_notify(G_OBJECT(self), "media-class");
454+
g_object_notify(G_OBJECT(self), "serial");
455+
g_object_notify(G_OBJECT(self), "path");
416456
}
417457

418458
static void astal_wp_endpoint_default_changed_as_default(AstalWpEndpoint *self) {
@@ -514,6 +554,7 @@ static void astal_wp_endpoint_init(AstalWpEndpoint *self) {
514554
self->mute = TRUE;
515555
self->description = NULL;
516556
self->name = NULL;
557+
self->path = NULL;
517558
}
518559

519560
static void astal_wp_endpoint_dispose(GObject *object) {
@@ -533,6 +574,7 @@ static void astal_wp_endpoint_finalize(GObject *object) {
533574
AstalWpEndpoint *self = ASTAL_WP_ENDPOINT(object);
534575
g_free(self->description);
535576
g_free(self->name);
577+
g_free(self->path);
536578
}
537579

538580
static void astal_wp_endpoint_class_init(AstalWpEndpointClass *class) {
@@ -615,6 +657,22 @@ static void astal_wp_endpoint_class_init(AstalWpEndpointClass *class) {
615657
astal_wp_endpoint_properties[ASTAL_WP_ENDPOINT_PROP_LOCK_CHANNELS] = g_param_spec_boolean(
616658
"lock-channels", "lock-channels", "lock channels", FALSE, G_PARAM_READWRITE);
617659

660+
/**
661+
* AstalWpEndpoint:serial:
662+
*
663+
* The object serial of this endpoint.
664+
*/
665+
astal_wp_endpoint_properties[ASTAL_WP_ENDPOINT_PROP_SERIAL] =
666+
g_param_spec_uint("serial", "serial", "serial", 0, UINT_MAX, 0, G_PARAM_READABLE);
667+
668+
/**
669+
* AstalWpEndpoint:path:
670+
*
671+
* The object path of this endpoint
672+
*/
673+
astal_wp_endpoint_properties[ASTAL_WP_ENDPOINT_PROP_PATH] = g_param_spec_string(
674+
"path", "path", "path", NULL, G_PARAM_READABLE);
675+
618676
g_object_class_install_properties(object_class, ASTAL_WP_ENDPOINT_N_PROPERTIES,
619677
astal_wp_endpoint_properties);
620678
}

0 commit comments

Comments
 (0)