mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-19 08:57:00 -05:00
add some helpers for dealing with DBusPendingCall based on Mrc-Andre's work in module-bluetooth-discover
This commit is contained in:
parent
746dc2ac19
commit
47a9b96b64
2 changed files with 72 additions and 0 deletions
|
|
@ -382,3 +382,51 @@ void pa_dbus_remove_matches(DBusConnection *c, ...) {
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pa_dbus_pending *pa_dbus_pending_new(DBusMessage *m, DBusPendingCall *pending, void *context_data, void *call_data) {
|
||||||
|
pa_dbus_pending *p;
|
||||||
|
|
||||||
|
pa_assert(pending);
|
||||||
|
|
||||||
|
p = pa_xnew(pa_dbus_pending, 1);
|
||||||
|
p->message = m;
|
||||||
|
p->pending = pending;
|
||||||
|
p->context_data = context_data;
|
||||||
|
p->call_data = call_data;
|
||||||
|
|
||||||
|
PA_LLIST_INIT(pa_dbus_pending, p);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pa_dbus_pending_free(pa_dbus_pending *p) {
|
||||||
|
pa_assert(p);
|
||||||
|
|
||||||
|
if (p->pending) {
|
||||||
|
dbus_pending_call_cancel(p->pending);
|
||||||
|
dbus_pending_call_unref(p->pending);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->message)
|
||||||
|
dbus_message_unref(p->message);
|
||||||
|
|
||||||
|
pa_xfree(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pa_dbus_sync_pending_list(pa_dbus_pending **p) {
|
||||||
|
pa_assert(p);
|
||||||
|
|
||||||
|
while (*p)
|
||||||
|
dbus_pending_call_block((*p)->pending);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pa_dbus_free_pending_list(pa_dbus_pending **p) {
|
||||||
|
pa_dbus_pending *i;
|
||||||
|
|
||||||
|
pa_assert(p);
|
||||||
|
|
||||||
|
while ((i = *p)) {
|
||||||
|
PA_LLIST_REMOVE(pa_dbus_pending, *p, i);
|
||||||
|
pa_dbus_pending_free(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
|
||||||
#include <pulsecore/core.h>
|
#include <pulsecore/core.h>
|
||||||
|
#include <pulsecore/llist.h>
|
||||||
|
|
||||||
typedef struct pa_dbus_connection pa_dbus_connection;
|
typedef struct pa_dbus_connection pa_dbus_connection;
|
||||||
|
|
||||||
|
|
@ -40,4 +41,27 @@ void pa_dbus_connection_unref(pa_dbus_connection *conn);
|
||||||
int pa_dbus_add_matches(DBusConnection *c, DBusError *error, ...) PA_GCC_SENTINEL;
|
int pa_dbus_add_matches(DBusConnection *c, DBusError *error, ...) PA_GCC_SENTINEL;
|
||||||
void pa_dbus_remove_matches(DBusConnection *c, ...) PA_GCC_SENTINEL;
|
void pa_dbus_remove_matches(DBusConnection *c, ...) PA_GCC_SENTINEL;
|
||||||
|
|
||||||
|
typedef struct pa_dbus_pending pa_dbus_pending;
|
||||||
|
|
||||||
|
struct userdata; /* We leave the actual definition to the caller */
|
||||||
|
|
||||||
|
struct pa_dbus_pending {
|
||||||
|
DBusMessage *message;
|
||||||
|
DBusPendingCall *pending;
|
||||||
|
|
||||||
|
void *context_data;
|
||||||
|
void *call_data;
|
||||||
|
|
||||||
|
PA_LLIST_FIELDS(pa_dbus_pending);
|
||||||
|
};
|
||||||
|
|
||||||
|
pa_dbus_pending *pa_dbus_pending_new(DBusMessage *m, DBusPendingCall *pending, void *context_data, void *call_data);
|
||||||
|
void pa_dbus_pending_free(pa_dbus_pending *p);
|
||||||
|
|
||||||
|
/* Sync up a list of pa_dbus_pending_call objects */
|
||||||
|
void pa_dbus_sync_pending_list(pa_dbus_pending **p);
|
||||||
|
|
||||||
|
/* Free up a list of pa_dbus_pending_call objects */
|
||||||
|
void pa_dbus_free_pending_list(pa_dbus_pending **p);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue