mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-01 22:58:47 -04:00
reserver: update from upstream git
This commit is contained in:
parent
8208214882
commit
c579cb56e9
1 changed files with 18 additions and 9 deletions
|
|
@ -38,6 +38,7 @@ struct rm_monitor {
|
|||
|
||||
char *device_name;
|
||||
char *service_name;
|
||||
char *match;
|
||||
|
||||
DBusConnection *connection;
|
||||
|
||||
|
|
@ -51,6 +52,13 @@ struct rm_monitor {
|
|||
|
||||
#define SERVICE_PREFIX "org.freedesktop.ReserveDevice1."
|
||||
|
||||
#define SERVICE_FILTER \
|
||||
"type='signal'," \
|
||||
"sender='" DBUS_SERVICE_DBUS "'," \
|
||||
"interface='" DBUS_INTERFACE_DBUS "'," \
|
||||
"member='NameOwnerChanged'," \
|
||||
"arg0='%s'"
|
||||
|
||||
static DBusHandlerResult filter_handler(
|
||||
DBusConnection *c,
|
||||
DBusMessage *s,
|
||||
|
|
@ -175,11 +183,13 @@ int rm_watch(
|
|||
|
||||
m->filtering = 1;
|
||||
|
||||
dbus_bus_add_match(m->connection,
|
||||
"type='signal',"
|
||||
"sender='" DBUS_SERVICE_DBUS "',"
|
||||
"interface='" DBUS_INTERFACE_DBUS "',"
|
||||
"member='NameOwnerChanged'", error);
|
||||
if (!(m->match = malloc(sizeof(SERVICE_FILTER) - 2 + strlen(m->service_name)))) {
|
||||
r = -ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
sprintf(m->match, SERVICE_FILTER, m->service_name);
|
||||
dbus_bus_add_match(m->connection, m->match, error);
|
||||
|
||||
if (dbus_error_is_set(error)) {
|
||||
r = -EIO;
|
||||
|
|
@ -220,10 +230,8 @@ void rm_release(rm_monitor *m) {
|
|||
if (m->matching)
|
||||
dbus_bus_remove_match(
|
||||
m->connection,
|
||||
"type='signal',"
|
||||
"sender='" DBUS_SERVICE_DBUS "',"
|
||||
"interface='" DBUS_INTERFACE_DBUS "',"
|
||||
"member='NameOwnerChanged'", NULL);
|
||||
m->match,
|
||||
NULL);
|
||||
|
||||
if (m->filtering)
|
||||
dbus_connection_remove_filter(
|
||||
|
|
@ -233,6 +241,7 @@ void rm_release(rm_monitor *m) {
|
|||
|
||||
free(m->device_name);
|
||||
free(m->service_name);
|
||||
free(m->match);
|
||||
|
||||
if (m->connection)
|
||||
dbus_connection_unref(m->connection);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue