mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-12 13:30:15 -05:00
System: More work on making system functions pluggable
Move the epoll functions to the system functions and make the loop use those. Use simple mask for events instead of enum. Add the used system api in pw_loop. Add System API to spa_support and use it where possible. Pass the system API used in the realtime loops in spa_support as well and use this in the realtime paths. Improve bootstrapping, load only the log and cpu interfaces because those can/need to be shared between instances. Let the core load the other interfaces. Add keys to configure the System and Loop implementations used in pw_loop.
This commit is contained in:
parent
86dc0496a5
commit
db88e9f954
22 changed files with 455 additions and 342 deletions
|
|
@ -32,6 +32,7 @@ extern "C" {
|
|||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/hook.h>
|
||||
#include <spa/utils/result.h>
|
||||
#include <spa/support/system.h>
|
||||
|
||||
#define SPA_VERSION_LOOP 0
|
||||
struct spa_loop { struct spa_interface iface; };
|
||||
|
|
@ -41,13 +42,6 @@ struct spa_loop_control { struct spa_interface iface; };
|
|||
struct spa_loop_utils { struct spa_interface iface; };
|
||||
struct spa_source;
|
||||
|
||||
enum spa_io {
|
||||
SPA_IO_IN = (1 << 0),
|
||||
SPA_IO_OUT = (1 << 1),
|
||||
SPA_IO_HUP = (1 << 2),
|
||||
SPA_IO_ERR = (1 << 3),
|
||||
};
|
||||
|
||||
typedef void (*spa_source_func_t) (struct spa_source *source);
|
||||
|
||||
struct spa_source {
|
||||
|
|
@ -55,8 +49,8 @@ struct spa_source {
|
|||
spa_source_func_t func;
|
||||
void *data;
|
||||
int fd;
|
||||
enum spa_io mask;
|
||||
enum spa_io rmask;
|
||||
uint32_t mask;
|
||||
uint32_t rmask;
|
||||
};
|
||||
|
||||
typedef int (*spa_invoke_func_t) (struct spa_loop *loop,
|
||||
|
|
@ -202,7 +196,7 @@ struct spa_loop_control_methods {
|
|||
#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__)
|
||||
|
||||
typedef void (*spa_source_io_func_t) (void *data, int fd, enum spa_io mask);
|
||||
typedef void (*spa_source_io_func_t) (void *data, int fd, uint32_t mask);
|
||||
typedef void (*spa_source_idle_func_t) (void *data);
|
||||
typedef void (*spa_source_event_func_t) (void *data, uint64_t count);
|
||||
typedef void (*spa_source_timer_func_t) (void *data, uint64_t expirations);
|
||||
|
|
@ -219,11 +213,11 @@ struct spa_loop_utils_methods {
|
|||
|
||||
struct spa_source *(*add_io) (void *object,
|
||||
int fd,
|
||||
enum spa_io mask,
|
||||
uint32_t mask,
|
||||
bool close,
|
||||
spa_source_io_func_t func, void *data);
|
||||
|
||||
int (*update_io) (void *object, struct spa_source *source, enum spa_io mask);
|
||||
int (*update_io) (void *object, struct spa_source *source, uint32_t mask);
|
||||
|
||||
struct spa_source *(*add_idle) (void *object,
|
||||
bool enabled,
|
||||
|
|
|
|||
|
|
@ -29,23 +29,36 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/hook.h>
|
||||
#include <spa/utils/result.h>
|
||||
|
||||
/**
|
||||
* a collection of system functions
|
||||
* a collection of core system functions
|
||||
*/
|
||||
#define SPA_VERSION_SYSTEM 0
|
||||
struct spa_system { struct spa_interface iface; };
|
||||
|
||||
/* IO events */
|
||||
#define SPA_IO_IN (1 << 0)
|
||||
#define SPA_IO_OUT (1 << 1)
|
||||
#define SPA_IO_HUP (1 << 2)
|
||||
#define SPA_IO_ERR (1 << 3)
|
||||
|
||||
/* flags */
|
||||
#define SPA_FD_CLOEXEC (1<<0)
|
||||
#define SPA_FD_NONBLOCK (1<<1)
|
||||
#define SPA_FD_EVENT_SEMAPHORE (1<<2)
|
||||
#define SPA_FD_TIMER_ABSTIME (1<<3)
|
||||
#define SPA_FD_TIMER_CANCEL_ON_SET (1<<4)
|
||||
|
||||
struct spa_poll_event {
|
||||
uint32_t events;
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct spa_system_methods {
|
||||
#define SPA_VERSION_SYSTEM_METHODS 0
|
||||
uint32_t version;
|
||||
|
|
@ -62,6 +75,14 @@ struct spa_system_methods {
|
|||
int (*clock_getres) (void *object,
|
||||
int clockid, struct timespec *res);
|
||||
|
||||
/* poll */
|
||||
int (*pollfd_create) (void *object, int flags);
|
||||
int (*pollfd_add) (void *object, int pfd, int fd, uint32_t events, void *data);
|
||||
int (*pollfd_mod) (void *object, int pfd, int fd, uint32_t events, void *data);
|
||||
int (*pollfd_del) (void *object, int pfd, int fd);
|
||||
int (*pollfd_wait) (void *object, int pfd,
|
||||
struct spa_poll_event *ev, int n_ev, int timeout);
|
||||
|
||||
/* timers */
|
||||
int (*timerfd_create) (void *object, int clockid, int flags);
|
||||
int (*timerfd_settime) (void *object,
|
||||
|
|
@ -101,6 +122,12 @@ struct spa_system_methods {
|
|||
#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__)
|
||||
|
||||
#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__)
|
||||
|
||||
#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__)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue