mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-11 13:30:07 -05:00
dbus: add events to the dbus connection
Add events to the dbus connection and notify about destroy and disconnect.
This commit is contained in:
parent
b6d803daa4
commit
2dcdabd2af
2 changed files with 67 additions and 4 deletions
|
|
@ -42,8 +42,23 @@ enum spa_dbus_type {
|
|||
SPA_DBUS_TYPE_STARTER /**< The bus that started us, if any */
|
||||
};
|
||||
|
||||
#define SPA_DBUS_CONNECTION_EVENT_DESTROY 0
|
||||
#define SPA_DBUS_CONNECTION_EVENT_DISCONNECTED 1
|
||||
#define SPA_DBUS_CONNECTION_EVENT_NUM 2
|
||||
|
||||
struct spa_dbus_connection_events {
|
||||
#define SPA_VERSION_DBUS_CONNECTION_EVENTS 0
|
||||
uint32_t version;
|
||||
|
||||
/* a connection is destroyed */
|
||||
void (*destroy) (void *data);
|
||||
|
||||
/* a connection disconnected */
|
||||
void (*disconnected) (void *data);
|
||||
};
|
||||
|
||||
struct spa_dbus_connection {
|
||||
#define SPA_VERSION_DBUS_CONNECTION 0
|
||||
#define SPA_VERSION_DBUS_CONNECTION 1
|
||||
uint32_t version;
|
||||
/**
|
||||
* Get the DBusConnection from a wrapper
|
||||
|
|
@ -58,10 +73,35 @@ struct spa_dbus_connection {
|
|||
* \param conn the wrapper to destroy
|
||||
*/
|
||||
void (*destroy) (struct spa_dbus_connection *conn);
|
||||
|
||||
/**
|
||||
* Add a listener for events
|
||||
*
|
||||
* Since version 1
|
||||
*/
|
||||
void (*add_listener) (struct spa_dbus_connection *conn,
|
||||
struct spa_hook *listener,
|
||||
const struct spa_dbus_connection_events *events,
|
||||
void *data);
|
||||
};
|
||||
|
||||
#define spa_dbus_connection_get(c) (c)->get((c))
|
||||
#define spa_dbus_connection_destroy(c) (c)->destroy((c))
|
||||
#define spa_dbus_connection_call(c,method,vers,...) \
|
||||
({ \
|
||||
if (SPA_LIKELY(SPA_CALLBACK_CHECK(c,method,vers))) \
|
||||
c->method((c), ## __VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define spa_dbus_connection_call_vp(c,method,vers,...) \
|
||||
({ \
|
||||
void *_res = NULL; \
|
||||
if (SPA_LIKELY(SPA_CALLBACK_CHECK(c,method,vers))) \
|
||||
_res = c->method((c), ## __VA_ARGS__); \
|
||||
_res; \
|
||||
})
|
||||
|
||||
#define spa_dbus_connection_get(c) spa_dbus_connection_call_vp(c,get,0)
|
||||
#define spa_dbus_connection_destroy(c) spa_dbus_connection_call(c,destroy,0)
|
||||
#define spa_dbus_connection_add_listener(c,...) spa_dbus_connection_call(c,add_listener,1,__VA_ARGS__)
|
||||
|
||||
struct spa_dbus_methods {
|
||||
#define SPA_VERSION_DBUS_METHODS 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue