spa: use static inline for interfaces instead of macro

It gives better typechecking and a path to make a library of functions.
This commit is contained in:
Wim Taymans 2024-11-19 19:57:37 +01:00
parent 5e0e1204d7
commit 84bd4b7ea9
32 changed files with 1069 additions and 563 deletions

View file

@ -83,28 +83,59 @@ struct spa_filter_graph_methods {
struct spa_filter_graph_chunk out[], uint32_t n_out);
};
#define spa_filter_graph_method_r(o,method,version,...) \
({ \
volatile int _res = -ENOTSUP; \
struct spa_filter_graph *_o = o; \
spa_interface_call_fast_res(&_o->iface, \
struct spa_filter_graph_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
static inline int spa_filter_graph_add_listener(struct spa_filter_graph *object,
struct spa_hook *listener,
const struct spa_filter_graph_events *events, void *data)
{
return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, add_listener, 0, listener,
events, data);
}
#define spa_filter_graph_add_listener(o,...) spa_filter_graph_method_r(o,add_listener,0,__VA_ARGS__)
static inline int spa_filter_graph_enum_prop_info(struct spa_filter_graph *object,
uint32_t idx, struct spa_pod_builder *b)
{
return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, enum_prop_info, 0, idx, b);
}
static inline int spa_filter_graph_get_props(struct spa_filter_graph *object,
struct spa_pod_builder *b, const struct spa_pod **props)
{
return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, get_props, 0, b, props);
}
#define spa_filter_graph_enum_prop_info(o,...) spa_filter_graph_method_r(o,enum_prop_info,0,__VA_ARGS__)
#define spa_filter_graph_get_props(o,...) spa_filter_graph_method_r(o,get_props,0,__VA_ARGS__)
#define spa_filter_graph_set_props(o,...) spa_filter_graph_method_r(o,set_props,0,__VA_ARGS__)
static inline int spa_filter_graph_set_props(struct spa_filter_graph *object,
enum spa_direction direction, const struct spa_pod *props)
{
return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, set_props, 0, direction, props);
}
#define spa_filter_graph_activate(o,...) spa_filter_graph_method_r(o,activate,0,__VA_ARGS__)
#define spa_filter_graph_deactivate(o) spa_filter_graph_method_r(o,deactivate,0)
static inline int spa_filter_graph_activate(struct spa_filter_graph *object, const struct spa_fraction *rate)
{
return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, activate, 0, rate);
}
static inline int spa_filter_graph_deactivate(struct spa_filter_graph *object)
{
return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, deactivate, 0);
}
#define spa_filter_graph_reset(o) spa_filter_graph_method_r(o,reset,0)
static inline int spa_filter_graph_reset(struct spa_filter_graph *object)
{
return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, reset, 0);
}
#define spa_filter_graph_process(o,...) spa_filter_graph_method_r(o,process,0,__VA_ARGS__)
static inline int spa_filter_graph_process(struct spa_filter_graph *object,
const struct spa_filter_graph_chunk in[], uint32_t n_in,
struct spa_filter_graph_chunk out[], uint32_t n_out)
{
return spa_api_method_r(int, -ENOTSUP,
spa_filter_graph, &object->iface, process, 0, in, n_in, out, n_out);
}
/**
* \}

View file

@ -68,26 +68,69 @@ struct spa_audio_aec_methods {
struct spa_audio_info_raw *out_info);
};
#define spa_audio_aec_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_audio_aec *_o = (o); \
spa_interface_call_res(&_o->iface, \
struct spa_audio_aec_methods, _res, \
method, (version), ##__VA_ARGS__); \
_res; \
})
static inline int spa_audio_aec_add_listener(struct spa_audio_aec *object,
struct spa_hook *listener,
const struct spa_audio_aec_events *events,
void *data)
{
return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, add_listener, 0, listener, events, data);
}
#define spa_audio_aec_add_listener(o,...) spa_audio_aec_method(o, add_listener, 0, __VA_ARGS__)
#define spa_audio_aec_init(o,...) spa_audio_aec_method(o, init, 0, __VA_ARGS__)
#define spa_audio_aec_run(o,...) spa_audio_aec_method(o, run, 0, __VA_ARGS__)
#define spa_audio_aec_set_props(o,...) spa_audio_aec_method(o, set_props, 0, __VA_ARGS__)
#define spa_audio_aec_activate(o) spa_audio_aec_method(o, activate, 1)
#define spa_audio_aec_deactivate(o) spa_audio_aec_method(o, deactivate, 1)
#define spa_audio_aec_enum_props(o,...) spa_audio_aec_method(o, enum_props, 2, __VA_ARGS__)
#define spa_audio_aec_get_params(o,...) spa_audio_aec_method(o, get_params, 2, __VA_ARGS__)
#define spa_audio_aec_set_params(o,...) spa_audio_aec_method(o, set_params, 2, __VA_ARGS__)
#define spa_audio_aec_init2(o,...) spa_audio_aec_method(o, init2, 3, __VA_ARGS__)
static inline int spa_audio_aec_init(struct spa_audio_aec *object,
const struct spa_dict *args, const struct spa_audio_info_raw *info)
{
return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, init, 0, args, info);
}
static inline int spa_audio_aec_run(struct spa_audio_aec *object,
const float *rec[], const float *play[], float *out[], uint32_t n_samples)
{
return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, run, 0, rec, play, out, n_samples);
}
static inline int spa_audio_aec_set_props(struct spa_audio_aec *object, const struct spa_dict *args)
{
return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, set_props, 0, args);
}
static inline int spa_audio_aec_activate(struct spa_audio_aec *object)
{
return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, activate, 1);
}
static inline int spa_audio_aec_deactivate(struct spa_audio_aec *object)
{
return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, deactivate, 1);
}
static inline int spa_audio_aec_enum_props(struct spa_audio_aec *object,
int index, struct spa_pod_builder* builder)
{
return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, enum_props, 2, index, builder);
}
static inline int spa_audio_aec_get_params(struct spa_audio_aec *object,
struct spa_pod_builder* builder)
{
return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, get_params, 2, builder);
}
static inline int spa_audio_aec_set_params(struct spa_audio_aec *object,
const struct spa_pod *args)
{
return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, set_params, 2, args);
}
static inline int spa_audio_aec_init2(struct spa_audio_aec *object,
const struct spa_dict *args,
struct spa_audio_info_raw *play_info,
struct spa_audio_info_raw *rec_info,
struct spa_audio_info_raw *out_info)
{
return spa_api_method_r(int, -ENOTSUP,
spa_audio_aec, &object->iface, init2, 3, args, play_info, rec_info, out_info);
}
#ifdef __cplusplus
} /* extern "C" */

View file

@ -220,20 +220,34 @@ struct spa_device_methods {
const struct spa_pod *param);
};
#define spa_device_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_device *_o = (o); \
spa_interface_call_res(&_o->iface, \
struct spa_device_methods, _res, \
method, (version), ##__VA_ARGS__); \
_res; \
})
static inline int spa_device_add_listener(struct spa_device *object,
struct spa_hook *listener,
const struct spa_device_events *events,
void *data)
{
return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, add_listener, 0,
listener, events, data);
#define spa_device_add_listener(d,...) spa_device_method(d, add_listener, 0, __VA_ARGS__)
#define spa_device_sync(d,...) spa_device_method(d, sync, 0, __VA_ARGS__)
#define spa_device_enum_params(d,...) spa_device_method(d, enum_params, 0, __VA_ARGS__)
#define spa_device_set_param(d,...) spa_device_method(d, set_param, 0, __VA_ARGS__)
}
static inline int spa_device_sync(struct spa_device *object, int seq)
{
return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, sync, 0,
seq);
}
static inline int spa_device_enum_params(struct spa_device *object, int seq,
uint32_t id, uint32_t index, uint32_t max,
const struct spa_pod *filter)
{
return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, enum_params, 0,
seq, id, index, max, filter);
}
static inline int spa_device_set_param(struct spa_device *object,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return spa_api_method_r(int, -ENOTSUP, spa_device, &object->iface, set_param, 0,
id, flags, param);
}
#define SPA_KEY_DEVICE_ENUM_API "device.enum.api" /**< the api used to discover this
* device */

View file

@ -633,44 +633,120 @@ struct spa_node_methods {
int (*process) (void *object);
};
#define spa_node_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_node *_n = o; \
spa_interface_call_res(&_n->iface, \
struct spa_node_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_node_method_fast(o,method,version,...) \
({ \
int _res; \
struct spa_node *_n = o; \
spa_interface_call_fast_res(&_n->iface, \
struct spa_node_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
static inline int spa_node_add_listener(struct spa_node *object,
struct spa_hook *listener,
const struct spa_node_events *events,
void *data)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, add_listener, 0,
listener, events, data);
}
static inline int spa_node_set_callbacks(struct spa_node *object,
const struct spa_node_callbacks *callbacks,
void *data)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, set_callbacks, 0,
callbacks, data);
}
static inline int spa_node_sync(struct spa_node *object, int seq)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, sync, 0,
seq);
}
static inline int spa_node_enum_params(struct spa_node *object, int seq,
uint32_t id, uint32_t start, uint32_t max,
const struct spa_pod *filter)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, enum_params, 0,
seq, id, start, max, filter);
}
static inline int spa_node_set_param(struct spa_node *object,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, set_param, 0,
id, flags, param);
}
static inline int spa_node_set_io(struct spa_node *object,
uint32_t id, void *data, size_t size)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, set_io, 0,
id, data, size);
}
static inline int spa_node_send_command(struct spa_node *object,
const struct spa_command *command)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, send_command, 0,
command);
}
static inline int spa_node_add_port(struct spa_node *object,
enum spa_direction direction, uint32_t port_id,
const struct spa_dict *props)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, add_port, 0,
direction, port_id, props);
}
static inline int spa_node_remove_port(struct spa_node *object,
enum spa_direction direction, uint32_t port_id)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, remove_port, 0,
direction, port_id);
}
static inline int spa_node_port_enum_params(struct spa_node *object, int seq,
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t start, uint32_t max,
const struct spa_pod *filter)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_enum_params, 0,
seq, direction, port_id, id, start, max, filter);
}
static inline int spa_node_port_set_param(struct spa_node *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_set_param, 0,
direction, port_id, id, flags, param);
}
static inline int spa_node_port_use_buffers(struct spa_node *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
struct spa_buffer **buffers,
uint32_t n_buffers)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_use_buffers, 0,
direction, port_id, flags, buffers, n_buffers);
}
static inline int spa_node_port_set_io(struct spa_node *object,
enum spa_direction direction,
uint32_t port_id,
uint32_t id, void *data, size_t size)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_set_io, 0,
direction, port_id, id, data, size);
}
#define spa_node_add_listener(n,...) spa_node_method(n, add_listener, 0, __VA_ARGS__)
#define spa_node_set_callbacks(n,...) spa_node_method(n, set_callbacks, 0, __VA_ARGS__)
#define spa_node_sync(n,...) spa_node_method(n, sync, 0, __VA_ARGS__)
#define spa_node_enum_params(n,...) spa_node_method(n, enum_params, 0, __VA_ARGS__)
#define spa_node_set_param(n,...) spa_node_method(n, set_param, 0, __VA_ARGS__)
#define spa_node_set_io(n,...) spa_node_method(n, set_io, 0, __VA_ARGS__)
#define spa_node_send_command(n,...) spa_node_method(n, send_command, 0, __VA_ARGS__)
#define spa_node_add_port(n,...) spa_node_method(n, add_port, 0, __VA_ARGS__)
#define spa_node_remove_port(n,...) spa_node_method(n, remove_port, 0, __VA_ARGS__)
#define spa_node_port_enum_params(n,...) spa_node_method(n, port_enum_params, 0, __VA_ARGS__)
#define spa_node_port_set_param(n,...) spa_node_method(n, port_set_param, 0, __VA_ARGS__)
#define spa_node_port_use_buffers(n,...) spa_node_method(n, port_use_buffers, 0, __VA_ARGS__)
#define spa_node_port_set_io(n,...) spa_node_method(n, port_set_io, 0, __VA_ARGS__)
#define spa_node_port_reuse_buffer(n,...) spa_node_method(n, port_reuse_buffer, 0, __VA_ARGS__)
#define spa_node_port_reuse_buffer_fast(n,...) spa_node_method_fast(n, port_reuse_buffer, 0, __VA_ARGS__)
#define spa_node_process(n) spa_node_method(n, process, 0)
#define spa_node_process_fast(n) spa_node_method_fast(n, process, 0)
static inline int spa_node_port_reuse_buffer(struct spa_node *object, uint32_t port_id, uint32_t buffer_id)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, port_reuse_buffer, 0,
port_id, buffer_id);
}
static inline int spa_node_port_reuse_buffer_fast(struct spa_node *object, uint32_t port_id, uint32_t buffer_id)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_node, &object->iface, port_reuse_buffer, 0,
port_id, buffer_id);
}
static inline int spa_node_process(struct spa_node *object)
{
return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, process, 0);
}
static inline int spa_node_process_fast(struct spa_node *object)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_node, &object->iface, process, 0);
}
/**
* \}

View file

@ -10,6 +10,7 @@ extern "C" {
#endif
#include <stdarg.h>
#include <errno.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
@ -159,21 +160,30 @@ struct spa_cpu_methods {
int (*zero_denormals) (void *object, bool enable);
};
#define spa_cpu_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_cpu *_c = o; \
spa_interface_call_res(&_c->iface, \
struct spa_cpu_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_cpu_get_flags(c) spa_cpu_method(c, get_flags, 0)
#define spa_cpu_force_flags(c,f) spa_cpu_method(c, force_flags, 0, f)
#define spa_cpu_get_count(c) spa_cpu_method(c, get_count, 0)
#define spa_cpu_get_max_align(c) spa_cpu_method(c, get_max_align, 0)
#define spa_cpu_get_vm_type(c) spa_cpu_method(c, get_vm_type, 1)
#define spa_cpu_zero_denormals(c,e) spa_cpu_method(c, zero_denormals, 2, e)
static inline uint32_t spa_cpu_get_flags(struct spa_cpu *c)
{
return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_flags, 0);
}
static inline int spa_cpu_force_flags(struct spa_cpu *c, uint32_t flags)
{
return spa_api_method_r(int, -ENOTSUP, spa_cpu, &c->iface, force_flags, 0, flags);
}
static inline uint32_t spa_cpu_get_count(struct spa_cpu *c)
{
return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_count, 0);
}
static inline uint32_t spa_cpu_get_max_align(struct spa_cpu *c)
{
return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_max_align, 0);
}
static inline uint32_t spa_cpu_get_vm_type(struct spa_cpu *c)
{
return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_vm_type, 1);
}
static inline int spa_cpu_zero_denormals(struct spa_cpu *c, bool enable)
{
return spa_api_method_r(int, -ENOTSUP, spa_cpu, &c->iface, zero_denormals, 2, enable);
}
/** keys can be given when initializing the cpu handle */
#define SPA_KEY_CPU_FORCE "cpu.force" /**< force cpu flags */

View file

@ -79,29 +79,27 @@ struct spa_dbus_connection {
void *data);
};
#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; \
})
/** \copydoc spa_dbus_connection.get
* \sa spa_dbus_connection.get */
#define spa_dbus_connection_get(c) spa_dbus_connection_call_vp(c,get,0)
static inline void *spa_dbus_connection_get(struct spa_dbus_connection *conn)
{
return spa_api_func_r(void *, NULL, conn, get, 0);
}
/** \copydoc spa_dbus_connection.destroy
* \sa spa_dbus_connection.destroy */
#define spa_dbus_connection_destroy(c) spa_dbus_connection_call(c,destroy,0)
static inline void spa_dbus_connection_destroy(struct spa_dbus_connection *conn)
{
spa_api_func_v(conn, destroy, 0);
}
/** \copydoc spa_dbus_connection.add_listener
* \sa spa_dbus_connection.add_listener */
#define spa_dbus_connection_add_listener(c,...) spa_dbus_connection_call(c,add_listener,1,__VA_ARGS__)
static inline void spa_dbus_connection_add_listener(struct spa_dbus_connection *conn,
struct spa_hook *listener,
const struct spa_dbus_connection_events *events,
void *data)
{
spa_api_func_v(conn, add_listener, 1, listener, events, data);
}
struct spa_dbus_methods {
#define SPA_VERSION_DBUS_METHODS 0
@ -129,11 +127,8 @@ struct spa_dbus_methods {
static inline struct spa_dbus_connection *
spa_dbus_get_connection(struct spa_dbus *dbus, enum spa_dbus_type type)
{
struct spa_dbus_connection *res = NULL;
spa_interface_call_res(&dbus->iface,
struct spa_dbus_methods, res,
get_connection, 0, type);
return res;
return spa_api_method_r(struct spa_dbus_connection *, NULL,
spa_dbus, &dbus->iface, get_connection, 0, type);
}
/**

View file

@ -56,24 +56,16 @@ SPA_FORMAT_ARG_FUNC(2)
static inline const char *
spa_i18n_text(struct spa_i18n *i18n, const char *msgid)
{
const char *res = msgid;
if (SPA_LIKELY(i18n != NULL))
spa_interface_call_res(&i18n->iface,
struct spa_i18n_methods, res,
text, 0, msgid);
return res;
return spa_api_method_null_r(const char *, msgid, spa_i18n, &i18n->iface,
text, 0, msgid);
}
static inline const char *
spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid,
const char *msgid_plural, unsigned long int n)
{
const char *res = n == 1 ? msgid : msgid_plural;
if (SPA_LIKELY(i18n != NULL))
spa_interface_call_res(&i18n->iface,
struct spa_i18n_methods, res,
ntext, 0, msgid, msgid_plural, n);
return res;
return spa_api_method_null_r(const char *, n == 1 ? msgid : msgid_plural,
spa_i18n, &i18n->iface, ntext, 0, msgid, msgid_plural, n);
}
/**

View file

@ -255,20 +255,22 @@ static inline bool spa_log_level_topic_enabled(const struct spa_log *log,
})
/* Transparently calls to version 0 logv if v1 is not supported */
#define spa_log_logtv(l,lev,topic,...) \
({ \
struct spa_log *_l = l; \
if (SPA_UNLIKELY(spa_log_level_topic_enabled(_l, topic, lev))) { \
struct spa_interface *_if = &_l->iface; \
if (!spa_interface_call(_if, \
struct spa_log_methods, logtv, 1, \
lev, topic, \
__VA_ARGS__)) \
spa_interface_call(_if, \
struct spa_log_methods, logv, 0, \
lev, __VA_ARGS__); \
} \
})
SPA_PRINTF_FUNC(7, 0)
static inline void spa_log_logtv(struct spa_log *l, enum spa_log_level level,
const struct spa_log_topic *topic, const char *file, int line,
const char *func, const char *fmt, va_list args)
{
if (SPA_UNLIKELY(spa_log_level_topic_enabled(l, topic, level))) {
struct spa_interface *i = &l->iface;
if (!spa_interface_call(i,
struct spa_log_methods, logtv, 1,
level, topic,
file, line, func, fmt, args))
spa_interface_call(i,
struct spa_log_methods, logv, 0,
level, file, line, func, fmt, args);
}
}
#define spa_logt_lev(l,lev,t,...) \
spa_log_logt(l,lev,t,__FILE__,__LINE__,__func__,__VA_ARGS__)

View file

@ -9,6 +9,8 @@
extern "C" {
#endif
#include <errno.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <spa/support/system.h>
@ -125,21 +127,29 @@ struct spa_loop_methods {
void *user_data);
};
#define spa_loop_method(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_loop *_o = o; \
spa_interface_call_res(&_o->iface, \
struct spa_loop_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_loop_add_source(l,...) spa_loop_method(l,add_source,0,##__VA_ARGS__)
#define spa_loop_update_source(l,...) spa_loop_method(l,update_source,0,##__VA_ARGS__)
#define spa_loop_remove_source(l,...) spa_loop_method(l,remove_source,0,##__VA_ARGS__)
#define spa_loop_invoke(l,...) spa_loop_method(l,invoke,0,##__VA_ARGS__)
static inline int spa_loop_add_source(struct spa_loop *object, struct spa_source *source)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop, &object->iface, add_source, 0, source);
}
static inline int spa_loop_update_source(struct spa_loop *object, struct spa_source *source)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop, &object->iface, update_source, 0, source);
}
static inline int spa_loop_remove_source(struct spa_loop *object, struct spa_source *source)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop, &object->iface, remove_source, 0, source);
}
static inline int spa_loop_invoke(struct spa_loop *object,
spa_invoke_func_t func, uint32_t seq, const void *data,
size_t size, bool block, void *user_data)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop, &object->iface, invoke, 0, func, seq, data,
size, block, user_data);
}
/** Control hooks. These hooks can't be removed from their
* callbacks and must be removed from a safe place (when the loop
@ -155,21 +165,19 @@ struct spa_loop_control_hooks {
void (*after) (void *data);
};
#define spa_loop_control_hook_before(l) \
({ \
struct spa_hook_list *_l = l; \
struct spa_hook *_h; \
spa_list_for_each_reverse(_h, &_l->list, link) \
spa_callbacks_call_fast(&_h->cb, struct spa_loop_control_hooks, before, 0); \
})
static inline void spa_loop_control_hook_before(struct spa_hook_list *l)
{
struct spa_hook *h;
spa_list_for_each_reverse(h, &l->list, link)
spa_callbacks_call_fast(&h->cb, struct spa_loop_control_hooks, before, 0);
}
#define spa_loop_control_hook_after(l) \
({ \
struct spa_hook_list *_l = l; \
struct spa_hook *_h; \
spa_list_for_each(_h, &_l->list, link) \
spa_callbacks_call_fast(&_h->cb, struct spa_loop_control_hooks, after, 0); \
})
static inline void spa_loop_control_hook_after(struct spa_hook_list *l)
{
struct spa_hook *h;
spa_list_for_each(h, &l->list, link)
spa_callbacks_call_fast(&h->cb, struct spa_loop_control_hooks, after, 0);
}
/**
* Control an event loop
@ -231,42 +239,43 @@ struct spa_loop_control_methods {
int (*check) (void *object);
};
#define spa_loop_control_method_v(o,method,version,...) \
({ \
struct spa_loop_control *_o = o; \
spa_interface_call(&_o->iface, \
struct spa_loop_control_methods, \
method, version, ##__VA_ARGS__); \
})
#define spa_loop_control_method_r(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_loop_control *_o = o; \
spa_interface_call_res(&_o->iface, \
struct spa_loop_control_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_loop_control_method_fast_r(o,method,version,...) \
({ \
int _res; \
struct spa_loop_control *_o = o; \
spa_interface_call_fast_res(&_o->iface, \
struct spa_loop_control_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_loop_control_get_fd(l) spa_loop_control_method_r(l,get_fd,0)
#define spa_loop_control_add_hook(l,...) spa_loop_control_method_v(l,add_hook,0,__VA_ARGS__)
#define spa_loop_control_enter(l) spa_loop_control_method_v(l,enter,0)
#define spa_loop_control_leave(l) spa_loop_control_method_v(l,leave,0)
#define spa_loop_control_iterate(l,...) spa_loop_control_method_r(l,iterate,0,__VA_ARGS__)
#define spa_loop_control_check(l) spa_loop_control_method_r(l,check,1)
#define spa_loop_control_iterate_fast(l,...) spa_loop_control_method_fast_r(l,iterate,0,__VA_ARGS__)
static inline int spa_loop_control_get_fd(struct spa_loop_control *object)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop_control, &object->iface, get_fd, 0);
}
static inline void spa_loop_control_add_hook(struct spa_loop_control *object,
struct spa_hook *hook, const struct spa_loop_control_hooks *hooks,
void *data)
{
spa_api_method_v(spa_loop_control, &object->iface, add_hook, 0,
hook, hooks, data);
}
static inline void spa_loop_control_enter(struct spa_loop_control *object)
{
spa_api_method_v(spa_loop_control, &object->iface, enter, 0);
}
static inline void spa_loop_control_leave(struct spa_loop_control *object)
{
spa_api_method_v(spa_loop_control, &object->iface, leave, 0);
}
static inline int spa_loop_control_iterate(struct spa_loop_control *object,
int timeout)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop_control, &object->iface, iterate, 0, timeout);
}
static inline int spa_loop_control_iterate_fast(struct spa_loop_control *object,
int timeout)
{
return spa_api_method_fast_r(int, -ENOTSUP,
spa_loop_control, &object->iface, iterate, 0, timeout);
}
static inline int spa_loop_control_check(struct spa_loop_control *object)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop_control, &object->iface, check, 1);
}
typedef void (*spa_source_io_func_t) (void *data, int fd, uint32_t mask);
typedef void (*spa_source_idle_func_t) (void *data);
@ -317,44 +326,71 @@ struct spa_loop_utils_methods {
void (*destroy_source) (void *object, struct spa_source *source);
};
#define spa_loop_utils_method_v(o,method,version,...) \
({ \
struct spa_loop_utils *_o = o; \
spa_interface_call(&_o->iface, \
struct spa_loop_utils_methods, \
method, version, ##__VA_ARGS__); \
})
#define spa_loop_utils_method_r(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_loop_utils *_o = o; \
spa_interface_call_res(&_o->iface, \
struct spa_loop_utils_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_loop_utils_method_s(o,method,version,...) \
({ \
struct spa_source *_res = NULL; \
struct spa_loop_utils *_o = o; \
spa_interface_call_res(&_o->iface, \
struct spa_loop_utils_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_loop_utils_add_io(l,...) spa_loop_utils_method_s(l,add_io,0,__VA_ARGS__)
#define spa_loop_utils_update_io(l,...) spa_loop_utils_method_r(l,update_io,0,__VA_ARGS__)
#define spa_loop_utils_add_idle(l,...) spa_loop_utils_method_s(l,add_idle,0,__VA_ARGS__)
#define spa_loop_utils_enable_idle(l,...) spa_loop_utils_method_r(l,enable_idle,0,__VA_ARGS__)
#define spa_loop_utils_add_event(l,...) spa_loop_utils_method_s(l,add_event,0,__VA_ARGS__)
#define spa_loop_utils_signal_event(l,...) spa_loop_utils_method_r(l,signal_event,0,__VA_ARGS__)
#define spa_loop_utils_add_timer(l,...) spa_loop_utils_method_s(l,add_timer,0,__VA_ARGS__)
#define spa_loop_utils_update_timer(l,...) spa_loop_utils_method_r(l,update_timer,0,__VA_ARGS__)
#define spa_loop_utils_add_signal(l,...) spa_loop_utils_method_s(l,add_signal,0,__VA_ARGS__)
#define spa_loop_utils_destroy_source(l,...) spa_loop_utils_method_v(l,destroy_source,0,__VA_ARGS__)
static inline struct spa_source *
spa_loop_utils_add_io(struct spa_loop_utils *object, int fd, uint32_t mask,
bool close, spa_source_io_func_t func, void *data)
{
return spa_api_method_r(struct spa_source *, NULL,
spa_loop_utils, &object->iface, add_io, 0, fd, mask, close, func, data);
}
static inline int spa_loop_utils_update_io(struct spa_loop_utils *object,
struct spa_source *source, uint32_t mask)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop_utils, &object->iface, update_io, 0, source, mask);
}
static inline struct spa_source *
spa_loop_utils_add_idle(struct spa_loop_utils *object, bool enabled,
spa_source_idle_func_t func, void *data)
{
return spa_api_method_r(struct spa_source *, NULL,
spa_loop_utils, &object->iface, add_idle, 0, enabled, func, data);
}
static inline int spa_loop_utils_enable_idle(struct spa_loop_utils *object,
struct spa_source *source, bool enabled)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop_utils, &object->iface, enable_idle, 0, source, enabled);
}
static inline struct spa_source *
spa_loop_utils_add_event(struct spa_loop_utils *object, spa_source_event_func_t func, void *data)
{
return spa_api_method_r(struct spa_source *, NULL,
spa_loop_utils, &object->iface, add_event, 0, func, data);
}
static inline int spa_loop_utils_signal_event(struct spa_loop_utils *object,
struct spa_source *source)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop_utils, &object->iface, signal_event, 0, source);
}
static inline struct spa_source *
spa_loop_utils_add_timer(struct spa_loop_utils *object, spa_source_timer_func_t func, void *data)
{
return spa_api_method_r(struct spa_source *, NULL,
spa_loop_utils, &object->iface, add_timer, 0, func, data);
}
static inline int spa_loop_utils_update_timer(struct spa_loop_utils *object,
struct spa_source *source, struct timespec *value,
struct timespec *interval, bool absolute)
{
return spa_api_method_r(int, -ENOTSUP,
spa_loop_utils, &object->iface, update_timer, 0, source,
value, interval, absolute);
}
static inline struct spa_source *
spa_loop_utils_add_signal(struct spa_loop_utils *object, int signal_number,
spa_source_signal_func_t func, void *data)
{
return spa_api_method_r(struct spa_source *, NULL,
spa_loop_utils, &object->iface, add_signal, 0,
signal_number, func, data);
}
static inline void spa_loop_utils_destroy_source(struct spa_loop_utils *object,
struct spa_source *source)
{
spa_api_method_v(spa_loop_utils, &object->iface, destroy_source, 0, source);
}
/**
* \}

View file

@ -51,23 +51,15 @@ struct spa_plugin_loader_methods {
static inline struct spa_handle *
spa_plugin_loader_load(struct spa_plugin_loader *loader, const char *factory_name, const struct spa_dict *info)
{
struct spa_handle *res = NULL;
if (SPA_LIKELY(loader != NULL))
spa_interface_call_res(&loader->iface,
struct spa_plugin_loader_methods, res,
load, 0, factory_name, info);
return res;
return spa_api_method_null_r(struct spa_handle *, NULL, spa_plugin_loader, &loader->iface,
load, 0, factory_name, info);
}
static inline int
spa_plugin_loader_unload(struct spa_plugin_loader *loader, struct spa_handle *handle)
{
int res = -1;
if (SPA_LIKELY(loader != NULL))
spa_interface_call_res(&loader->iface,
struct spa_plugin_loader_methods, res,
unload, 0, handle);
return res;
return spa_api_method_null_r(int, -1, spa_plugin_loader, &loader->iface,
unload, 0, handle);
}
/**

View file

@ -9,7 +9,10 @@
extern "C" {
#endif
#include <errno.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <spa/utils/dict.h>
/**
@ -51,8 +54,17 @@ struct spa_handle {
int (*clear) (struct spa_handle *handle);
};
#define spa_handle_get_interface(h,...) (h)->get_interface((h),__VA_ARGS__)
#define spa_handle_clear(h) (h)->clear((h))
static inline int
spa_handle_get_interface(struct spa_handle *object,
const char *type, void **iface)
{
return spa_api_func_r(int, -ENOTSUP, object, get_interface, 0, type, iface);
}
static inline int
spa_handle_clear(struct spa_handle *object)
{
return spa_api_func_r(int, -ENOTSUP, object, clear, 0);
}
/**
* This structure lists the information about available interfaces on
@ -158,9 +170,27 @@ struct spa_handle_factory {
uint32_t *index);
};
#define spa_handle_factory_get_size(h,...) (h)->get_size((h),__VA_ARGS__)
#define spa_handle_factory_init(h,...) (h)->init((h),__VA_ARGS__)
#define spa_handle_factory_enum_interface_info(h,...) (h)->enum_interface_info((h),__VA_ARGS__)
static inline size_t
spa_handle_factory_get_size(const struct spa_handle_factory *object,
const struct spa_dict *params)
{
return spa_api_func_r(size_t, 0, object, get_size, 1, params);
}
static inline int
spa_handle_factory_init(const struct spa_handle_factory *object,
struct spa_handle *handle, const struct spa_dict *info,
const struct spa_support *support, uint32_t n_support)
{
return spa_api_func_r(int, -ENOTSUP, object, init, 1, handle, info,
support, n_support);
}
static inline int
spa_handle_factory_enum_interface_info(const struct spa_handle_factory *object,
const struct spa_interface_info **info, uint32_t *index)
{
return spa_api_func_r(int, -ENOTSUP, object, enum_interface_info, 1,
info, index);
}
/**
* The function signature of the entry point in a plugin.

View file

@ -12,6 +12,7 @@ extern "C" {
struct itimerspec;
#include <time.h>
#include <errno.h>
#include <sys/types.h>
#include <spa/utils/defs.h>
@ -97,41 +98,106 @@ struct spa_system_methods {
int (*signalfd_read) (void *object, int fd, int *signal);
};
#define spa_system_method_r(o,method,version,...) \
({ \
volatile int _res = -ENOTSUP; \
struct spa_system *_o = o; \
spa_interface_call_fast_res(&_o->iface, \
struct spa_system_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
static inline ssize_t spa_system_read(struct spa_system *object, int fd, void *buf, size_t count)
{
return spa_api_method_fast_r(ssize_t, -ENOTSUP, spa_system, &object->iface, read, 0, fd, buf, count);
}
static inline ssize_t spa_system_write(struct spa_system *object, int fd, const void *buf, size_t count)
{
return spa_api_method_fast_r(ssize_t, -ENOTSUP, spa_system, &object->iface, write, 0, fd, buf, count);
}
#define spa_system_ioctl(object,fd,request,...) \
spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, ioctl, 0, fd, request, ##__VA_ARGS__)
#define spa_system_read(s,...) spa_system_method_r(s,read,0,__VA_ARGS__)
#define spa_system_write(s,...) spa_system_method_r(s,write,0,__VA_ARGS__)
#define spa_system_ioctl(s,...) spa_system_method_r(s,ioctl,0,__VA_ARGS__)
#define spa_system_close(s,...) spa_system_method_r(s,close,0,__VA_ARGS__)
static inline int spa_system_close(struct spa_system *object, int fd)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, close, 0, fd);
}
static inline int spa_system_clock_gettime(struct spa_system *object,
int clockid, struct timespec *value)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, clock_gettime, 0, clockid, value);
}
static inline int spa_system_clock_getres(struct spa_system *object,
int clockid, struct timespec *res)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, clock_getres, 0, clockid, res);
}
#define spa_system_clock_gettime(s,...) spa_system_method_r(s,clock_gettime,0,__VA_ARGS__)
#define spa_system_clock_getres(s,...) spa_system_method_r(s,clock_getres,0,__VA_ARGS__)
static inline int spa_system_pollfd_create(struct spa_system *object, int flags)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_create, 0, flags);
}
static inline int spa_system_pollfd_add(struct spa_system *object, int pfd, int fd, uint32_t events, void *data)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_add, 0, pfd, fd, events, data);
}
static inline int spa_system_pollfd_mod(struct spa_system *object, int pfd, int fd, uint32_t events, void *data)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_mod, 0, pfd, fd, events, data);
}
static inline int spa_system_pollfd_del(struct spa_system *object, int pfd, int fd)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_del, 0, pfd, fd);
}
static inline int spa_system_pollfd_wait(struct spa_system *object, int pfd,
struct spa_poll_event *ev, int n_ev, int timeout)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_wait, 0, pfd, ev, n_ev, timeout);
}
#define spa_system_pollfd_create(s,...) spa_system_method_r(s,pollfd_create,0,__VA_ARGS__)
#define spa_system_pollfd_add(s,...) spa_system_method_r(s,pollfd_add,0,__VA_ARGS__)
#define spa_system_pollfd_mod(s,...) spa_system_method_r(s,pollfd_mod,0,__VA_ARGS__)
#define spa_system_pollfd_del(s,...) spa_system_method_r(s,pollfd_del,0,__VA_ARGS__)
#define spa_system_pollfd_wait(s,...) spa_system_method_r(s,pollfd_wait,0,__VA_ARGS__)
static inline int spa_system_timerfd_create(struct spa_system *object, int clockid, int flags)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_create, 0, clockid, flags);
}
#define spa_system_timerfd_create(s,...) spa_system_method_r(s,timerfd_create,0,__VA_ARGS__)
#define spa_system_timerfd_settime(s,...) spa_system_method_r(s,timerfd_settime,0,__VA_ARGS__)
#define spa_system_timerfd_gettime(s,...) spa_system_method_r(s,timerfd_gettime,0,__VA_ARGS__)
#define spa_system_timerfd_read(s,...) spa_system_method_r(s,timerfd_read,0,__VA_ARGS__)
static inline int spa_system_timerfd_settime(struct spa_system *object,
int fd, int flags,
const struct itimerspec *new_value,
struct itimerspec *old_value)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_settime, 0,
fd, flags, new_value, old_value);
}
#define spa_system_eventfd_create(s,...) spa_system_method_r(s,eventfd_create,0,__VA_ARGS__)
#define spa_system_eventfd_write(s,...) spa_system_method_r(s,eventfd_write,0,__VA_ARGS__)
#define spa_system_eventfd_read(s,...) spa_system_method_r(s,eventfd_read,0,__VA_ARGS__)
static inline int spa_system_timerfd_gettime(struct spa_system *object,
int fd, struct itimerspec *curr_value)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_gettime, 0,
fd, curr_value);
}
static inline int spa_system_timerfd_read(struct spa_system *object, int fd, uint64_t *expirations)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_read, 0,
fd, expirations);
}
#define spa_system_signalfd_create(s,...) spa_system_method_r(s,signalfd_create,0,__VA_ARGS__)
#define spa_system_signalfd_read(s,...) spa_system_method_r(s,signalfd_read,0,__VA_ARGS__)
static inline int spa_system_eventfd_create(struct spa_system *object, int flags)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_create, 0, flags);
}
static inline int spa_system_eventfd_write(struct spa_system *object, int fd, uint64_t count)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_write, 0,
fd, count);
}
static inline int spa_system_eventfd_read(struct spa_system *object, int fd, uint64_t *count)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_read, 0,
fd, count);
}
static inline int spa_system_signalfd_create(struct spa_system *object, int signal, int flags)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, signalfd_create, 0,
signal, flags);
}
static inline int spa_system_signalfd_read(struct spa_system *object, int fd, int *signal)
{
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, signalfd_read, 0,
fd, signal);
}
/**
* \}

View file

@ -61,11 +61,9 @@ struct spa_thread_utils_methods {
static inline struct spa_thread *spa_thread_utils_create(struct spa_thread_utils *o,
const struct spa_dict *props, void *(*start_routine)(void*), void *arg)
{
struct spa_thread *res = NULL;
spa_interface_call_res(&o->iface,
struct spa_thread_utils_methods, res, create, 0,
return spa_api_method_r(struct spa_thread *, NULL,
spa_thread_utils, &o->iface, create, 0,
props, start_routine, arg);
return res;
}
/** \copydoc spa_thread_utils_methods.join
@ -73,11 +71,9 @@ static inline struct spa_thread *spa_thread_utils_create(struct spa_thread_utils
static inline int spa_thread_utils_join(struct spa_thread_utils *o,
struct spa_thread *thread, void **retval)
{
int res = -ENOTSUP;
spa_interface_call_res(&o->iface,
struct spa_thread_utils_methods, res, join, 0,
return spa_api_method_r(int, -ENOTSUP,
spa_thread_utils, &o->iface, join, 0,
thread, retval);
return res;
}
/** \copydoc spa_thread_utils_methods.get_rt_range
@ -85,11 +81,9 @@ static inline int spa_thread_utils_join(struct spa_thread_utils *o,
static inline int spa_thread_utils_get_rt_range(struct spa_thread_utils *o,
const struct spa_dict *props, int *min, int *max)
{
int res = -ENOTSUP;
spa_interface_call_res(&o->iface,
struct spa_thread_utils_methods, res, get_rt_range, 0,
return spa_api_method_r(int, -ENOTSUP,
spa_thread_utils, &o->iface, get_rt_range, 0,
props, min, max);
return res;
}
/** \copydoc spa_thread_utils_methods.acquire_rt
@ -97,11 +91,9 @@ static inline int spa_thread_utils_get_rt_range(struct spa_thread_utils *o,
static inline int spa_thread_utils_acquire_rt(struct spa_thread_utils *o,
struct spa_thread *thread, int priority)
{
int res = -ENOTSUP;
spa_interface_call_res(&o->iface,
struct spa_thread_utils_methods, res, acquire_rt, 0,
return spa_api_method_r(int, -ENOTSUP,
spa_thread_utils, &o->iface, acquire_rt, 0,
thread, priority);
return res;
}
/** \copydoc spa_thread_utils_methods.drop_rt
@ -109,10 +101,8 @@ static inline int spa_thread_utils_acquire_rt(struct spa_thread_utils *o,
static inline int spa_thread_utils_drop_rt(struct spa_thread_utils *o,
struct spa_thread *thread)
{
int res = -ENOTSUP;
spa_interface_call_res(&o->iface,
struct spa_thread_utils_methods, res, drop_rt, 0, thread);
return res;
return spa_api_method_r(int, -ENOTSUP,
spa_thread_utils, &o->iface, drop_rt, 0, thread);
}
#define SPA_KEY_THREAD_NAME "thread.name" /* the thread name */

View file

@ -245,6 +245,69 @@ struct spa_interface {
#define spa_interface_call_fast_res(iface,method_type,res,method,vers,...) \
spa_callbacks_call_fast_res(&(iface)->cb,method_type,res,method,vers,##__VA_ARGS__)
#define spa_api_func_v(o,method,version,...) \
({ \
if (SPA_LIKELY(SPA_CALLBACK_CHECK(o,method,version))) \
(o)->method(o, ##__VA_ARGS__); \
})
#define spa_api_func_r(rtype,def,o,method,version,...) \
({ \
rtype _res = def; \
if (SPA_LIKELY(SPA_CALLBACK_CHECK(o,method,version))) \
_res = (o)->method(o, ##__VA_ARGS__); \
_res; \
})
#define spa_api_func_fast(o,method,...) \
({ \
(o)->method(o, ##__VA_ARGS__); \
})
#define spa_api_method_v(type,o,method,version,...) \
({ \
struct spa_interface *_i = o; \
spa_interface_call(_i, struct type ##_methods, \
method, version, ##__VA_ARGS__); \
})
#define spa_api_method_r(rtype,def,type,o,method,version,...) \
({ \
rtype _res = def; \
struct spa_interface *_i = o; \
spa_interface_call_res(_i, struct type ##_methods, \
_res, method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_api_method_null_v(type,o,method,version,...) \
({ \
struct spa_interface *_i = o; \
if (SPA_LIKELY(_i != NULL)) \
spa_interface_call(_i, struct type ##_methods, \
method, version, ##__VA_ARGS__); \
})
#define spa_api_method_null_r(rtype,def,type,o,method,version,...) \
({ \
rtype _res = def; \
struct spa_interface *_i = o; \
if (SPA_LIKELY(_i != NULL)) \
spa_interface_call_res(_i, struct type ##_methods, \
_res, method, version, ##__VA_ARGS__); \
_res; \
})
#define spa_api_method_fast_v(type,o,method,version,...) \
({ \
struct spa_interface *_i = o; \
spa_interface_call_fast(_i, struct type ##_methods, \
method, version, ##__VA_ARGS__); \
})
#define spa_api_method_fast_r(rtype,def,type,o,method,version,...) \
({ \
rtype _res = def; \
struct spa_interface *_i = o; \
spa_interface_call_fast_res(_i, struct type ##_methods, \
_res, method, version, ##__VA_ARGS__); \
_res; \
})
/**
* \}
*/