From 2de51001431ffdfa67ef7d65ad1427aaa3b88872 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Mon, 15 Jan 2018 18:26:10 +0100 Subject: [PATCH 1/3] Enable OSS and use SONAME on FreeBSD. From Tobias Kortkamp , thanks! --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index d4bc494..63292e6 100755 --- a/configure +++ b/configure @@ -80,8 +80,10 @@ case `uname` in -DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME' ;; DragonFly|FreeBSD) + oss=yes umidi=yes user=_sndio + so_ldflags="-Wl,-soname=libsndio.so.\${MAJ}.\${MIN}" so_link="libsndio.so" defs='-DHAVE_ARC4RANDOM -DHAVE_ISSETUGID \\\ -DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRTONUM \\\ From a81ef2709a30a255e6e47cf3064c6ed8ccb4fb91 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Mon, 15 Jan 2018 18:30:21 +0100 Subject: [PATCH 2/3] Check if the device supports playing/recording. From Tobias Kortkamp . Thanks. --- libsndio/sio_oss.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libsndio/sio_oss.c b/libsndio/sio_oss.c index 7199782..4b32f4a 100644 --- a/libsndio/sio_oss.c +++ b/libsndio/sio_oss.c @@ -264,6 +264,21 @@ sio_oss_getfd(const char *str, unsigned int mode, int nbio) DPERROR(path); return -1; } + + /* + * Check if the device supports playing/recording. + * Unfortunately, it's possible for devices to be opened RDWR + * even when they don't support playing/recording. + */ + if (mode & SIO_PLAY && ioctl(fd, SNDCTL_DSP_GETOSPACE, &bi) < 0) { + close(fd); + return -1; + } + if (mode & SIO_REC && ioctl(fd, SNDCTL_DSP_GETISPACE, &bi) < 0) { + close(fd); + return -1; + } + val = 1; if (ioctl(fd, SNDCTL_DSP_LOW_WATER, &val) < 0) { DPERROR("sio_oss_start: LOW_WATER"); From 1024ccde8b38c800b3406e5d25bff947031d1d74 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Mon, 15 Jan 2018 18:32:02 +0100 Subject: [PATCH 3/3] Handle par->le, par->msb, par->sig as booleans in sio_oss_setpar(). From Tobias Kortkamp . Thanks. --- libsndio/sio_oss.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libsndio/sio_oss.c b/libsndio/sio_oss.c index 4b32f4a..c44ff60 100644 --- a/libsndio/sio_oss.c +++ b/libsndio/sio_oss.c @@ -398,13 +398,25 @@ sio_oss_setpar(struct sio_hdl *sh, struct sio_par *par) struct sio_oss_hdl *hdl = (struct sio_oss_hdl *)sh; unsigned int i, round, bufsz; int frag_max, frag_shift, frag_count, frag; + unsigned int le, sig, msb; + + le = par->le; + sig = par->sig; + msb = par->msb; + + if (le == ~0U) + le = 0; + if (sig == ~0U) + sig = 0; + if (msb == ~0U) + msb = 0; hdl->fmt = AFMT_S16_LE; for (i = 0; i < sizeof(formats)/sizeof(formats[0]); i++) { if (formats[i].bits == par->bits && - formats[i].le == par->le && - formats[i].sig == par->sig && - formats[i].msb == par->msb) { + formats[i].le == le && + formats[i].sig == sig && + formats[i].msb == msb) { hdl->fmt = formats[i].fmt; break; }