Merge branch 'master' into mixer

This commit is contained in:
Alexandre Ratchov 2018-02-23 18:19:17 +01:00
commit 03799aab3f
2 changed files with 32 additions and 3 deletions

2
configure vendored
View File

@ -83,8 +83,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 \\\

View File

@ -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");
@ -383,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;
}