mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-03 07:15:32 -04:00
system: use attribute packed for the spa_poll_event
This makes it the same size as epoll_event and we don't need to copy the results over. It however technically causes an ABI break, in case someone was using the system interface directly.
This commit is contained in:
parent
54c517b2d9
commit
67dd3549a7
2 changed files with 8 additions and 13 deletions
|
|
@ -41,7 +41,7 @@ struct itimerspec;
|
||||||
#define SPA_TYPE_INTERFACE_System SPA_TYPE_INFO_INTERFACE_BASE "System"
|
#define SPA_TYPE_INTERFACE_System SPA_TYPE_INFO_INTERFACE_BASE "System"
|
||||||
#define SPA_TYPE_INTERFACE_DataSystem SPA_TYPE_INFO_INTERFACE_BASE "DataSystem"
|
#define SPA_TYPE_INTERFACE_DataSystem SPA_TYPE_INFO_INTERFACE_BASE "DataSystem"
|
||||||
|
|
||||||
#define SPA_VERSION_SYSTEM 0
|
#define SPA_VERSION_SYSTEM 1
|
||||||
struct spa_system { struct spa_interface iface; };
|
struct spa_system { struct spa_interface iface; };
|
||||||
|
|
||||||
/* IO events */
|
/* IO events */
|
||||||
|
|
@ -60,10 +60,10 @@ struct spa_system { struct spa_interface iface; };
|
||||||
struct spa_poll_event {
|
struct spa_poll_event {
|
||||||
uint32_t events;
|
uint32_t events;
|
||||||
void *data;
|
void *data;
|
||||||
};
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct spa_system_methods {
|
struct spa_system_methods {
|
||||||
#define SPA_VERSION_SYSTEM_METHODS 0
|
#define SPA_VERSION_SYSTEM_METHODS 1
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
||||||
/* read/write/ioctl */
|
/* read/write/ioctl */
|
||||||
|
|
@ -151,7 +151,7 @@ SPA_API_SYSTEM int spa_system_pollfd_del(struct spa_system *object, int pfd, int
|
||||||
SPA_API_SYSTEM int spa_system_pollfd_wait(struct spa_system *object, int pfd,
|
SPA_API_SYSTEM int spa_system_pollfd_wait(struct spa_system *object, int pfd,
|
||||||
struct spa_poll_event *ev, int n_ev, int timeout)
|
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);
|
return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_wait, 1, pfd, ev, n_ev, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPA_API_SYSTEM int spa_system_timerfd_create(struct spa_system *object, int clockid, int flags)
|
SPA_API_SYSTEM int spa_system_timerfd_create(struct spa_system *object, int clockid, int flags)
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ SPA_LOG_TOPIC_DEFINE_STATIC(log_topic, "spa.system");
|
||||||
# define TFD_TIMER_CANCEL_ON_SET (1 << 1)
|
# define TFD_TIMER_CANCEL_ON_SET (1 << 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SPA_STATIC_ASSERT(sizeof(struct spa_poll_event) == sizeof(struct epoll_event));
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
struct spa_handle handle;
|
struct spa_handle handle;
|
||||||
struct spa_system system;
|
struct spa_system system;
|
||||||
|
|
@ -132,16 +134,9 @@ static int impl_pollfd_del(void *object, int pfd, int fd)
|
||||||
static int impl_pollfd_wait(void *object, int pfd,
|
static int impl_pollfd_wait(void *object, int pfd,
|
||||||
struct spa_poll_event *ev, int n_ev, int timeout)
|
struct spa_poll_event *ev, int n_ev, int timeout)
|
||||||
{
|
{
|
||||||
struct epoll_event ep[n_ev];
|
int nfds;
|
||||||
int i, nfds;
|
if (SPA_UNLIKELY((nfds = epoll_wait(pfd, (struct epoll_event*)ev, n_ev, timeout)) < 0))
|
||||||
|
|
||||||
if (SPA_UNLIKELY((nfds = epoll_wait(pfd, ep, n_ev, timeout)) < 0))
|
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
for (i = 0; i < nfds; i++) {
|
|
||||||
ev[i].events = ep[i].events;
|
|
||||||
ev[i].data = ep[i].data.ptr;
|
|
||||||
}
|
|
||||||
return nfds;
|
return nfds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue