From c446e8d141d38f8b1d0420efa80cd30c7a4e1384 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Thu, 31 Mar 2011 13:08:07 +0200 Subject: [PATCH] add sio__nfds() method --- libsndio/sio.c | 9 +++------ libsndio/sio_aucat.c | 8 ++++++++ libsndio/sio_priv.h | 3 ++- libsndio/sio_sun.c | 8 ++++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/libsndio/sio.c b/libsndio/sio.c index 2870a7d..375b244 100644 --- a/libsndio/sio.c +++ b/libsndio/sio.c @@ -89,7 +89,7 @@ sio_open(const char *str, unsigned mode, int nbio) return hdl; #endif #ifdef USE_ALSA - hdl = sio_open_alsa("0", mode, nbio); + hdl = sio_alsa_open("0", mode, nbio); if (hdl != NULL) return hdl; #endif @@ -123,7 +123,7 @@ sio_open(const char *str, unsigned mode, int nbio) #ifdef USE_ALSA if (len == (sizeof(prefix_alsa) - 1) && memcmp(str, prefix_alsa, len) == 0) - return sio_open_alsa(sep + 1, mode, nbio); + return sio_alsa_open(sep + 1, mode, nbio); #endif DPRINTF("sio_open: %s: unknown device type\n", str); return NULL; @@ -379,10 +379,7 @@ sio_write(struct sio_hdl *hdl, const void *buf, size_t len) int sio_nfds(struct sio_hdl *hdl) { - /* - * In the future we might use larger values - */ - return 1; + return hdl->ops->nfds(hdl); } int diff --git a/libsndio/sio_aucat.c b/libsndio/sio_aucat.c index f93278d..b4bad5b 100644 --- a/libsndio/sio_aucat.c +++ b/libsndio/sio_aucat.c @@ -57,6 +57,7 @@ static int sio_aucat_getpar(struct sio_hdl *, struct sio_par *); static int sio_aucat_getcap(struct sio_hdl *, struct sio_cap *); static size_t sio_aucat_read(struct sio_hdl *, void *, size_t); static size_t sio_aucat_write(struct sio_hdl *, const void *, size_t); +static int sio_aucat_nfds(struct sio_hdl *); static int sio_aucat_pollfd(struct sio_hdl *, struct pollfd *, int); static int sio_aucat_revents(struct sio_hdl *, struct pollfd *); static int sio_aucat_setvol(struct sio_hdl *, unsigned); @@ -71,6 +72,7 @@ static struct sio_ops sio_aucat_ops = { sio_aucat_read, sio_aucat_start, sio_aucat_stop, + sio_aucat_nfds, sio_aucat_pollfd, sio_aucat_revents, sio_aucat_setvol, @@ -690,6 +692,12 @@ sio_aucat_write(struct sio_hdl *sh, const void *buf, size_t len) return n; } +static int +sio_aucat_nfds(struct sio_hdl *hdl) +{ + return 1; + } + static int sio_aucat_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events) { diff --git a/libsndio/sio_priv.h b/libsndio/sio_priv.h index 2ca3c75..4c5b63a 100644 --- a/libsndio/sio_priv.h +++ b/libsndio/sio_priv.h @@ -71,6 +71,7 @@ struct sio_ops { size_t (*read)(struct sio_hdl *, void *, size_t); int (*start)(struct sio_hdl *); int (*stop)(struct sio_hdl *); + int (*nfds)(struct sio_hdl *); int (*pollfd)(struct sio_hdl *, struct pollfd *, int); int (*revents)(struct sio_hdl *, struct pollfd *); int (*setvol)(struct sio_hdl *, unsigned); @@ -82,7 +83,7 @@ struct sio_hdl *sio_aucat_open(const char *, unsigned, int); struct sio_hdl *sio_sun_open(const char *, unsigned, int); #endif #ifdef USE_ALSA -struct sio_hdl *sio_open_alsa(const char *, unsigned, int); +struct sio_hdl *sio_alsa_open(const char *, unsigned, int); #endif void sio_create(struct sio_hdl *, struct sio_ops *, unsigned, int); void sio_destroy(struct sio_hdl *); diff --git a/libsndio/sio_sun.c b/libsndio/sio_sun.c index 7a85b4d..9c886c9 100644 --- a/libsndio/sio_sun.c +++ b/libsndio/sio_sun.c @@ -63,6 +63,7 @@ static int sio_sun_getpar(struct sio_hdl *, struct sio_par *); static int sio_sun_getcap(struct sio_hdl *, struct sio_cap *); static size_t sio_sun_read(struct sio_hdl *, void *, size_t); static size_t sio_sun_write(struct sio_hdl *, const void *, size_t); +static int sio_sun_nfds(struct sio_hdl *); static int sio_sun_pollfd(struct sio_hdl *, struct pollfd *, int); static int sio_sun_revents(struct sio_hdl *, struct pollfd *); @@ -75,6 +76,7 @@ static struct sio_ops sio_sun_ops = { sio_sun_read, sio_sun_start, sio_sun_stop, + sio_sun_nfds, sio_sun_pollfd, sio_sun_revents, NULL, /* setvol */ @@ -861,6 +863,12 @@ sio_sun_write(struct sio_hdl *sh, const void *buf, size_t len) return n; } +static int +sio_sun_nfds(struct sio_hdl *hdl) +{ + return 1; +} + static int sio_sun_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events) {