mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
system: use the same bits as POLL and EPOLL
Use the same bits for the io mask as POLL and EPOLL so that we can avoid conversions.
This commit is contained in:
parent
49a5e97d69
commit
59bf522ce1
4 changed files with 10 additions and 82 deletions
|
|
@ -120,38 +120,6 @@ static int impl_clock_getres(void *object,
|
|||
}
|
||||
|
||||
/* poll */
|
||||
static inline uint32_t spa_io_to_poll(uint32_t mask)
|
||||
{
|
||||
uint32_t events = 0;
|
||||
|
||||
if (mask & SPA_IO_IN)
|
||||
events |= POLLIN;
|
||||
if (mask & SPA_IO_OUT)
|
||||
events |= POLLOUT;
|
||||
if (mask & SPA_IO_ERR)
|
||||
events |= POLLERR;
|
||||
if (mask & SPA_IO_HUP)
|
||||
events |= POLLHUP;
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
static inline uint32_t spa_poll_to_io(uint32_t events)
|
||||
{
|
||||
uint32_t mask = 0;
|
||||
|
||||
if (events & POLLIN)
|
||||
mask |= SPA_IO_IN;
|
||||
if (events & POLLOUT)
|
||||
mask |= SPA_IO_OUT;
|
||||
if (events & POLLHUP)
|
||||
mask |= SPA_IO_HUP;
|
||||
if (events & POLLERR)
|
||||
mask |= SPA_IO_ERR;
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
static int impl_pollfd_create(void *object, int flags)
|
||||
{
|
||||
int retval;
|
||||
|
|
@ -181,7 +149,7 @@ static int impl_pollfd_add(void *object, int pfd, int fd, uint32_t events, void
|
|||
e = &impl->entries[impl->n_entries++];
|
||||
e->pfd = pfd;
|
||||
e->fd = fd;
|
||||
e->events = spa_io_to_poll(events);
|
||||
e->events = events;
|
||||
e->data = data;
|
||||
return evl_add_pollfd(pfd, fd, e->events);
|
||||
}
|
||||
|
|
@ -195,7 +163,7 @@ static int impl_pollfd_mod(void *object, int pfd, int fd, uint32_t events, void
|
|||
if (e == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
e->events = spa_io_to_poll(events);
|
||||
e->events = events;
|
||||
e->data = data;
|
||||
return evl_mod_pollfd(pfd, fd, e->events);
|
||||
}
|
||||
|
|
@ -247,7 +215,7 @@ static int impl_pollfd_wait(void *object, int pfd,
|
|||
if (e == NULL)
|
||||
continue;
|
||||
|
||||
ev[j].events = spa_poll_to_io(pollset[i].events);
|
||||
ev[j].events = pollset[i].events;
|
||||
ev[j].data = e->data;
|
||||
j++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,38 +96,6 @@ static int impl_clock_getres(void *object,
|
|||
}
|
||||
|
||||
/* poll */
|
||||
static inline uint32_t spa_io_to_epoll(uint32_t mask)
|
||||
{
|
||||
uint32_t events = 0;
|
||||
|
||||
if (mask & SPA_IO_IN)
|
||||
events |= EPOLLIN;
|
||||
if (mask & SPA_IO_OUT)
|
||||
events |= EPOLLOUT;
|
||||
if (mask & SPA_IO_ERR)
|
||||
events |= EPOLLERR;
|
||||
if (mask & SPA_IO_HUP)
|
||||
events |= EPOLLHUP;
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
static inline uint32_t spa_epoll_to_io(uint32_t events)
|
||||
{
|
||||
uint32_t mask = 0;
|
||||
|
||||
if (events & EPOLLIN)
|
||||
mask |= SPA_IO_IN;
|
||||
if (events & EPOLLOUT)
|
||||
mask |= SPA_IO_OUT;
|
||||
if (events & EPOLLHUP)
|
||||
mask |= SPA_IO_HUP;
|
||||
if (events & EPOLLERR)
|
||||
mask |= SPA_IO_ERR;
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
static int impl_pollfd_create(void *object, int flags)
|
||||
{
|
||||
int fl = 0, res;
|
||||
|
|
@ -143,7 +111,7 @@ static int impl_pollfd_add(void *object, int pfd, int fd, uint32_t events, void
|
|||
int res;
|
||||
|
||||
spa_zero(ep);
|
||||
ep.events = spa_io_to_epoll(events);
|
||||
ep.events = events;
|
||||
ep.data.ptr = data;
|
||||
|
||||
res = epoll_ctl(pfd, EPOLL_CTL_ADD, fd, &ep);
|
||||
|
|
@ -156,7 +124,7 @@ static int impl_pollfd_mod(void *object, int pfd, int fd, uint32_t events, void
|
|||
int res;
|
||||
|
||||
spa_zero(ep);
|
||||
ep.events = spa_io_to_epoll(events);
|
||||
ep.events = events;
|
||||
ep.data.ptr = data;
|
||||
|
||||
res = epoll_ctl(pfd, EPOLL_CTL_MOD, fd, &ep);
|
||||
|
|
@ -175,11 +143,11 @@ static int impl_pollfd_wait(void *object, int pfd,
|
|||
struct epoll_event ep[n_ev];
|
||||
int i, nfds;
|
||||
|
||||
if (SPA_UNLIKELY((nfds = epoll_wait(pfd, ep, SPA_N_ELEMENTS(ep), timeout)) < 0))
|
||||
if (SPA_UNLIKELY((nfds = epoll_wait(pfd, ep, n_ev, timeout)) < 0))
|
||||
return -errno;
|
||||
|
||||
for (i = 0; i < nfds; i++) {
|
||||
ev[i].events = spa_epoll_to_io(ep[i].events);
|
||||
ev[i].events = ep[i].events;
|
||||
ev[i].data = ep[i].data.ptr;
|
||||
}
|
||||
return nfds;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue