mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -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
				
			
		| 
						 | 
				
			
			@ -69,7 +69,8 @@ typedef struct {
 | 
			
		|||
  V4l2Buffer buffers[MAX_BUFFERS];
 | 
			
		||||
  V4l2Buffer *ready;
 | 
			
		||||
  uint32_t ready_count;
 | 
			
		||||
  SpaEventPoll poll;
 | 
			
		||||
  SpaPollFd fds[1];
 | 
			
		||||
  SpaPollItem poll;
 | 
			
		||||
} SpaV4l2State;
 | 
			
		||||
 | 
			
		||||
struct _SpaV4l2Source {
 | 
			
		||||
| 
						 | 
				
			
			@ -91,14 +92,6 @@ struct _SpaV4l2Source {
 | 
			
		|||
 | 
			
		||||
#include "v4l2-utils.c"
 | 
			
		||||
 | 
			
		||||
static const uint32_t min_uint32 = 1;
 | 
			
		||||
static const uint32_t max_uint32 = UINT32_MAX;
 | 
			
		||||
 | 
			
		||||
static const SpaPropRangeInfo uint32_range[] = {
 | 
			
		||||
  { "min", "Minimum value", 4, &min_uint32 },
 | 
			
		||||
  { "max", "Maximum value", 4, &max_uint32 },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum {
 | 
			
		||||
  PROP_ID_DEVICE,
 | 
			
		||||
  PROP_ID_DEVICE_NAME,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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