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

@ -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 */