+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
main
| 1 | /* Simple Plugin API */ |
| 2 | /* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */ |
| 3 | /* SPDX-License-Identifier: MIT */ |
| 4 | |
| 5 | #ifndef SPA_SYSTEM_H |
| 6 | #define SPA_SYSTEM_H |
| 7 | |
| 8 | #include <time.h> |
| 9 | #include <errno.h> |
| 10 | #include <sys/types.h> |
| 11 | |
| 12 | #include <spa/utils/defs.h> |
| 13 | #include <spa/utils/hook.h> |
| 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
| 19 | struct itimerspec; |
| 20 | |
| 21 | #ifndef SPA_API_SYSTEM |
| 22 | #ifdef SPA_API_IMPL |
| 23 | #define SPA_API_SYSTEM SPA_API_IMPL |
| 24 | #else |
| 25 | #define SPA_API_SYSTEM static inline |
| 26 | #endif |
| 27 | #endif |
| 28 | |
| 29 | /** \defgroup spa_system System |
| 30 | * I/O, clock, polling, timer, and signal interfaces |
| 31 | */ |
| 32 | |
| 33 | /** |
| 34 | * \addtogroup spa_system |
| 35 | * \{ |
| 36 | */ |
| 37 | |
| 38 | /** |
| 39 | * a collection of core system functions |
| 40 | */ |
| 41 | #define SPA_TYPE_INTERFACE_System SPA_TYPE_INFO_INTERFACE_BASE "System" |
| 42 | #define SPA_TYPE_INTERFACE_DataSystem SPA_TYPE_INFO_INTERFACE_BASE "DataSystem" |
| 43 | |
| 44 | #define SPA_VERSION_SYSTEM 0 |
| 45 | struct spa_system { struct spa_interface iface; }; |
| 46 | |
| 47 | /* IO events */ |
| 48 | #define SPA_IO_IN (1 << 0) |
| 49 | #define SPA_IO_OUT (1 << 2) |
| 50 | #define SPA_IO_ERR (1 << 3) |
| 51 | #define SPA_IO_HUP (1 << 4) |
| 52 | |
| 53 | /* flags */ |
| 54 | #define SPA_FD_CLOEXEC (1<<0) |
| 55 | #define SPA_FD_NONBLOCK (1<<1) |
| 56 | #define SPA_FD_EVENT_SEMAPHORE (1<<2) |
| 57 | #define SPA_FD_TIMER_ABSTIME (1<<3) |
| 58 | #define SPA_FD_TIMER_CANCEL_ON_SET (1<<4) |
| 59 | |
| 60 | struct spa_poll_event { |
| 61 | uint32_t events; |
| 62 | void *data; |
| 63 | }; |
| 64 | |
| 65 | struct spa_system_methods { |
| 66 | #define SPA_VERSION_SYSTEM_METHODS 0 |
| 67 | uint32_t version; |
| 68 | |
| 69 | /* read/write/ioctl */ |
| 70 | ssize_t (*read) (void *object, int fd, void *buf, size_t count); |
| 71 | ssize_t (*write) (void *object, int fd, const void *buf, size_t count); |
| 72 | int (*ioctl) (void *object, int fd, unsigned long request, ...); |
| 73 | int (*close) (void *object, int fd); |
| 74 | |
| 75 | /* clock */ |
| 76 | int (*clock_gettime) (void *object, |
| 77 | int clockid, struct timespec *value); |
| 78 | int (*clock_getres) (void *object, |
| 79 | int clockid, struct timespec *res); |
| 80 | |
| 81 | /* poll */ |
| 82 | int (*pollfd_create) (void *object, int flags); |
| 83 | int (*pollfd_add) (void *object, int pfd, int fd, uint32_t events, void *data); |
| 84 | int (*pollfd_mod) (void *object, int pfd, int fd, uint32_t events, void *data); |
| 85 | int (*pollfd_del) (void *object, int pfd, int fd); |
| 86 | int (*pollfd_wait) (void *object, int pfd, |
| 87 | struct spa_poll_event *ev, int n_ev, int timeout); |
| 88 | |
| 89 | /* timers */ |
| 90 | int (*timerfd_create) (void *object, int clockid, int flags); |
| 91 | int (*timerfd_settime) (void *object, |
| 92 | int fd, int flags, |
| 93 | const struct itimerspec *new_value, |
| 94 | struct itimerspec *old_value); |
| 95 | int (*timerfd_gettime) (void *object, |
| 96 | int fd, struct itimerspec *curr_value); |
| 97 | int (*timerfd_read) (void *object, int fd, uint64_t *expirations); |
| 98 | |
| 99 | /* events */ |
| 100 | int (*eventfd_create) (void *object, int flags); |
| 101 | int (*eventfd_write) (void *object, int fd, uint64_t count); |
| 102 | int (*eventfd_read) (void *object, int fd, uint64_t *count); |
| 103 | |
| 104 | /* signals */ |
| 105 | int (*signalfd_create) (void *object, int signal, int flags); |
| 106 | int (*signalfd_read) (void *object, int fd, int *signal); |
| 107 | }; |
| 108 | |
| 109 | SPA_API_SYSTEM ssize_t spa_system_read(struct spa_system *object, int fd, void *buf, size_t count) |
| 110 | { |
| 111 | return spa_api_method_fast_r(ssize_t, -ENOTSUP, spa_system, &object->iface, read, 0, fd, buf, count); |
| 112 | } |
| 113 | SPA_API_SYSTEM ssize_t spa_system_write(struct spa_system *object, int fd, const void *buf, size_t count) |
| 114 | { |
| 115 | return spa_api_method_fast_r(ssize_t, -ENOTSUP, spa_system, &object->iface, write, 0, fd, buf, count); |
| 116 | } |
| 117 | #define spa_system_ioctl(object,fd,request,...) \ |
| 118 | spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, ioctl, 0, fd, request, ##__VA_ARGS__) |
| 119 | |
| 120 | SPA_API_SYSTEM int spa_system_close(struct spa_system *object, int fd) |
| 121 | { |
| 122 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, close, 0, fd); |
| 123 | } |
| 124 | SPA_API_SYSTEM int spa_system_clock_gettime(struct spa_system *object, |
| 125 | int clockid, struct timespec *value) |
| 126 | { |
| 127 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, clock_gettime, 0, clockid, value); |
| 128 | } |
| 129 | SPA_API_SYSTEM int spa_system_clock_getres(struct spa_system *object, |
| 130 | int clockid, struct timespec *res) |
| 131 | { |
| 132 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, clock_getres, 0, clockid, res); |
| 133 | } |
| 134 | |
| 135 | SPA_API_SYSTEM int spa_system_pollfd_create(struct spa_system *object, int flags) |
| 136 | { |
| 137 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_create, 0, flags); |
| 138 | } |
| 139 | SPA_API_SYSTEM int spa_system_pollfd_add(struct spa_system *object, int pfd, int fd, uint32_t events, void *data) |
| 140 | { |
| 141 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_add, 0, pfd, fd, events, data); |
| 142 | } |
| 143 | SPA_API_SYSTEM int spa_system_pollfd_mod(struct spa_system *object, int pfd, int fd, uint32_t events, void *data) |
| 144 | { |
| 145 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_mod, 0, pfd, fd, events, data); |
| 146 | } |
| 147 | SPA_API_SYSTEM int spa_system_pollfd_del(struct spa_system *object, int pfd, int fd) |
| 148 | { |
| 149 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_del, 0, pfd, fd); |
| 150 | } |
| 151 | SPA_API_SYSTEM int spa_system_pollfd_wait(struct spa_system *object, int pfd, |
| 152 | struct spa_poll_event *ev, int n_ev, int timeout) |
| 153 | { |
| 154 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_wait, 0, pfd, ev, n_ev, timeout); |
| 155 | } |
| 156 | |
| 157 | SPA_API_SYSTEM int spa_system_timerfd_create(struct spa_system *object, int clockid, int flags) |
| 158 | { |
| 159 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_create, 0, clockid, flags); |
| 160 | } |
| 161 | |
| 162 | SPA_API_SYSTEM int spa_system_timerfd_settime(struct spa_system *object, |
| 163 | int fd, int flags, |
| 164 | const struct itimerspec *new_value, |
| 165 | struct itimerspec *old_value) |
| 166 | { |
| 167 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_settime, 0, |
| 168 | fd, flags, new_value, old_value); |
| 169 | } |
| 170 | |
| 171 | SPA_API_SYSTEM int spa_system_timerfd_gettime(struct spa_system *object, |
| 172 | int fd, struct itimerspec *curr_value) |
| 173 | { |
| 174 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_gettime, 0, |
| 175 | fd, curr_value); |
| 176 | } |
| 177 | SPA_API_SYSTEM int spa_system_timerfd_read(struct spa_system *object, int fd, uint64_t *expirations) |
| 178 | { |
| 179 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, timerfd_read, 0, |
| 180 | fd, expirations); |
| 181 | } |
| 182 | |
| 183 | SPA_API_SYSTEM int spa_system_eventfd_create(struct spa_system *object, int flags) |
| 184 | { |
| 185 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_create, 0, flags); |
| 186 | } |
| 187 | SPA_API_SYSTEM int spa_system_eventfd_write(struct spa_system *object, int fd, uint64_t count) |
| 188 | { |
| 189 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_write, 0, |
| 190 | fd, count); |
| 191 | } |
| 192 | SPA_API_SYSTEM int spa_system_eventfd_read(struct spa_system *object, int fd, uint64_t *count) |
| 193 | { |
| 194 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, eventfd_read, 0, |
| 195 | fd, count); |
| 196 | } |
| 197 | |
| 198 | SPA_API_SYSTEM int spa_system_signalfd_create(struct spa_system *object, int signal, int flags) |
| 199 | { |
| 200 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, signalfd_create, 0, |
| 201 | signal, flags); |
| 202 | } |
| 203 | |
| 204 | SPA_API_SYSTEM int spa_system_signalfd_read(struct spa_system *object, int fd, int *signal) |
| 205 | { |
| 206 | return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, signalfd_read, 0, |
| 207 | fd, signal); |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * \} |
| 212 | */ |
| 213 | |
| 214 | #ifdef __cplusplus |
| 215 | } /* extern "C" */ |
| 216 | #endif |
| 217 | |
| 218 | #endif /* SPA_SYSTEM_H */ |