system.h
Go to the documentation of this file.
/* Simple Plugin API
*
* Copyright © 2019 Wim Taymans
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef SPA_SYSTEM_H
#define SPA_SYSTEM_H
#ifdef __cplusplus
extern "C" {
#endif
struct itimerspec;
#include <time.h>
#include <sys/types.h>
#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#define SPA_TYPE_INTERFACE_System SPA_TYPE_INFO_INTERFACE_BASE "System"
#define SPA_TYPE_INTERFACE_DataSystem SPA_TYPE_INFO_INTERFACE_BASE "DataSystem"
#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 << 2)
#define SPA_IO_ERR (1 << 3)
#define SPA_IO_HUP (1 << 4)
/* 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;
/* read/write/ioctl */
ssize_t (*read) (void *object, int fd, void *buf, size_t count);
ssize_t (*write) (void *object, int fd, const void *buf, size_t count);
int (*ioctl) (void *object, int fd, unsigned long request, ...);
int (*close) (void *object, int fd);
/* clock */
int (*clock_gettime) (void *object,
int clockid, struct timespec *value);
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,
int fd, int flags,
const struct itimerspec *new_value,
struct itimerspec *old_value);
int (*timerfd_gettime) (void *object,
int fd, struct itimerspec *curr_value);
int (*timerfd_read) (void *object, int fd, uint64_t *expirations);
/* events */
int (*eventfd_create) (void *object, int flags);
int (*eventfd_write) (void *object, int fd, uint64_t count);
int (*eventfd_read) (void *object, int fd, uint64_t *count);
/* signals */
int (*signalfd_create) (void *object, int signal, int flags);
int (*signalfd_read) (void *object, int fd, int *signal);
};
#define spa_system_method_r(o,method,version,...) \
({ \
int _res = -ENOTSUP; \
struct spa_system *_o = o; \
spa_interface_call_res(&_o->iface, \
struct spa_system_methods, _res, \
method, version, ##__VA_ARGS__); \
_res; \
})
#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__)
#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__)
#define spa_system_timerfd_read(s,...) spa_system_method_r(s,timerfd_read,0,__VA_ARGS__)
#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__)
#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__)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_SYSTEM_H */
defs.h
spa/utils/defs.h
hook.h
spa/utils/hook.h
itimerspec
spa_interface
Definition: hook.h:158
spa_poll_event
Definition: system.h:89
spa_poll_event::events
uint32_t events
Definition: system.h:90
spa_poll_event::data
void * data
Definition: system.h:91
spa_system_methods
Definition: system.h:94
spa_system_methods::pollfd_del
int(* pollfd_del)(void *object, int pfd, int fd)
Definition: system.h:115
spa_system_methods::eventfd_read
int(* eventfd_read)(void *object, int fd, uint64_t *count)
Definition: system.h:132
spa_system_methods::signalfd_read
int(* signalfd_read)(void *object, int fd, int *signal)
Definition: system.h:136
spa_system_methods::pollfd_wait
int(* pollfd_wait)(void *object, int pfd, struct spa_poll_event *ev, int n_ev, int timeout)
Definition: system.h:116
spa_system_methods::timerfd_create
int(* timerfd_create)(void *object, int clockid, int flags)
Definition: system.h:120
spa_system_methods::eventfd_write
int(* eventfd_write)(void *object, int fd, uint64_t count)
Definition: system.h:131
spa_system_methods::eventfd_create
int(* eventfd_create)(void *object, int flags)
Definition: system.h:130
spa_system_methods::read
ssize_t(* read)(void *object, int fd, void *buf, size_t count)
Definition: system.h:100
spa_system_methods::version
uint32_t version
Definition: system.h:97
spa_system_methods::clock_getres
int(* clock_getres)(void *object, int clockid, struct timespec *res)
Definition: system.h:108
spa_system_methods::timerfd_read
int(* timerfd_read)(void *object, int fd, uint64_t *expirations)
Definition: system.h:127
spa_system_methods::close
int(* close)(void *object, int fd)
Definition: system.h:103
spa_system_methods::pollfd_create
int(* pollfd_create)(void *object, int flags)
Definition: system.h:112
spa_system_methods::clock_gettime
int(* clock_gettime)(void *object, int clockid, struct timespec *value)
Definition: system.h:106
spa_system_methods::write
ssize_t(* write)(void *object, int fd, const void *buf, size_t count)
Definition: system.h:101
spa_system_methods::pollfd_add
int(* pollfd_add)(void *object, int pfd, int fd, uint32_t events, void *data)
Definition: system.h:113
spa_system_methods::timerfd_gettime
int(* timerfd_gettime)(void *object, int fd, struct itimerspec *curr_value)
Definition: system.h:125
spa_system_methods::signalfd_create
int(* signalfd_create)(void *object, int signal, int flags)
Definition: system.h:135
spa_system_methods::timerfd_settime
int(* timerfd_settime)(void *object, int fd, int flags, const struct itimerspec *new_value, struct itimerspec *old_value)
Definition: system.h:121
spa_system_methods::pollfd_mod
int(* pollfd_mod)(void *object, int pfd, int fd, uint32_t events, void *data)
Definition: system.h:114
spa_system_methods::ioctl
int(* ioctl)(void *object, int fd, unsigned long request,...)
Definition: system.h:102
spa_system
Definition: system.h:65
spa_system::iface
struct spa_interface iface
Definition: system.h:65