More generic support for poll descriptors

This commit is contained in:
Abramo Bagnara 2001-02-12 23:51:49 +00:00
parent a86efa083c
commit 460660d4b4
25 changed files with 162 additions and 68 deletions

View file

@ -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;

View file

@ -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)
{

View file

@ -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)

View file

@ -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)

View file

@ -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);

View file

@ -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);