diff --git a/configure b/configure index 16b2ebc..6649f9f 100755 --- a/configure +++ b/configure @@ -13,10 +13,12 @@ Usage: configure [options] --libdir=DIR install libraries in DIR [\$prefix/lib] --mandir=DIR install man pages in DIR [\$prefix/man] --precision=NUMBER aucat/sndiod processing precision [$precision] ---enable-alsa enable alsa backend [$alsa] ---disable-alsa disable alsa backend ---enable-sun enable sun backend [$sun] ---disable-sun disable sun backend +--enable-alsa enable alsa audio & midi backends [$alsa] +--disable-alsa disable alsa audio & midi backends +--enable-sun enable sun audio backend [$sun] +--disable-sun disable sun audio backend +--enable-rmidi enable character device midi backend [$rmidi] +--disable-rmidi disable character device midi backend END } @@ -27,6 +29,7 @@ prefix=/usr/local # where to install sndio so="libsndio.so.\${MAJ}.\${MIN}" # shared libs to build alsa=no # do we want alsa support ? sun=no # do we want sun support ? +rmidi=no # do we want support for raw char dev ? precision=16 # aucat/sndiod arithmetic precision unset vars # variables passed as arguments unset bindir # path where to install binaries @@ -51,6 +54,7 @@ case `uname` in ;; OpenBSD) sun=yes + rmidi=yes defs='-DUSE_ARC4RANDOM' ;; esac @@ -94,6 +98,12 @@ for i; do --disable-sun) sun=no shift;; + --enable-rmidi) + rmidi=yes + shift;; + --disable-rmidi) + rmidi=no + shift;; --precision=*) precision="${i#--precision=}" if [ "$precision" != 16 -a "$precision" != 24 ]; then @@ -135,6 +145,13 @@ if [ $sun = yes ]; then defs="$defs -DUSE_SUN" fi +# +# if using raw character devices for midi, add corresponding parameters +# +if [ $rmidi = yes ]; then + defs="$defs -DUSE_RMIDI" +fi + for makefile in Makefile aucat/Makefile sndiod/Makefile libsndio/Makefile examples/Makefile do sed \ @@ -160,6 +177,7 @@ echo "mandir................... $mandir" echo "precision................ $precision" echo "alsa..................... $alsa" echo "sun...................... $sun" +echo "rmidi.................... $rmidi" echo echo "Do \"make && make install\" to compile and install sndio" echo diff --git a/libsndio/Makefile.in b/libsndio/Makefile.in index b38f730..a9ea642 100644 --- a/libsndio/Makefile.in +++ b/libsndio/Makefile.in @@ -98,7 +98,8 @@ clean: # loader to determine dependencies in a single pass # OBJS = debug.o aucat.o \ -mio.o mio_rmidi.o mio_aucat.o sio.o sio_alsa.o sio_aucat.o sio_sun.o \ +mio.o mio_rmidi.o mio_alsa.o mio_aucat.o \ +sio.o sio_alsa.o sio_aucat.o sio_sun.o \ issetugid.o strlcat.o strlcpy.o strtonum.o .c.o: @@ -130,12 +131,15 @@ aucat.o: aucat.c aucat.h amsg.h debug.h \ debug.o: debug.c debug.h ../bsd-compat/bsd-compat.h mio.o: mio.c debug.h mio_priv.h sndio.h \ ../bsd-compat/bsd-compat.h +mio_alsa.o: mio_alsa.c debug.h mio_priv.h sndio.h mio_aucat.o: mio_aucat.c aucat.h amsg.h debug.h mio_priv.h sndio.h \ ../bsd-compat/bsd-compat.h mio_rmidi.o: mio_rmidi.c debug.h mio_priv.h sndio.h sio.o: sio.c debug.h sio_priv.h sndio.h \ ../bsd-compat/bsd-compat.h -sio_alsa.o: sio_alsa.c debug.h sio_priv.h sndio.h +sio_alsa.o: sio_alsa.c debug.h sio_priv.h sndio.h \ + ../bsd-compat/bsd-compat.h sio_aucat.o: sio_aucat.c aucat.h amsg.h debug.h sio_priv.h sndio.h \ ../bsd-compat/bsd-compat.h -sio_sun.o: sio_sun.c debug.h sio_priv.h sndio.h +sio_sun.o: sio_sun.c debug.h sio_priv.h sndio.h \ + ../bsd-compat/bsd-compat.h diff --git a/libsndio/mio.c b/libsndio/mio.c index cb13a60..09377b7 100644 --- a/libsndio/mio.c +++ b/libsndio/mio.c @@ -55,15 +55,28 @@ mio_open(const char *str, unsigned int mode, int nbio) hdl = mio_aucat_open("/0", mode, nbio, 1); if (hdl != NULL) return hdl; +#if defined(USE_RMIDI) return mio_rmidi_open("/0", mode, nbio); +#elif defined(USE_ALSA) + return mio_alsa_open("/0", mode, nbio); +#else + return NULL; +#endif } if ((p = sndio_parsetype(str, "snd")) != NULL || (p = sndio_parsetype(str, "aucat")) != NULL) return mio_aucat_open(p, mode, nbio, 0); if ((p = sndio_parsetype(str, "midithru")) != NULL) return mio_aucat_open(p, mode, nbio, 1); - if ((p = sndio_parsetype(str, "rmidi")) != NULL) +#if defined(USE_RMIDI) || defined(USE_ALSA) + if ((p = sndio_parsetype(str, "rmidi")) != NULL) { +#if defined(USE_SUN) return mio_rmidi_open(p, mode, nbio); +#elif defined(USE_ALSA) + return mio_alsa_open(p, mode, nbio); +#endif + } +#endif DPRINTF("mio_open: %s: unknown device type\n", str); return NULL; } @@ -193,7 +206,7 @@ mio_write(struct mio_hdl *hdl, const void *buf, size_t len) int mio_nfds(struct mio_hdl *hdl) { - return 1; + return hdl->ops->nfds(hdl); } int diff --git a/libsndio/mio_aucat.c b/libsndio/mio_aucat.c index 5b64315..7ab2833 100644 --- a/libsndio/mio_aucat.c +++ b/libsndio/mio_aucat.c @@ -42,6 +42,7 @@ struct mio_aucat_hdl { static void mio_aucat_close(struct mio_hdl *); static size_t mio_aucat_read(struct mio_hdl *, void *, size_t); static size_t mio_aucat_write(struct mio_hdl *, const void *, size_t); +static int mio_aucat_nfds(struct mio_hdl *); static int mio_aucat_pollfd(struct mio_hdl *, struct pollfd *, int); static int mio_aucat_revents(struct mio_hdl *, struct pollfd *); @@ -49,8 +50,9 @@ static struct mio_ops mio_aucat_ops = { mio_aucat_close, mio_aucat_write, mio_aucat_read, + mio_aucat_nfds, mio_aucat_pollfd, - mio_aucat_revents, + mio_aucat_revents }; /* @@ -140,6 +142,12 @@ mio_aucat_write(struct mio_hdl *sh, const void *buf, size_t len) return n; } +static int +mio_aucat_nfds(struct mio_hdl *sh) +{ + return 1; +} + static int mio_aucat_pollfd(struct mio_hdl *sh, struct pollfd *pfd, int events) { diff --git a/libsndio/mio_priv.h b/libsndio/mio_priv.h index 3380eea..772992b 100644 --- a/libsndio/mio_priv.h +++ b/libsndio/mio_priv.h @@ -39,11 +39,13 @@ struct mio_ops { void (*close)(struct mio_hdl *); size_t (*write)(struct mio_hdl *, const void *, size_t); size_t (*read)(struct mio_hdl *, void *, size_t); + int (*nfds)(struct mio_hdl *); int (*pollfd)(struct mio_hdl *, struct pollfd *, int); int (*revents)(struct mio_hdl *, struct pollfd *); }; struct mio_hdl *mio_rmidi_open(const char *, unsigned, int); +struct mio_hdl *mio_alsa_open(const char *, unsigned, int); struct mio_hdl *mio_aucat_open(const char *, unsigned, int, unsigned); void mio_create(struct mio_hdl *, struct mio_ops *, unsigned, int); void mio_destroy(struct mio_hdl *); diff --git a/libsndio/mio_rmidi.c b/libsndio/mio_rmidi.c index 71b900a..b460497 100644 --- a/libsndio/mio_rmidi.c +++ b/libsndio/mio_rmidi.c @@ -38,6 +38,7 @@ struct mio_rmidi_hdl { static void mio_rmidi_close(struct mio_hdl *); static size_t mio_rmidi_read(struct mio_hdl *, void *, size_t); static size_t mio_rmidi_write(struct mio_hdl *, const void *, size_t); +static int mio_rmidi_nfds(struct mio_hdl *); static int mio_rmidi_pollfd(struct mio_hdl *, struct pollfd *, int); static int mio_rmidi_revents(struct mio_hdl *, struct pollfd *); @@ -45,8 +46,9 @@ static struct mio_ops mio_rmidi_ops = { mio_rmidi_close, mio_rmidi_write, mio_rmidi_read, + mio_rmidi_nfds, mio_rmidi_pollfd, - mio_rmidi_revents, + mio_rmidi_revents }; struct mio_hdl * @@ -148,6 +150,12 @@ mio_rmidi_write(struct mio_hdl *sh, const void *buf, size_t len) return n; } +static int +mio_rmidi_nfds(struct mio_hdl *sh) +{ + return 1; +} + static int mio_rmidi_pollfd(struct mio_hdl *sh, struct pollfd *pfd, int events) {