mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	More generic support for poll descriptors
This commit is contained in:
		
							parent
							
								
									a86efa083c
								
							
						
					
					
						commit
						460660d4b4
					
				
					 25 changed files with 162 additions and 68 deletions
				
			
		| 
						 | 
				
			
			@ -68,12 +68,22 @@ int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid)
 | 
			
		|||
	return ctl->ops->async(ctl, sig, pid);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_ctl_poll_descriptor(snd_ctl_t *ctl)
 | 
			
		||||
int _snd_ctl_poll_descriptor(snd_ctl_t *ctl)
 | 
			
		||||
{
 | 
			
		||||
	assert(ctl);
 | 
			
		||||
	return ctl->ops->poll_descriptor(ctl);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_ctl_poll_descriptors(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int space)
 | 
			
		||||
{
 | 
			
		||||
	assert(ctl);
 | 
			
		||||
	if (space >= 1) {
 | 
			
		||||
		pfds->fd = ctl->ops->poll_descriptor(ctl);
 | 
			
		||||
		pfds->events = POLLIN;
 | 
			
		||||
	}
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info)
 | 
			
		||||
{
 | 
			
		||||
	assert(ctl && info);
 | 
			
		||||
| 
						 | 
				
			
			@ -163,8 +173,8 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
 | 
			
		|||
{
 | 
			
		||||
	struct pollfd pfd;
 | 
			
		||||
	int err;
 | 
			
		||||
	pfd.fd = snd_ctl_poll_descriptor(ctl);
 | 
			
		||||
	pfd.events = POLLIN;
 | 
			
		||||
	err = snd_ctl_poll_descriptors(ctl, &pfd, 1);
 | 
			
		||||
	assert(err == 1);
 | 
			
		||||
	err = poll(&pfd, 1, timeout);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -74,5 +74,6 @@ struct _snd_hctl {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int _snd_ctl_poll_descriptor(snd_ctl_t *ctl);
 | 
			
		||||
int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card);
 | 
			
		||||
int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket, const char *sname);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,7 +34,6 @@
 | 
			
		|||
#include <netinet/in.h>
 | 
			
		||||
#include <netdb.h>
 | 
			
		||||
#include "aserver.h"
 | 
			
		||||
#include "control_local.h"
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
	int socket;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -81,10 +81,10 @@ int snd_hctl_async(snd_hctl_t *hctl, int sig, pid_t pid)
 | 
			
		|||
	return snd_ctl_async(hctl->ctl, sig, pid);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_hctl_poll_descriptor(snd_hctl_t *hctl)
 | 
			
		||||
int snd_hctl_poll_descriptors(snd_hctl_t *hctl, struct pollfd *pfds, unsigned int space)
 | 
			
		||||
{
 | 
			
		||||
	assert(hctl);
 | 
			
		||||
	return snd_ctl_poll_descriptor(hctl->ctl);
 | 
			
		||||
	return snd_ctl_poll_descriptors(hctl->ctl, pfds, space);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int _snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id, int *dir)
 | 
			
		||||
| 
						 | 
				
			
			@ -441,6 +441,18 @@ unsigned int snd_hctl_get_count(snd_hctl_t *hctl)
 | 
			
		|||
	return hctl->count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_hctl_wait(snd_hctl_t *hctl, int timeout)
 | 
			
		||||
{
 | 
			
		||||
	struct pollfd pfd;
 | 
			
		||||
	int err;
 | 
			
		||||
	err = snd_hctl_poll_descriptors(hctl, &pfd, 1);
 | 
			
		||||
	assert(err == 1);
 | 
			
		||||
	err = poll(&pfd, 1, timeout);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
 | 
			
		||||
{
 | 
			
		||||
	snd_hctl_elem_t *elem;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,6 +42,7 @@ int snd_hwdep_open(snd_hwdep_t **handle, int card, int device, int mode)
 | 
			
		|||
	int fd, ver;
 | 
			
		||||
	char filename[32];
 | 
			
		||||
	snd_hwdep_t *hwdep;
 | 
			
		||||
	assert(handle);
 | 
			
		||||
 | 
			
		||||
	*handle = NULL;
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			@ -77,27 +78,26 @@ int snd_hwdep_open(snd_hwdep_t **handle, int card, int device, int mode)
 | 
			
		|||
int snd_hwdep_close(snd_hwdep_t *hwdep)
 | 
			
		||||
{
 | 
			
		||||
	int res;
 | 
			
		||||
 | 
			
		||||
	if (!hwdep)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	assert(hwdep);
 | 
			
		||||
	res = close(hwdep->fd) < 0 ? -errno : 0;
 | 
			
		||||
	free(hwdep);
 | 
			
		||||
	return res;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_hwdep_poll_descriptor(snd_hwdep_t *hwdep)
 | 
			
		||||
int snd_hwdep_poll_descriptors(snd_hwdep_t *hwdep, struct pollfd *pfds, unsigned int space)
 | 
			
		||||
{
 | 
			
		||||
	if (!hwdep)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	return hwdep->fd;
 | 
			
		||||
	assert(hwdep);
 | 
			
		||||
	if (space >= 1) {
 | 
			
		||||
		pfds->fd = hwdep->fd;
 | 
			
		||||
		pfds->events = POLLOUT | POLLIN;
 | 
			
		||||
	}
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_hwdep_block_mode(snd_hwdep_t *hwdep, int enable)
 | 
			
		||||
{
 | 
			
		||||
	long flags;
 | 
			
		||||
 | 
			
		||||
	if (!hwdep)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	assert(hwdep);
 | 
			
		||||
	if ((flags = fcntl(hwdep->fd, F_GETFL)) < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
	if (enable)
 | 
			
		||||
| 
						 | 
				
			
			@ -111,8 +111,7 @@ int snd_hwdep_block_mode(snd_hwdep_t *hwdep, int enable)
 | 
			
		|||
 | 
			
		||||
int snd_hwdep_info(snd_hwdep_t *hwdep, snd_hwdep_info_t *info)
 | 
			
		||||
{
 | 
			
		||||
	if (!hwdep || !info)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	assert(hwdep && info);
 | 
			
		||||
	if (ioctl(hwdep->fd, SNDRV_HWDEP_IOCTL_INFO, info) < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -120,8 +119,7 @@ int snd_hwdep_info(snd_hwdep_t *hwdep, snd_hwdep_info_t *info)
 | 
			
		|||
 | 
			
		||||
int snd_hwdep_ioctl(snd_hwdep_t *hwdep, int request, void * arg)
 | 
			
		||||
{
 | 
			
		||||
	if (!hwdep)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	assert(hwdep);
 | 
			
		||||
	if (ioctl(hwdep->fd, request, arg) < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -130,9 +128,7 @@ int snd_hwdep_ioctl(snd_hwdep_t *hwdep, int request, void * arg)
 | 
			
		|||
ssize_t snd_hwdep_write(snd_hwdep_t *hwdep, const void *buffer, size_t size)
 | 
			
		||||
{
 | 
			
		||||
	ssize_t result;
 | 
			
		||||
 | 
			
		||||
	if (!hwdep || (!buffer && size > 0))
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	assert(hwdep && (buffer || size == 0));
 | 
			
		||||
	result = write(hwdep->fd, buffer, size);
 | 
			
		||||
	if (result < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
| 
						 | 
				
			
			@ -142,9 +138,7 @@ ssize_t snd_hwdep_write(snd_hwdep_t *hwdep, const void *buffer, size_t size)
 | 
			
		|||
ssize_t snd_hwdep_read(snd_hwdep_t *hwdep, void *buffer, size_t size)
 | 
			
		||||
{
 | 
			
		||||
	ssize_t result;
 | 
			
		||||
 | 
			
		||||
	if (!hwdep || (!buffer && size > 0))
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
	assert(hwdep && (buffer || size == 0));
 | 
			
		||||
	result = read(hwdep->fd, buffer, size);
 | 
			
		||||
	if (result < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -447,19 +447,48 @@ int snd_mixer_set_compare(snd_mixer_t *mixer, snd_mixer_compare_t msort)
 | 
			
		|||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_mixer_poll_descriptor(snd_mixer_t *mixer, const char *name)
 | 
			
		||||
int snd_mixer_poll_descriptors(snd_mixer_t *mixer, struct pollfd *pfds, unsigned int space)
 | 
			
		||||
{
 | 
			
		||||
	struct list_head *pos, *next;
 | 
			
		||||
	assert(mixer && name);
 | 
			
		||||
	unsigned int count = 0;
 | 
			
		||||
	assert(mixer);
 | 
			
		||||
	list_for_each(pos, next, &mixer->slaves) {
 | 
			
		||||
		snd_mixer_slave_t *s;
 | 
			
		||||
		const char *n;
 | 
			
		||||
		int n;
 | 
			
		||||
		s = list_entry(pos, snd_mixer_slave_t, list);
 | 
			
		||||
		n = snd_hctl_name(s->hctl);
 | 
			
		||||
		if (n && strcmp(name, n) == 0)
 | 
			
		||||
			return snd_hctl_poll_descriptor(s->hctl);
 | 
			
		||||
		n = snd_hctl_poll_descriptors(s->hctl, pfds, space);
 | 
			
		||||
		if (n < 0)
 | 
			
		||||
			return n;
 | 
			
		||||
		count += n;
 | 
			
		||||
		if (space > (unsigned int) n) {
 | 
			
		||||
			space -= n;
 | 
			
		||||
			pfds += n;
 | 
			
		||||
		} else
 | 
			
		||||
			space = 0;
 | 
			
		||||
	}
 | 
			
		||||
	return -ENOENT;
 | 
			
		||||
	return count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_mixer_wait(snd_mixer_t *mixer, int timeout)
 | 
			
		||||
{
 | 
			
		||||
	struct pollfd spfds[16];
 | 
			
		||||
	struct pollfd *pfds = spfds;
 | 
			
		||||
	int err;
 | 
			
		||||
	int count;
 | 
			
		||||
	count = snd_mixer_poll_descriptors(mixer, pfds, sizeof(spfds) / sizeof(spfds[0]));
 | 
			
		||||
	if (count < 0)
 | 
			
		||||
		return count;
 | 
			
		||||
	if ((unsigned int) count > sizeof(spfds) / sizeof(spfds[0])) {
 | 
			
		||||
		pfds = malloc(count * sizeof(*pfds));
 | 
			
		||||
		if (!pfds)
 | 
			
		||||
			return -ENOMEM;
 | 
			
		||||
		err = snd_mixer_poll_descriptors(mixer, pfds, count);
 | 
			
		||||
		assert(err == count);
 | 
			
		||||
	}
 | 
			
		||||
	err = poll(pfds, count, timeout);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
snd_mixer_elem_t *snd_mixer_first_elem(snd_mixer_t *mixer)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -205,12 +205,12 @@ snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t s
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
/* FIXME */
 | 
			
		||||
#define snd_pcm_link_descriptor snd_pcm_poll_descriptor
 | 
			
		||||
#define _snd_pcm_link_descriptor _snd_pcm_poll_descriptor
 | 
			
		||||
 | 
			
		||||
int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2)
 | 
			
		||||
{
 | 
			
		||||
	int fd1 = snd_pcm_link_descriptor(pcm1);
 | 
			
		||||
	int fd2 = snd_pcm_link_descriptor(pcm2);
 | 
			
		||||
	int fd1 = _snd_pcm_link_descriptor(pcm1);
 | 
			
		||||
	int fd2 = _snd_pcm_link_descriptor(pcm2);
 | 
			
		||||
	if (fd1 < 0 || fd2 < 0)
 | 
			
		||||
		return -ENOSYS;
 | 
			
		||||
	if (ioctl(fd1, SNDRV_PCM_IOCTL_LINK, fd2) < 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -223,7 +223,7 @@ int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2)
 | 
			
		|||
int snd_pcm_unlink(snd_pcm_t *pcm)
 | 
			
		||||
{
 | 
			
		||||
	int fd;
 | 
			
		||||
	fd = snd_pcm_link_descriptor(pcm);
 | 
			
		||||
	fd = _snd_pcm_link_descriptor(pcm);
 | 
			
		||||
	if (ioctl(fd, SNDRV_PCM_IOCTL_UNLINK) < 0) {
 | 
			
		||||
		SYSERR("SNDRV_PCM_IOCTL_UNLINK failed");
 | 
			
		||||
		return -errno;
 | 
			
		||||
| 
						 | 
				
			
			@ -231,12 +231,22 @@ int snd_pcm_unlink(snd_pcm_t *pcm)
 | 
			
		|||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_pcm_poll_descriptor(snd_pcm_t *pcm)
 | 
			
		||||
int _snd_pcm_poll_descriptor(snd_pcm_t *pcm)
 | 
			
		||||
{
 | 
			
		||||
	assert(pcm);
 | 
			
		||||
	return pcm->poll_fd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space)
 | 
			
		||||
{
 | 
			
		||||
	assert(pcm);
 | 
			
		||||
	if (space >= 1) {
 | 
			
		||||
		pfds->fd = pcm->poll_fd;
 | 
			
		||||
		pfds->events = pcm->stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
 | 
			
		||||
	}
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define STATE(v) [SND_PCM_STATE_##v] = #v
 | 
			
		||||
#define STREAM(v) [SND_PCM_STREAM_##v] = #v
 | 
			
		||||
#define READY(v) [SND_PCM_READY_##v] = #v
 | 
			
		||||
| 
						 | 
				
			
			@ -688,8 +698,8 @@ int snd_pcm_wait(snd_pcm_t *pcm, int timeout)
 | 
			
		|||
{
 | 
			
		||||
	struct pollfd pfd;
 | 
			
		||||
	int err;
 | 
			
		||||
	pfd.fd = snd_pcm_poll_descriptor(pcm);
 | 
			
		||||
	pfd.events = pcm->stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
 | 
			
		||||
	err = snd_pcm_poll_descriptors(pcm, &pfd, 1);
 | 
			
		||||
	assert(err == 1);
 | 
			
		||||
	err = poll(&pfd, 1, timeout);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return -errno;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -202,6 +202,7 @@ snd_pcm_sframes_t snd_pcm_read_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t size);
 | 
			
		|||
snd_pcm_sframes_t snd_pcm_write_mmap(snd_pcm_t *pcm, snd_pcm_uframes_t size);
 | 
			
		||||
int snd_pcm_channel_info(snd_pcm_t *pcm, snd_pcm_channel_info_t *info);
 | 
			
		||||
int snd_pcm_channel_info_shm(snd_pcm_t *pcm, snd_pcm_channel_info_t *info, int shmid);
 | 
			
		||||
int _snd_pcm_poll_descriptor(snd_pcm_t *pcm);
 | 
			
		||||
 | 
			
		||||
static inline snd_pcm_uframes_t snd_pcm_mmap_playback_avail(snd_pcm_t *pcm)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -447,7 +447,7 @@ int snd_pcm_multi_poll_descriptor(snd_pcm_t *pcm)
 | 
			
		|||
{
 | 
			
		||||
	snd_pcm_multi_t *multi = pcm->private_data;
 | 
			
		||||
	snd_pcm_t *slave = multi->slaves[0].pcm;
 | 
			
		||||
	return snd_pcm_poll_descriptor(slave);
 | 
			
		||||
	return _snd_pcm_poll_descriptor(slave);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void snd_pcm_multi_dump(snd_pcm_t *pcm, snd_output_t *out)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -337,7 +337,7 @@ int snd_pcm_plugin_munmap(snd_pcm_t *pcm)
 | 
			
		|||
int snd_pcm_plugin_poll_descriptor(snd_pcm_t *pcm)
 | 
			
		||||
{
 | 
			
		||||
	snd_pcm_plugin_t *plugin = pcm->private_data;
 | 
			
		||||
	return snd_pcm_poll_descriptor(plugin->slave);
 | 
			
		||||
	return _snd_pcm_poll_descriptor(plugin->slave);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_pcm_plugin_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,7 +61,7 @@ int snd_pcm_plugin_mmap(snd_pcm_t *pcm);
 | 
			
		|||
int snd_pcm_plugin_munmap_status(snd_pcm_t *pcm);
 | 
			
		||||
int snd_pcm_plugin_munmap_control(snd_pcm_t *pcm);
 | 
			
		||||
int snd_pcm_plugin_munmap(snd_pcm_t *pcm);
 | 
			
		||||
int snd_pcm_plugin_poll_descriptor(snd_pcm_t *pcm);
 | 
			
		||||
int snd_pcm_plugin_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space);
 | 
			
		||||
int snd_pcm_plugin_hw_params_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
 | 
			
		||||
int snd_pcm_plugin_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -346,8 +346,8 @@ void *snd_pcm_share_slave_thread(void *data)
 | 
			
		|||
	int err;
 | 
			
		||||
	pfd[0].fd = slave->poll[0];
 | 
			
		||||
	pfd[0].events = POLLIN;
 | 
			
		||||
	pfd[1].fd = snd_pcm_poll_descriptor(spcm);
 | 
			
		||||
	pfd[1].events = POLLIN | POLLOUT;
 | 
			
		||||
	err = snd_pcm_poll_descriptors(spcm, &pfd[1], 1);
 | 
			
		||||
	assert(err == 1);
 | 
			
		||||
	Pthread_mutex_lock(&slave->mutex);
 | 
			
		||||
	err = pipe(slave->poll);
 | 
			
		||||
	assert(err >= 0);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,12 +52,23 @@ int snd_rawmidi_close(snd_rawmidi_t *rmidi)
 | 
			
		|||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_rawmidi_poll_descriptor(snd_rawmidi_t *rmidi)
 | 
			
		||||
int _snd_rawmidi_poll_descriptor(snd_rawmidi_t *rmidi)
 | 
			
		||||
{
 | 
			
		||||
	assert(rmidi);
 | 
			
		||||
	return rmidi->poll_fd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_rawmidi_poll_descriptors(snd_rawmidi_t *rmidi, struct pollfd *pfds, unsigned int space)
 | 
			
		||||
{
 | 
			
		||||
	assert(rmidi);
 | 
			
		||||
	if (space >= 1) {
 | 
			
		||||
		pfds->fd = rmidi->poll_fd;
 | 
			
		||||
		pfds->events = rmidi->stream == SND_RAWMIDI_STREAM_OUTPUT ? POLLOUT : POLLIN;
 | 
			
		||||
	}
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock)
 | 
			
		||||
{
 | 
			
		||||
	int err;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -146,12 +146,26 @@ int snd_seq_close(snd_seq_t *seq)
 | 
			
		|||
/*
 | 
			
		||||
 * returns the file descriptor of the client
 | 
			
		||||
 */
 | 
			
		||||
int snd_seq_poll_descriptor(snd_seq_t *seq)
 | 
			
		||||
int _snd_seq_poll_descriptor(snd_seq_t *seq)
 | 
			
		||||
{
 | 
			
		||||
	assert(seq);
 | 
			
		||||
	return seq->poll_fd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_seq_poll_descriptors(snd_seq_t *seq, struct pollfd *pfds, unsigned int space)
 | 
			
		||||
{
 | 
			
		||||
	assert(seq);
 | 
			
		||||
	if (space >= 1) {
 | 
			
		||||
		pfds->fd = seq->poll_fd;
 | 
			
		||||
		pfds->events = 0;
 | 
			
		||||
		if (seq->streams & SND_SEQ_OPEN_INPUT)
 | 
			
		||||
			pfds->events |= POLLIN;
 | 
			
		||||
		if (seq->streams & SND_SEQ_OPEN_OUTPUT)
 | 
			
		||||
			pfds->events |= POLLOUT;
 | 
			
		||||
	}
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * set blocking behavior
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -74,7 +74,7 @@ int snd_timer_close(snd_timer_t *handle)
 | 
			
		|||
	return res;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_timer_poll_descriptor(snd_timer_t *handle)
 | 
			
		||||
int _snd_timer_poll_descriptor(snd_timer_t *handle)
 | 
			
		||||
{
 | 
			
		||||
	snd_timer_t *tmr;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -84,6 +84,16 @@ int snd_timer_poll_descriptor(snd_timer_t *handle)
 | 
			
		|||
	return tmr->fd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_timer_poll_descriptors(snd_timer_t *timer, struct pollfd *pfds, unsigned int space)
 | 
			
		||||
{
 | 
			
		||||
	assert(timer);
 | 
			
		||||
	if (space >= 1) {
 | 
			
		||||
		pfds->fd = timer->fd;
 | 
			
		||||
		pfds->events = POLLIN;
 | 
			
		||||
	}
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_timer_next_device(snd_timer_t *handle, snd_timer_id_t * tid)
 | 
			
		||||
{
 | 
			
		||||
	snd_timer_t *tmr;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue