mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04: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
|
|
@ -276,7 +276,7 @@ int pcm_shm_open(client_t *client, int *cookie)
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
client->device.pcm.handle = pcm;
|
client->device.pcm.handle = pcm;
|
||||||
client->device.pcm.fd = snd_pcm_poll_descriptor(pcm);
|
client->device.pcm.fd = _snd_pcm_poll_descriptor(pcm);
|
||||||
|
|
||||||
shmid = shmget(IPC_PRIVATE, PCM_SHM_SIZE, 0666);
|
shmid = shmget(IPC_PRIVATE, PCM_SHM_SIZE, 0666);
|
||||||
if (shmid < 0) {
|
if (shmid < 0) {
|
||||||
|
|
@ -459,7 +459,7 @@ int pcm_shm_cmd(client_t *client)
|
||||||
break;
|
break;
|
||||||
case SND_PCM_IOCTL_POLL_DESCRIPTOR:
|
case SND_PCM_IOCTL_POLL_DESCRIPTOR:
|
||||||
ctrl->result = 0;
|
ctrl->result = 0;
|
||||||
return shm_ack_fd(client, snd_pcm_poll_descriptor(pcm));
|
return shm_ack_fd(client, _snd_pcm_poll_descriptor(pcm));
|
||||||
case SND_PCM_IOCTL_CLOSE:
|
case SND_PCM_IOCTL_CLOSE:
|
||||||
client->ops->close(client);
|
client->ops->close(client);
|
||||||
break;
|
break;
|
||||||
|
|
@ -503,7 +503,7 @@ int ctl_shm_open(client_t *client, int *cookie)
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
client->device.control.handle = ctl;
|
client->device.control.handle = ctl;
|
||||||
client->device.control.fd = snd_ctl_poll_descriptor(ctl);
|
client->device.control.fd = _snd_ctl_poll_descriptor(ctl);
|
||||||
|
|
||||||
shmid = shmget(IPC_PRIVATE, CTL_SHM_SIZE, 0666);
|
shmid = shmget(IPC_PRIVATE, CTL_SHM_SIZE, 0666);
|
||||||
if (shmid < 0) {
|
if (shmid < 0) {
|
||||||
|
|
@ -627,7 +627,7 @@ int ctl_shm_cmd(client_t *client)
|
||||||
break;
|
break;
|
||||||
case SND_CTL_IOCTL_POLL_DESCRIPTOR:
|
case SND_CTL_IOCTL_POLL_DESCRIPTOR:
|
||||||
ctrl->result = 0;
|
ctrl->result = 0;
|
||||||
return shm_ack_fd(client, snd_ctl_poll_descriptor(ctl));
|
return shm_ack_fd(client, _snd_ctl_poll_descriptor(ctl));
|
||||||
default:
|
default:
|
||||||
ERROR("Bogus cmd: %x", ctrl->cmd);
|
ERROR("Bogus cmd: %x", ctrl->cmd);
|
||||||
ctrl->result = -ENOSYS;
|
ctrl->result = -ENOSYS;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../src/pcm/pcm_local.h"
|
#include "../src/pcm/pcm_local.h"
|
||||||
|
#include "../src/control/control_local.h"
|
||||||
|
|
||||||
typedef enum _snd_dev_type {
|
typedef enum _snd_dev_type {
|
||||||
SND_DEV_TYPE_PCM,
|
SND_DEV_TYPE_PCM,
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ int snd_ctl_open(snd_ctl_t **ctl, const char *name);
|
||||||
int snd_ctl_close(snd_ctl_t *ctl);
|
int snd_ctl_close(snd_ctl_t *ctl);
|
||||||
int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock);
|
int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock);
|
||||||
int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid);
|
int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid);
|
||||||
int snd_ctl_poll_descriptor(snd_ctl_t *ctl);
|
int snd_ctl_poll_descriptors(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int space);
|
||||||
int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info);
|
int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info);
|
||||||
int snd_ctl_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t * list);
|
int snd_ctl_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t * list);
|
||||||
int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info);
|
int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info);
|
||||||
|
|
@ -215,7 +215,7 @@ int snd_hctl_open(snd_hctl_t **hctl, const char *name);
|
||||||
int snd_hctl_close(snd_hctl_t *hctl);
|
int snd_hctl_close(snd_hctl_t *hctl);
|
||||||
int snd_hctl_nonblock(snd_hctl_t *hctl, int nonblock);
|
int snd_hctl_nonblock(snd_hctl_t *hctl, int nonblock);
|
||||||
int snd_hctl_async(snd_hctl_t *hctl, int sig, pid_t pid);
|
int snd_hctl_async(snd_hctl_t *hctl, int sig, pid_t 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);
|
||||||
unsigned int snd_hctl_get_count(snd_hctl_t *hctl);
|
unsigned int snd_hctl_get_count(snd_hctl_t *hctl);
|
||||||
int snd_hctl_set_compare(snd_hctl_t *hctl, snd_hctl_compare_t hsort);
|
int snd_hctl_set_compare(snd_hctl_t *hctl, snd_hctl_compare_t hsort);
|
||||||
snd_hctl_elem_t *snd_hctl_first_elem(snd_hctl_t *hctl);
|
snd_hctl_elem_t *snd_hctl_first_elem(snd_hctl_t *hctl);
|
||||||
|
|
@ -230,6 +230,7 @@ int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event);
|
||||||
int snd_hctl_handle_events(snd_hctl_t *hctl);
|
int snd_hctl_handle_events(snd_hctl_t *hctl);
|
||||||
const char *snd_hctl_name(snd_hctl_t *hctl);
|
const char *snd_hctl_name(snd_hctl_t *hctl);
|
||||||
snd_ctl_type_t snd_hctl_type(snd_hctl_t *hctl);
|
snd_ctl_type_t snd_hctl_type(snd_hctl_t *hctl);
|
||||||
|
int snd_hctl_wait(snd_hctl_t *hctl, int timeout);
|
||||||
|
|
||||||
snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem);
|
snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem);
|
||||||
snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem);
|
snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/poll.h>
|
||||||
|
|
||||||
#ifndef ATTRIBUTE_UNUSED
|
#ifndef ATTRIBUTE_UNUSED
|
||||||
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,14 @@ typedef struct _snd_hwdep snd_hwdep_t;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int snd_hwdep_open(snd_hwdep_t **handle, int card, int device, int mode);
|
int snd_hwdep_open(snd_hwdep_t **hwdep, int card, int device, int mode);
|
||||||
int snd_hwdep_close(snd_hwdep_t *handle);
|
int snd_hwdep_close(snd_hwdep_t *hwdep);
|
||||||
int snd_hwdep_poll_descriptor(snd_hwdep_t *handle);
|
int snd_hwdep_poll_descriptors(snd_hwdep_t *hwdep, struct pollfd *pfds, unsigned int space);
|
||||||
int snd_hwdep_block_mode(snd_hwdep_t *handle, int enable);
|
int snd_hwdep_block_mode(snd_hwdep_t *hwdep, int enable);
|
||||||
int snd_hwdep_info(snd_hwdep_t *handle, snd_hwdep_info_t * info);
|
int snd_hwdep_info(snd_hwdep_t *hwdep, snd_hwdep_info_t * info);
|
||||||
int snd_hwdep_ioctl(snd_hwdep_t *handle, int request, void * arg);
|
int snd_hwdep_ioctl(snd_hwdep_t *hwdep, int request, void * arg);
|
||||||
ssize_t snd_hwdep_write(snd_hwdep_t *handle, const void *buffer, size_t size);
|
ssize_t snd_hwdep_write(snd_hwdep_t *hwdep, const void *buffer, size_t size);
|
||||||
ssize_t snd_hwdep_read(snd_hwdep_t *handle, void *buffer, size_t size);
|
ssize_t snd_hwdep_read(snd_hwdep_t *hwdep, void *buffer, size_t size);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,9 @@ snd_mixer_elem_t *snd_mixer_last_elem(snd_mixer_t *mixer);
|
||||||
int snd_mixer_handle_events(snd_mixer_t *mixer);
|
int snd_mixer_handle_events(snd_mixer_t *mixer);
|
||||||
int snd_mixer_attach(snd_mixer_t *mixer, const char *name);
|
int snd_mixer_attach(snd_mixer_t *mixer, const char *name);
|
||||||
int snd_mixer_detach(snd_mixer_t *mixer, const char *name);
|
int snd_mixer_detach(snd_mixer_t *mixer, const char *name);
|
||||||
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);
|
||||||
int snd_mixer_load(snd_mixer_t *mixer);
|
int snd_mixer_load(snd_mixer_t *mixer);
|
||||||
|
int snd_mixer_wait(snd_mixer_t *mixer, int timeout);
|
||||||
int snd_mixer_set_compare(snd_mixer_t *mixer, snd_mixer_compare_t msort);
|
int snd_mixer_set_compare(snd_mixer_t *mixer, snd_mixer_compare_t msort);
|
||||||
|
|
||||||
snd_mixer_elem_t *snd_mixer_elem_next(snd_mixer_elem_t *elem);
|
snd_mixer_elem_t *snd_mixer_elem_next(snd_mixer_elem_t *elem);
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ int snd_pcm_open(snd_pcm_t **pcm, const char *name,
|
||||||
|
|
||||||
snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm);
|
snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm);
|
||||||
int snd_pcm_close(snd_pcm_t *pcm);
|
int snd_pcm_close(snd_pcm_t *pcm);
|
||||||
int snd_pcm_poll_descriptor(snd_pcm_t *pcm);
|
int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space);
|
||||||
int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock);
|
int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock);
|
||||||
int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid);
|
int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid);
|
||||||
int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
|
int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ extern "C" {
|
||||||
int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi,
|
int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi,
|
||||||
const char *name, int mode);
|
const char *name, int mode);
|
||||||
int snd_rawmidi_close(snd_rawmidi_t *rmidi);
|
int snd_rawmidi_close(snd_rawmidi_t *rmidi);
|
||||||
int snd_rawmidi_poll_descriptor(snd_rawmidi_t *rmidi);
|
int snd_rawmidi_poll_descriptors(snd_rawmidi_t *rmidi, struct pollfd *pfds, unsigned int space);
|
||||||
int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock);
|
int snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock);
|
||||||
int snd_rawmidi_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info);
|
int snd_rawmidi_info(snd_rawmidi_t *rmidi, snd_rawmidi_info_t * info);
|
||||||
int snd_rawmidi_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * params);
|
int snd_rawmidi_params(snd_rawmidi_t *rmidi, snd_rawmidi_params_t * params);
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ extern "C" {
|
||||||
|
|
||||||
int snd_seq_open(snd_seq_t **handle, const char *name, int streams, int mode);
|
int snd_seq_open(snd_seq_t **handle, const char *name, int streams, int mode);
|
||||||
int snd_seq_close(snd_seq_t *handle);
|
int snd_seq_close(snd_seq_t *handle);
|
||||||
int snd_seq_poll_descriptor(snd_seq_t *handle);
|
int snd_seq_poll_descriptors(snd_seq_t *handle, struct pollfd *pfds, unsigned int space);
|
||||||
int snd_seq_nonblock(snd_seq_t *handle, int nonblock);
|
int snd_seq_nonblock(snd_seq_t *handle, int nonblock);
|
||||||
int snd_seq_client_id(snd_seq_t *handle);
|
int snd_seq_client_id(snd_seq_t *handle);
|
||||||
int snd_seq_output_buffer_size(snd_seq_t *handle);
|
int snd_seq_output_buffer_size(snd_seq_t *handle);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ extern "C" {
|
||||||
|
|
||||||
int snd_timer_open(snd_timer_t **handle);
|
int snd_timer_open(snd_timer_t **handle);
|
||||||
int snd_timer_close(snd_timer_t *handle);
|
int snd_timer_close(snd_timer_t *handle);
|
||||||
int snd_timer_poll_descriptor(snd_timer_t *handle);
|
int snd_timer_poll_descriptors(snd_timer_t *handle, struct pollfd *pfds, unsigned int space);
|
||||||
int snd_timer_next_device(snd_timer_t *handle, snd_timer_id_t *tid);
|
int snd_timer_next_device(snd_timer_t *handle, snd_timer_id_t *tid);
|
||||||
int snd_timer_select(snd_timer_t *handle, snd_timer_select_t *tselect);
|
int snd_timer_select(snd_timer_t *handle, snd_timer_select_t *tselect);
|
||||||
int snd_timer_info(snd_timer_t *handle, snd_timer_info_t *timer);
|
int snd_timer_info(snd_timer_t *handle, snd_timer_info_t *timer);
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,22 @@ int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid)
|
||||||
return ctl->ops->async(ctl, sig, 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);
|
assert(ctl);
|
||||||
return ctl->ops->poll_descriptor(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)
|
int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info)
|
||||||
{
|
{
|
||||||
assert(ctl && info);
|
assert(ctl && info);
|
||||||
|
|
@ -163,8 +173,8 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
|
||||||
{
|
{
|
||||||
struct pollfd pfd;
|
struct pollfd pfd;
|
||||||
int err;
|
int err;
|
||||||
pfd.fd = snd_ctl_poll_descriptor(ctl);
|
err = snd_ctl_poll_descriptors(ctl, &pfd, 1);
|
||||||
pfd.events = POLLIN;
|
assert(err == 1);
|
||||||
err = poll(&pfd, 1, timeout);
|
err = poll(&pfd, 1, timeout);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return -errno;
|
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_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);
|
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 <netinet/in.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include "aserver.h"
|
#include "aserver.h"
|
||||||
#include "control_local.h"
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int socket;
|
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);
|
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);
|
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)
|
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;
|
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)
|
int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
|
||||||
{
|
{
|
||||||
snd_hctl_elem_t *elem;
|
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;
|
int fd, ver;
|
||||||
char filename[32];
|
char filename[32];
|
||||||
snd_hwdep_t *hwdep;
|
snd_hwdep_t *hwdep;
|
||||||
|
assert(handle);
|
||||||
|
|
||||||
*handle = NULL;
|
*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 snd_hwdep_close(snd_hwdep_t *hwdep)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
assert(hwdep);
|
||||||
if (!hwdep)
|
|
||||||
return -EINVAL;
|
|
||||||
res = close(hwdep->fd) < 0 ? -errno : 0;
|
res = close(hwdep->fd) < 0 ? -errno : 0;
|
||||||
free(hwdep);
|
free(hwdep);
|
||||||
return res;
|
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)
|
assert(hwdep);
|
||||||
return -EINVAL;
|
if (space >= 1) {
|
||||||
return hwdep->fd;
|
pfds->fd = hwdep->fd;
|
||||||
|
pfds->events = POLLOUT | POLLIN;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_hwdep_block_mode(snd_hwdep_t *hwdep, int enable)
|
int snd_hwdep_block_mode(snd_hwdep_t *hwdep, int enable)
|
||||||
{
|
{
|
||||||
long flags;
|
long flags;
|
||||||
|
assert(hwdep);
|
||||||
if (!hwdep)
|
|
||||||
return -EINVAL;
|
|
||||||
if ((flags = fcntl(hwdep->fd, F_GETFL)) < 0)
|
if ((flags = fcntl(hwdep->fd, F_GETFL)) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
if (enable)
|
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)
|
int snd_hwdep_info(snd_hwdep_t *hwdep, snd_hwdep_info_t *info)
|
||||||
{
|
{
|
||||||
if (!hwdep || !info)
|
assert(hwdep && info);
|
||||||
return -EINVAL;
|
|
||||||
if (ioctl(hwdep->fd, SNDRV_HWDEP_IOCTL_INFO, info) < 0)
|
if (ioctl(hwdep->fd, SNDRV_HWDEP_IOCTL_INFO, info) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
return 0;
|
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)
|
int snd_hwdep_ioctl(snd_hwdep_t *hwdep, int request, void * arg)
|
||||||
{
|
{
|
||||||
if (!hwdep)
|
assert(hwdep);
|
||||||
return -EINVAL;
|
|
||||||
if (ioctl(hwdep->fd, request, arg) < 0)
|
if (ioctl(hwdep->fd, request, arg) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
return 0;
|
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 snd_hwdep_write(snd_hwdep_t *hwdep, const void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
ssize_t result;
|
ssize_t result;
|
||||||
|
assert(hwdep && (buffer || size == 0));
|
||||||
if (!hwdep || (!buffer && size > 0))
|
|
||||||
return -EINVAL;
|
|
||||||
result = write(hwdep->fd, buffer, size);
|
result = write(hwdep->fd, buffer, size);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
return -errno;
|
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 snd_hwdep_read(snd_hwdep_t *hwdep, void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
ssize_t result;
|
ssize_t result;
|
||||||
|
assert(hwdep && (buffer || size == 0));
|
||||||
if (!hwdep || (!buffer && size > 0))
|
|
||||||
return -EINVAL;
|
|
||||||
result = read(hwdep->fd, buffer, size);
|
result = read(hwdep->fd, buffer, size);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
|
||||||
|
|
@ -447,19 +447,48 @@ int snd_mixer_set_compare(snd_mixer_t *mixer, snd_mixer_compare_t msort)
|
||||||
return 0;
|
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;
|
struct list_head *pos, *next;
|
||||||
assert(mixer && name);
|
unsigned int count = 0;
|
||||||
|
assert(mixer);
|
||||||
list_for_each(pos, next, &mixer->slaves) {
|
list_for_each(pos, next, &mixer->slaves) {
|
||||||
snd_mixer_slave_t *s;
|
snd_mixer_slave_t *s;
|
||||||
const char *n;
|
int n;
|
||||||
s = list_entry(pos, snd_mixer_slave_t, list);
|
s = list_entry(pos, snd_mixer_slave_t, list);
|
||||||
n = snd_hctl_name(s->hctl);
|
n = snd_hctl_poll_descriptors(s->hctl, pfds, space);
|
||||||
if (n && strcmp(name, n) == 0)
|
if (n < 0)
|
||||||
return snd_hctl_poll_descriptor(s->hctl);
|
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)
|
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 */
|
/* 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 snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2)
|
||||||
{
|
{
|
||||||
int fd1 = snd_pcm_link_descriptor(pcm1);
|
int fd1 = _snd_pcm_link_descriptor(pcm1);
|
||||||
int fd2 = snd_pcm_link_descriptor(pcm2);
|
int fd2 = _snd_pcm_link_descriptor(pcm2);
|
||||||
if (fd1 < 0 || fd2 < 0)
|
if (fd1 < 0 || fd2 < 0)
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
if (ioctl(fd1, SNDRV_PCM_IOCTL_LINK, fd2) < 0) {
|
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 snd_pcm_unlink(snd_pcm_t *pcm)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
fd = snd_pcm_link_descriptor(pcm);
|
fd = _snd_pcm_link_descriptor(pcm);
|
||||||
if (ioctl(fd, SNDRV_PCM_IOCTL_UNLINK) < 0) {
|
if (ioctl(fd, SNDRV_PCM_IOCTL_UNLINK) < 0) {
|
||||||
SYSERR("SNDRV_PCM_IOCTL_UNLINK failed");
|
SYSERR("SNDRV_PCM_IOCTL_UNLINK failed");
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
@ -231,12 +231,22 @@ int snd_pcm_unlink(snd_pcm_t *pcm)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_pcm_poll_descriptor(snd_pcm_t *pcm)
|
int _snd_pcm_poll_descriptor(snd_pcm_t *pcm)
|
||||||
{
|
{
|
||||||
assert(pcm);
|
assert(pcm);
|
||||||
return pcm->poll_fd;
|
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 STATE(v) [SND_PCM_STATE_##v] = #v
|
||||||
#define STREAM(v) [SND_PCM_STREAM_##v] = #v
|
#define STREAM(v) [SND_PCM_STREAM_##v] = #v
|
||||||
#define READY(v) [SND_PCM_READY_##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;
|
struct pollfd pfd;
|
||||||
int err;
|
int err;
|
||||||
pfd.fd = snd_pcm_poll_descriptor(pcm);
|
err = snd_pcm_poll_descriptors(pcm, &pfd, 1);
|
||||||
pfd.events = pcm->stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
|
assert(err == 1);
|
||||||
err = poll(&pfd, 1, timeout);
|
err = poll(&pfd, 1, timeout);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return -errno;
|
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);
|
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(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_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)
|
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_multi_t *multi = pcm->private_data;
|
||||||
snd_pcm_t *slave = multi->slaves[0].pcm;
|
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)
|
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)
|
int snd_pcm_plugin_poll_descriptor(snd_pcm_t *pcm)
|
||||||
{
|
{
|
||||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
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)
|
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_status(snd_pcm_t *pcm);
|
||||||
int snd_pcm_plugin_munmap_control(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_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_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);
|
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;
|
int err;
|
||||||
pfd[0].fd = slave->poll[0];
|
pfd[0].fd = slave->poll[0];
|
||||||
pfd[0].events = POLLIN;
|
pfd[0].events = POLLIN;
|
||||||
pfd[1].fd = snd_pcm_poll_descriptor(spcm);
|
err = snd_pcm_poll_descriptors(spcm, &pfd[1], 1);
|
||||||
pfd[1].events = POLLIN | POLLOUT;
|
assert(err == 1);
|
||||||
Pthread_mutex_lock(&slave->mutex);
|
Pthread_mutex_lock(&slave->mutex);
|
||||||
err = pipe(slave->poll);
|
err = pipe(slave->poll);
|
||||||
assert(err >= 0);
|
assert(err >= 0);
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,23 @@ int snd_rawmidi_close(snd_rawmidi_t *rmidi)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_rawmidi_poll_descriptor(snd_rawmidi_t *rmidi)
|
int _snd_rawmidi_poll_descriptor(snd_rawmidi_t *rmidi)
|
||||||
{
|
{
|
||||||
assert(rmidi);
|
assert(rmidi);
|
||||||
return rmidi->poll_fd;
|
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 snd_rawmidi_nonblock(snd_rawmidi_t *rmidi, int nonblock)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
|
||||||
|
|
@ -146,12 +146,26 @@ int snd_seq_close(snd_seq_t *seq)
|
||||||
/*
|
/*
|
||||||
* returns the file descriptor of the client
|
* 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);
|
assert(seq);
|
||||||
return seq->poll_fd;
|
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
|
* set blocking behavior
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ int snd_timer_close(snd_timer_t *handle)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_timer_poll_descriptor(snd_timer_t *handle)
|
int _snd_timer_poll_descriptor(snd_timer_t *handle)
|
||||||
{
|
{
|
||||||
snd_timer_t *tmr;
|
snd_timer_t *tmr;
|
||||||
|
|
||||||
|
|
@ -84,6 +84,16 @@ int snd_timer_poll_descriptor(snd_timer_t *handle)
|
||||||
return tmr->fd;
|
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)
|
int snd_timer_next_device(snd_timer_t *handle, snd_timer_id_t * tid)
|
||||||
{
|
{
|
||||||
snd_timer_t *tmr;
|
snd_timer_t *tmr;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue