Make structure private

Make structs private. Expose methods for things we need.
Signals only work on exposed structures so make a new callback helper to
signal events.
This commit is contained in:
Wim Taymans 2017-08-04 10:18:54 +02:00
parent e24c934a1b
commit b898eb46cd
72 changed files with 2980 additions and 2120 deletions

View file

@ -24,9 +24,6 @@
extern "C" {
#endif
#include <pipewire/type.h>
#include <pipewire/utils.h>
struct pw_remote;
/** \page page_proxy Proxy
@ -87,45 +84,52 @@ struct pw_remote;
*
* See \ref page_proxy
*/
struct pw_proxy {
struct pw_remote *remote; /**< the owner remote of this proxy */
struct spa_list link; /**< link in the remote */
struct pw_proxy;
uint32_t id; /**< client side id */
uint32_t type; /**< type id */
#include <pipewire/type.h>
#include <pipewire/utils.h>
#include <pipewire/callback.h>
const void *listener; /**< event listener */
void *object; /**< object associated with proxy */
struct pw_proxy_callbacks {
#define PW_VERSION_PROXY_CALLBACKS 0
uint32_t version;
const struct pw_protocol_marshal *marshal; /**< protocol specific marshal functions */
/** destroy is emited when the proxy is destroyed */
PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_proxy *proxy));
void *user_data; /**< extra user data */
pw_destroy_t destroy; /**< optional destroy function to clean up the user_data */
void (*destroy) (void *data);
};
/** Make a new proxy object. The id can be used to bind to a remote object. */
struct pw_proxy *
pw_proxy_new(struct pw_remote *remote, /**< remote this proxy is from */
uint32_t id, /**< local id, SPA_ID_INVALID to have one automatically
* allocated for you */
uint32_t type, /**< interface type id */
size_t user_data_size, /**< size of user data */
pw_destroy_t destroy /**< destroy function for user data */);
pw_proxy_new(struct pw_proxy *proxy, /**< proxy as factory */
uint32_t type, /**< interface type */
size_t user_data_size /**< size of user data */);
void
pw_proxy_add_callbacks(struct pw_proxy *proxy,
struct pw_callback_info *info,
const struct pw_proxy_callbacks *callbacks,
void *data);
void
pw_proxy_add_listener(struct pw_proxy *proxy, /**< the proxy */
void *object, /**< object associated with proxy */
const void *events /**< events */);
struct pw_callback_info *info,
const void *callbacks, /**< events */
void *data /**< data passed to events */);
void pw_proxy_destroy(struct pw_proxy *proxy);
#define pw_proxy_notify(p,type,event,...) ((type*) (p)->listener)->event(p, __VA_ARGS__)
#define pw_proxy_notify_na(p,type,event) ((type*) (p)->listener)->event(p)
#define pw_proxy_do(p,type,method,...) ((type*) (p)->marshal->method_marshal)->method(p, __VA_ARGS__)
#define pw_proxy_do_na(p,type,method) ((type*) (p)->marshal->method_marshal)->method(p)
void *pw_proxy_get_user_data(struct pw_proxy *proxy);
uint32_t pw_proxy_get_id(struct pw_proxy *proxy);
struct pw_callback_list *pw_proxy_get_listeners(struct pw_proxy *proxy);
const void *pw_proxy_get_implementation(struct pw_proxy *proxy);
#define pw_proxy_notify(p,type,event,...) pw_callback_emit(pw_proxy_get_listeners(p),type,event,__VA_ARGS__)
#define pw_proxy_notify_na(p,type,event) pw_callback_emit_na(pw_proxy_get_listeners(p),type,event)
#define pw_proxy_do(p,type,method,...) ((type*) pw_proxy_get_implementation(p))->method(p, __VA_ARGS__)
#define pw_proxy_do_na(p,type,method) ((type*) pw_proxy_get_implementation(p))->method(p)
#ifdef __cplusplus
}