mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
poll: remove threads from alsa-sink
Remove the thread from alsa sink and use the pollfd event. Make it possible to pass multiple fds in one pollfd event Add 3 callbacks to the pollfd event and add support for timeouts
This commit is contained in:
parent
ac59fa9371
commit
5fa334a89b
10 changed files with 313 additions and 202 deletions
|
|
@ -343,7 +343,6 @@ mmap_read (SpaV4l2Source *this)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
fprintf (stderr, "captured buffer %d\n", buf.index);
|
||||
|
||||
b = &state->buffers[buf.index];
|
||||
b->next = state->ready;
|
||||
|
|
@ -353,10 +352,10 @@ mmap_read (SpaV4l2Source *this)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
v4l2_on_fd_events (void *user_data)
|
||||
static int
|
||||
v4l2_on_fd_events (SpaPollNotifyData *data)
|
||||
{
|
||||
SpaV4l2Source *this = user_data;
|
||||
SpaV4l2Source *this = data->user_data;
|
||||
SpaEvent event;
|
||||
|
||||
mmap_read (this);
|
||||
|
|
@ -368,6 +367,8 @@ v4l2_on_fd_events (void *user_data)
|
|||
event.size = 0;
|
||||
event.data = NULL;
|
||||
this->event_cb (&this->handle, &event, this->user_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -386,8 +387,6 @@ v4l2_buffer_free (void *data)
|
|||
b->buffer.refcount = 1;
|
||||
b->outstanding = false;
|
||||
|
||||
fprintf (stderr, "queue buffer %d\n", buf.index);
|
||||
|
||||
if (xioctl (state->fd, VIDIOC_QBUF, &buf) < 0) {
|
||||
perror ("VIDIOC_QBUF");
|
||||
}
|
||||
|
|
@ -523,10 +522,15 @@ spa_v4l2_start (SpaV4l2Source *this)
|
|||
event.data = &state->poll;
|
||||
event.size = sizeof (state->poll);
|
||||
|
||||
state->poll.fd = state->fd;
|
||||
state->poll.events = POLLIN | POLLPRI | POLLERR;
|
||||
state->poll.revents = 0;
|
||||
state->poll.callback = v4l2_on_fd_events;
|
||||
state->fds[0].fd = state->fd;
|
||||
state->fds[0].events = POLLIN | POLLPRI | POLLERR;
|
||||
state->fds[0].revents = 0;
|
||||
|
||||
state->poll.fds = state->fds;
|
||||
state->poll.n_fds = 1;
|
||||
state->poll.idle_cb = NULL;
|
||||
state->poll.before_cb = NULL;
|
||||
state->poll.after_cb = v4l2_on_fd_events;
|
||||
state->poll.user_data = this;
|
||||
this->event_cb (&this->handle, &event, this->user_data);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue