mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	add new functions pa_dbus_add_matches()/pa_dbus_remove_matches()
This commit is contained in:
		
							parent
							
								
									daf0612e37
								
							
						
					
					
						commit
						509535d240
					
				
					 2 changed files with 60 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -24,6 +24,8 @@
 | 
			
		|||
#include <config.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
 | 
			
		||||
#include <pulse/xmalloc.h>
 | 
			
		||||
#include <pulse/timeval.h>
 | 
			
		||||
#include <pulsecore/log.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -325,3 +327,58 @@ pa_dbus_connection* pa_dbus_bus_get(pa_core *c, DBusBusType type, DBusError *err
 | 
			
		|||
 | 
			
		||||
    return pconn;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int pa_dbus_add_matches(DBusConnection *c, DBusError *error, ...) {
 | 
			
		||||
    const char *t;
 | 
			
		||||
    va_list ap;
 | 
			
		||||
    unsigned k = 0;
 | 
			
		||||
 | 
			
		||||
    pa_assert(c);
 | 
			
		||||
    pa_assert(error);
 | 
			
		||||
 | 
			
		||||
    va_start(ap, error);
 | 
			
		||||
    while ((t = va_arg(ap, const char*))) {
 | 
			
		||||
        dbus_bus_add_match(c, t, error);
 | 
			
		||||
 | 
			
		||||
        if (dbus_error_is_set(error))
 | 
			
		||||
            goto fail;
 | 
			
		||||
 | 
			
		||||
        k++;
 | 
			
		||||
    }
 | 
			
		||||
    va_end(ap);
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
fail:
 | 
			
		||||
 | 
			
		||||
    va_end(ap);
 | 
			
		||||
    va_start(ap, error);
 | 
			
		||||
    for (; k > 0; k--) {
 | 
			
		||||
        DBusError e;
 | 
			
		||||
 | 
			
		||||
        pa_assert_se(t = va_arg(ap, const char*));
 | 
			
		||||
 | 
			
		||||
        dbus_error_init(&e);
 | 
			
		||||
        dbus_bus_remove_match(c, t, &e);
 | 
			
		||||
        dbus_error_free(&e);
 | 
			
		||||
    }
 | 
			
		||||
    va_end(ap);
 | 
			
		||||
 | 
			
		||||
    return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void pa_dbus_remove_matches(DBusConnection *c, ...) {
 | 
			
		||||
    const char *t;
 | 
			
		||||
    va_list ap;
 | 
			
		||||
    DBusError error;
 | 
			
		||||
 | 
			
		||||
    pa_assert(c);
 | 
			
		||||
 | 
			
		||||
    dbus_error_init(&error);
 | 
			
		||||
 | 
			
		||||
    va_start(ap, c);
 | 
			
		||||
    while ((t = va_arg(ap, const char*))) {
 | 
			
		||||
        dbus_bus_remove_match(c, t, &error);
 | 
			
		||||
        dbus_error_free(&error);
 | 
			
		||||
    }
 | 
			
		||||
    va_end(ap);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,4 +37,7 @@ DBusConnection* pa_dbus_connection_get(pa_dbus_connection *conn);
 | 
			
		|||
pa_dbus_connection* pa_dbus_connection_ref(pa_dbus_connection *conn);
 | 
			
		||||
void pa_dbus_connection_unref(pa_dbus_connection *conn);
 | 
			
		||||
 | 
			
		||||
int pa_dbus_add_matches(DBusConnection *c, DBusError *error, ...) PA_GCC_SENTINEL;
 | 
			
		||||
void pa_dbus_remove_matches(DBusConnection *c,  ...) PA_GCC_SENTINEL;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue