mirror of https://github.com/ericonr/sndio.git
Rename siomix -> sioctl, stop using "mixer" word.
This commit is contained in:
parent
7afde07efd
commit
6e83bb6a4f
|
@ -34,9 +34,9 @@ MAN3 = \
|
|||
sio_start.3 sio_stop.3 sio_read.3 sio_write.3 sio_onmove.3 \
|
||||
sio_nfds.3 sio_pollfd.3 sio_revents.3 sio_eof.3 \
|
||||
sio_setvol.3 sio_onvol.3 sio_initpar.3 \
|
||||
siomix_open.3 \
|
||||
siomix_close.3 siomix_setctl.3 siomix_ondesc.3 siomix_onctl.3 \
|
||||
siomix_nfds.3 siomix_pollfd.3 siomix_revents.3 siomix_eof.3 \
|
||||
sioctl_open.3 \
|
||||
sioctl_close.3 sioctl_setctl.3 sioctl_ondesc.3 sioctl_onctl.3 \
|
||||
sioctl_nfds.3 sioctl_pollfd.3 sioctl_revents.3 sioctl_eof.3 \
|
||||
mio_open.3 \
|
||||
mio_close.3 mio_read.3 mio_write.3 mio_nfds.3 mio_pollfd.3 \
|
||||
mio_revents.3 mio_eof.3
|
||||
|
@ -77,15 +77,15 @@ install:
|
|||
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_setvol.3
|
||||
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_onvol.3
|
||||
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_initpar.3
|
||||
cp siomix_open.3 ${DESTDIR}${MAN3_DIR}
|
||||
ln -sf siomix_open.3 ${DESTDIR}${MAN3_DIR}/siomix_close.3
|
||||
ln -sf siomix_open.3 ${DESTDIR}${MAN3_DIR}/siomix_setctl.3
|
||||
ln -sf siomix_open.3 ${DESTDIR}${MAN3_DIR}/siomix_ondesc.3
|
||||
ln -sf siomix_open.3 ${DESTDIR}${MAN3_DIR}/siomix_onctl.3
|
||||
ln -sf siomix_open.3 ${DESTDIR}${MAN3_DIR}/siomix_nfds.3
|
||||
ln -sf siomix_open.3 ${DESTDIR}${MAN3_DIR}/siomix_pollfd.3
|
||||
ln -sf siomix_open.3 ${DESTDIR}${MAN3_DIR}/siomix_revents.3
|
||||
ln -sf siomix_open.3 ${DESTDIR}${MAN3_DIR}/siomix_eof.3
|
||||
cp sioctl_open.3 ${DESTDIR}${MAN3_DIR}
|
||||
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_close.3
|
||||
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_setctl.3
|
||||
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_ondesc.3
|
||||
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_onctl.3
|
||||
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_nfds.3
|
||||
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_pollfd.3
|
||||
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_revents.3
|
||||
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_eof.3
|
||||
cp mio_open.3 ${DESTDIR}${MAN3_DIR}
|
||||
ln -sf mio_open.3 ${DESTDIR}${MAN3_DIR}/mio_close.3
|
||||
ln -sf mio_open.3 ${DESTDIR}${MAN3_DIR}/mio_read.3
|
||||
|
@ -114,7 +114,7 @@ clean:
|
|||
OBJS = debug.o aucat.o \
|
||||
mio.o mio_rmidi.o mio_alsa.o mio_aucat.o \
|
||||
sio.o sio_alsa.o sio_aucat.o sio_oss.o sio_sun.o \
|
||||
siomix.o siomix_aucat.o siomix_sun.o \
|
||||
sioctl.o sioctl_aucat.o sioctl_sun.o \
|
||||
issetugid.o strlcat.o strlcpy.o strtonum.o clock_gettime.o
|
||||
|
||||
.c.o:
|
||||
|
@ -160,6 +160,6 @@ sio_oss.o: sio_oss.c 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 \
|
||||
../bsd-compat/bsd-compat.h
|
||||
siomix.o: siomix.c debug.h siomix_priv.h
|
||||
siomix_aucat.o: siomix_aucat.c debug.h aucat.h amsg.h siomix_priv.h
|
||||
siomix_sun.o: siomix_sun.c debug.h amsg.h siomix_priv.h
|
||||
sioctl.o: sioctl.c debug.h sioctl_priv.h
|
||||
sioctl_aucat.o: sioctl_aucat.c debug.h aucat.h amsg.h sioctl_priv.h
|
||||
sioctl_sun.o: sioctl_sun.c debug.h amsg.h sioctl_priv.h
|
||||
|
|
|
@ -45,9 +45,7 @@
|
|||
/*
|
||||
* limits
|
||||
*/
|
||||
#define AMSG_MIX_NAMEMAX 16 /* max name length */
|
||||
#define AMSG_MIX_INTMAX 127 /* max channel number */
|
||||
#define AMSG_MIX_HALF 64 /* also bool threshold */
|
||||
#define AMSG_CTL_NAMEMAX 16 /* max name length */
|
||||
|
||||
/*
|
||||
* WARNING: since the protocol may be simultaneously used by static
|
||||
|
@ -71,9 +69,9 @@ struct amsg {
|
|||
#define AMSG_HELLO 10 /* say hello, check versions and so ... */
|
||||
#define AMSG_BYE 11 /* ask server to drop connection */
|
||||
#define AMSG_AUTH 12 /* send authentication cookie */
|
||||
#define AMSG_MIXSUB 13 /* ondesc/onctl subscription */
|
||||
#define AMSG_MIXSET 14 /* set mixer control value */
|
||||
#define AMSG_MIXSYNC 15 /* end of mixer description */
|
||||
#define AMSG_CTLSUB 13 /* ondesc/onctl subscription */
|
||||
#define AMSG_CTLSET 14 /* set control value */
|
||||
#define AMSG_CTLSYNC 15 /* end of controls descriptions */
|
||||
uint32_t cmd;
|
||||
uint32_t __pad;
|
||||
union {
|
||||
|
@ -118,20 +116,20 @@ struct amsg {
|
|||
#define AMSG_COOKIELEN 16
|
||||
uint8_t cookie[AMSG_COOKIELEN];
|
||||
} auth;
|
||||
struct amsg_mixsub {
|
||||
struct amsg_ctlsub {
|
||||
uint8_t desc, val;
|
||||
} mixsub;
|
||||
struct amsg_mixset {
|
||||
} ctlsub;
|
||||
struct amsg_ctlset {
|
||||
uint16_t addr, val;
|
||||
} mixset;
|
||||
} ctlset;
|
||||
} u;
|
||||
};
|
||||
|
||||
/*
|
||||
* subset of channels of a stream
|
||||
*/
|
||||
struct amsg_mix_chan {
|
||||
char str[AMSG_MIX_NAMEMAX]; /* stream name */
|
||||
struct amsg_ctl_chan {
|
||||
char str[AMSG_CTL_NAMEMAX]; /* stream name */
|
||||
int16_t unit; /* stream number */
|
||||
uint8_t __pad[2];
|
||||
};
|
||||
|
@ -139,12 +137,12 @@ struct amsg_mix_chan {
|
|||
/*
|
||||
* description of a control (index, value) pair
|
||||
*/
|
||||
struct amsg_mix_desc {
|
||||
struct amsg_mix_chan group; /* group of the control */
|
||||
struct amsg_mix_chan chan0; /* affected channels */
|
||||
struct amsg_mix_chan chan1; /* dito for AMSG_MIX_{SEL,VEC,LIST} */
|
||||
char func[AMSG_MIX_NAMEMAX]; /* parameter function name */
|
||||
uint8_t type; /* see siomix_desc structure */
|
||||
struct amsg_ctl_desc {
|
||||
struct amsg_ctl_chan group; /* group of the control */
|
||||
struct amsg_ctl_chan chan0; /* affected channels */
|
||||
struct amsg_ctl_chan chan1; /* dito for AMSG_CTL_{SEL,VEC,LIST} */
|
||||
char func[AMSG_CTL_NAMEMAX]; /* parameter function name */
|
||||
uint8_t type; /* see sioctl_desc structure */
|
||||
uint8_t __pad1[1];
|
||||
uint16_t addr; /* control address */
|
||||
uint16_t __pad2[1];
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "siomix_priv.h"
|
||||
#include "sioctl_priv.h"
|
||||
#include "bsd-compat.h"
|
||||
|
||||
struct siomix_hdl *
|
||||
siomix_open(const char *str, unsigned int mode, int nbio)
|
||||
struct sioctl_hdl *
|
||||
sioctl_open(const char *str, unsigned int mode, int nbio)
|
||||
{
|
||||
static char devany[] = SIOMIX_DEVANY;
|
||||
struct siomix_hdl *hdl;
|
||||
static char devany[] = SIOCTL_DEVANY;
|
||||
struct sioctl_hdl *hdl;
|
||||
|
||||
#ifdef DEBUG
|
||||
_sndio_debug_init();
|
||||
|
@ -41,33 +41,33 @@ siomix_open(const char *str, unsigned int mode, int nbio)
|
|||
str = devany;
|
||||
}
|
||||
if (strcmp(str, devany) == 0) {
|
||||
hdl = _siomix_aucat_open("snd/0", mode, nbio);
|
||||
hdl = _sioctl_aucat_open("snd/0", mode, nbio);
|
||||
if (hdl != NULL)
|
||||
return hdl;
|
||||
#if defined(USE_SUN_MIXER)
|
||||
return _siomix_sun_open("rsnd/0", mode, nbio);
|
||||
return _sioctl_sun_open("rsnd/0", mode, nbio);
|
||||
#elif defined(USE_ALSA_MIXER)
|
||||
return _siomix_alsa_open("rsnd/0", mode, nbio);
|
||||
return _sioctl_alsa_open("rsnd/0", mode, nbio);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
if (_sndio_parsetype(str, "snd"))
|
||||
return _siomix_aucat_open(str, mode, nbio);
|
||||
return _sioctl_aucat_open(str, mode, nbio);
|
||||
if (_sndio_parsetype(str, "rsnd"))
|
||||
#if defined(USE_SUN_MIXER)
|
||||
return _siomix_sun_open(str, mode, nbio);
|
||||
return _sioctl_sun_open(str, mode, nbio);
|
||||
#elif defined(USE_ALSA_MIXER)
|
||||
return _siomix_alsa_open(str, mode, nbio);
|
||||
return _sioctl_alsa_open(str, mode, nbio);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
DPRINTF("siomix_open: %s: unknown device type\n", str);
|
||||
DPRINTF("sioctl_open: %s: unknown device type\n", str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
_siomix_create(struct siomix_hdl *hdl, struct siomix_ops *ops,
|
||||
_sioctl_create(struct sioctl_hdl *hdl, struct sioctl_ops *ops,
|
||||
unsigned int mode, int nbio)
|
||||
{
|
||||
hdl->ops = ops;
|
||||
|
@ -78,25 +78,25 @@ _siomix_create(struct siomix_hdl *hdl, struct siomix_ops *ops,
|
|||
}
|
||||
|
||||
int
|
||||
_siomix_psleep(struct siomix_hdl *hdl, int event)
|
||||
_sioctl_psleep(struct sioctl_hdl *hdl, int event)
|
||||
{
|
||||
struct pollfd pfds[SIOMIX_MAXNFDS];
|
||||
struct pollfd pfds[SIOCTL_MAXNFDS];
|
||||
int revents, nfds;
|
||||
|
||||
for (;;) {
|
||||
nfds = siomix_pollfd(hdl, pfds, event);
|
||||
nfds = sioctl_pollfd(hdl, pfds, event);
|
||||
if (nfds == 0)
|
||||
return 0;
|
||||
while (poll(pfds, nfds, -1) < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
DPERROR("siomix_psleep: poll");
|
||||
DPERROR("sioctl_psleep: poll");
|
||||
hdl->eof = 1;
|
||||
return 0;
|
||||
}
|
||||
revents = siomix_revents(hdl, pfds);
|
||||
revents = sioctl_revents(hdl, pfds);
|
||||
if (revents & POLLHUP) {
|
||||
DPRINTF("siomix_psleep: hang-up\n");
|
||||
DPRINTF("sioctl_psleep: hang-up\n");
|
||||
return 0;
|
||||
}
|
||||
if (event == 0 || (revents & event))
|
||||
|
@ -106,19 +106,19 @@ _siomix_psleep(struct siomix_hdl *hdl, int event)
|
|||
}
|
||||
|
||||
void
|
||||
siomix_close(struct siomix_hdl *hdl)
|
||||
sioctl_close(struct sioctl_hdl *hdl)
|
||||
{
|
||||
hdl->ops->close(hdl);
|
||||
}
|
||||
|
||||
int
|
||||
siomix_nfds(struct siomix_hdl *hdl)
|
||||
sioctl_nfds(struct sioctl_hdl *hdl)
|
||||
{
|
||||
return hdl->ops->nfds(hdl);
|
||||
}
|
||||
|
||||
int
|
||||
siomix_pollfd(struct siomix_hdl *hdl, struct pollfd *pfd, int events)
|
||||
sioctl_pollfd(struct sioctl_hdl *hdl, struct pollfd *pfd, int events)
|
||||
{
|
||||
if (hdl->eof)
|
||||
return 0;
|
||||
|
@ -126,7 +126,7 @@ siomix_pollfd(struct siomix_hdl *hdl, struct pollfd *pfd, int events)
|
|||
}
|
||||
|
||||
int
|
||||
siomix_revents(struct siomix_hdl *hdl, struct pollfd *pfd)
|
||||
sioctl_revents(struct sioctl_hdl *hdl, struct pollfd *pfd)
|
||||
{
|
||||
if (hdl->eof)
|
||||
return POLLHUP;
|
||||
|
@ -134,14 +134,14 @@ siomix_revents(struct siomix_hdl *hdl, struct pollfd *pfd)
|
|||
}
|
||||
|
||||
int
|
||||
siomix_eof(struct siomix_hdl *hdl)
|
||||
sioctl_eof(struct sioctl_hdl *hdl)
|
||||
{
|
||||
return hdl->eof;
|
||||
}
|
||||
|
||||
int
|
||||
siomix_ondesc(struct siomix_hdl *hdl,
|
||||
void (*cb)(void *, struct siomix_desc *, int), void *arg)
|
||||
sioctl_ondesc(struct sioctl_hdl *hdl,
|
||||
void (*cb)(void *, struct sioctl_desc *, int), void *arg)
|
||||
{
|
||||
hdl->desc_cb = cb;
|
||||
hdl->desc_arg = arg;
|
||||
|
@ -149,7 +149,7 @@ siomix_ondesc(struct siomix_hdl *hdl,
|
|||
}
|
||||
|
||||
int
|
||||
siomix_onctl(struct siomix_hdl *hdl,
|
||||
sioctl_onctl(struct sioctl_hdl *hdl,
|
||||
void (*cb)(void *, unsigned int, unsigned int), void *arg)
|
||||
{
|
||||
hdl->ctl_cb = cb;
|
||||
|
@ -158,11 +158,11 @@ siomix_onctl(struct siomix_hdl *hdl,
|
|||
}
|
||||
|
||||
void
|
||||
_siomix_ondesc_cb(struct siomix_hdl *hdl,
|
||||
struct siomix_desc *desc, unsigned int val)
|
||||
_sioctl_ondesc_cb(struct sioctl_hdl *hdl,
|
||||
struct sioctl_desc *desc, unsigned int val)
|
||||
{
|
||||
if (desc) {
|
||||
DPRINTF("_siomix_ondesc_cb: %u -> %s[%d].%s=%s[%d]:%d\n",
|
||||
DPRINTF("_sioctl_ondesc_cb: %u -> %s[%d].%s=%s[%d]:%d\n",
|
||||
desc->addr,
|
||||
desc->chan0.str, desc->chan0.unit,
|
||||
desc->func,
|
||||
|
@ -174,17 +174,17 @@ _siomix_ondesc_cb(struct siomix_hdl *hdl,
|
|||
}
|
||||
|
||||
void
|
||||
_siomix_onctl_cb(struct siomix_hdl *hdl, unsigned int addr, unsigned int val)
|
||||
_sioctl_onctl_cb(struct sioctl_hdl *hdl, unsigned int addr, unsigned int val)
|
||||
{
|
||||
DPRINTF("_siomix_onctl_cb: %u -> %u\n", addr, val);
|
||||
DPRINTF("_sioctl_onctl_cb: %u -> %u\n", addr, val);
|
||||
if (hdl->ctl_cb)
|
||||
hdl->ctl_cb(hdl->ctl_arg, addr, val);
|
||||
}
|
||||
|
||||
int
|
||||
siomix_setctl(struct siomix_hdl *hdl, unsigned int addr, unsigned int val)
|
||||
sioctl_setctl(struct sioctl_hdl *hdl, unsigned int addr, unsigned int val)
|
||||
{
|
||||
if (!(hdl->mode & SIOMIX_WRITE))
|
||||
if (!(hdl->mode & SIOCTL_WRITE))
|
||||
return 0;
|
||||
return hdl->ops->setctl(hdl, addr, val);
|
||||
}
|
|
@ -23,44 +23,44 @@
|
|||
#include <arpa/inet.h>
|
||||
#include "debug.h"
|
||||
#include "aucat.h"
|
||||
#include "siomix_priv.h"
|
||||
#include "sioctl_priv.h"
|
||||
#include "bsd-compat.h"
|
||||
|
||||
struct siomix_aucat_hdl {
|
||||
struct siomix_hdl siomix;
|
||||
struct sioctl_aucat_hdl {
|
||||
struct sioctl_hdl sioctl;
|
||||
struct aucat aucat;
|
||||
struct siomix_desc desc;
|
||||
struct amsg_mix_desc buf[16];
|
||||
struct sioctl_desc desc;
|
||||
struct amsg_ctl_desc buf[16];
|
||||
size_t buf_wpos;
|
||||
int dump_wait;
|
||||
};
|
||||
|
||||
static void siomix_aucat_close(struct siomix_hdl *);
|
||||
static int siomix_aucat_nfds(struct siomix_hdl *);
|
||||
static int siomix_aucat_pollfd(struct siomix_hdl *, struct pollfd *, int);
|
||||
static int siomix_aucat_revents(struct siomix_hdl *, struct pollfd *);
|
||||
static int siomix_aucat_setctl(struct siomix_hdl *, unsigned int, unsigned int);
|
||||
static int siomix_aucat_onctl(struct siomix_hdl *);
|
||||
static int siomix_aucat_ondesc(struct siomix_hdl *);
|
||||
static void sioctl_aucat_close(struct sioctl_hdl *);
|
||||
static int sioctl_aucat_nfds(struct sioctl_hdl *);
|
||||
static int sioctl_aucat_pollfd(struct sioctl_hdl *, struct pollfd *, int);
|
||||
static int sioctl_aucat_revents(struct sioctl_hdl *, struct pollfd *);
|
||||
static int sioctl_aucat_setctl(struct sioctl_hdl *, unsigned int, unsigned int);
|
||||
static int sioctl_aucat_onctl(struct sioctl_hdl *);
|
||||
static int sioctl_aucat_ondesc(struct sioctl_hdl *);
|
||||
|
||||
/*
|
||||
* operations every device should support
|
||||
*/
|
||||
struct siomix_ops siomix_aucat_ops = {
|
||||
siomix_aucat_close,
|
||||
siomix_aucat_nfds,
|
||||
siomix_aucat_pollfd,
|
||||
siomix_aucat_revents,
|
||||
siomix_aucat_setctl,
|
||||
siomix_aucat_onctl,
|
||||
siomix_aucat_ondesc
|
||||
struct sioctl_ops sioctl_aucat_ops = {
|
||||
sioctl_aucat_close,
|
||||
sioctl_aucat_nfds,
|
||||
sioctl_aucat_pollfd,
|
||||
sioctl_aucat_revents,
|
||||
sioctl_aucat_setctl,
|
||||
sioctl_aucat_onctl,
|
||||
sioctl_aucat_ondesc
|
||||
};
|
||||
|
||||
static int
|
||||
siomix_aucat_rdata(struct siomix_aucat_hdl *hdl)
|
||||
sioctl_aucat_rdata(struct sioctl_aucat_hdl *hdl)
|
||||
{
|
||||
struct siomix_desc desc;
|
||||
struct amsg_mix_desc *c;
|
||||
struct sioctl_desc desc;
|
||||
struct amsg_ctl_desc *c;
|
||||
size_t rpos;
|
||||
int n;
|
||||
|
||||
|
@ -72,8 +72,8 @@ siomix_aucat_rdata(struct siomix_aucat_hdl *hdl)
|
|||
n = _aucat_rdata(&hdl->aucat,
|
||||
(unsigned char *)hdl->buf + hdl->buf_wpos,
|
||||
sizeof(hdl->buf) - hdl->buf_wpos,
|
||||
&hdl->siomix.eof);
|
||||
if (n == 0 || hdl->siomix.eof)
|
||||
&hdl->sioctl.eof);
|
||||
if (n == 0 || hdl->sioctl.eof)
|
||||
return 0;
|
||||
hdl->buf_wpos += n;
|
||||
}
|
||||
|
@ -82,18 +82,18 @@ siomix_aucat_rdata(struct siomix_aucat_hdl *hdl)
|
|||
c = hdl->buf;
|
||||
rpos = 0;
|
||||
while (rpos < hdl->buf_wpos) {
|
||||
strlcpy(desc.group.str, c->group.str, SIOMIX_NAMEMAX);
|
||||
strlcpy(desc.group.str, c->group.str, SIOCTL_NAMEMAX);
|
||||
desc.group.unit = (int16_t)ntohs(c->group.unit);
|
||||
strlcpy(desc.chan0.str, c->chan0.str, SIOMIX_NAMEMAX);
|
||||
strlcpy(desc.chan0.str, c->chan0.str, SIOCTL_NAMEMAX);
|
||||
desc.chan0.unit = (int16_t)ntohs(c->chan0.unit);
|
||||
strlcpy(desc.chan1.str, c->chan1.str, SIOMIX_NAMEMAX);
|
||||
strlcpy(desc.chan1.str, c->chan1.str, SIOCTL_NAMEMAX);
|
||||
desc.chan1.unit = (int16_t)ntohs(c->chan1.unit);
|
||||
strlcpy(desc.func, c->func, SIOMIX_NAMEMAX);
|
||||
strlcpy(desc.func, c->func, SIOCTL_NAMEMAX);
|
||||
desc.type = c->type;
|
||||
desc.addr = ntohs(c->addr);
|
||||
_siomix_ondesc_cb(&hdl->siomix,
|
||||
_sioctl_ondesc_cb(&hdl->sioctl,
|
||||
&desc, ntohs(c->curval));
|
||||
rpos += sizeof(struct amsg_mix_desc);
|
||||
rpos += sizeof(struct amsg_ctl_desc);
|
||||
c++;
|
||||
}
|
||||
hdl->buf_wpos = 0;
|
||||
|
@ -105,31 +105,31 @@ siomix_aucat_rdata(struct siomix_aucat_hdl *hdl)
|
|||
* execute the next message, return 0 if blocked
|
||||
*/
|
||||
static int
|
||||
siomix_aucat_runmsg(struct siomix_aucat_hdl *hdl)
|
||||
sioctl_aucat_runmsg(struct sioctl_aucat_hdl *hdl)
|
||||
{
|
||||
if (!_aucat_rmsg(&hdl->aucat, &hdl->siomix.eof))
|
||||
if (!_aucat_rmsg(&hdl->aucat, &hdl->sioctl.eof))
|
||||
return 0;
|
||||
switch (ntohl(hdl->aucat.rmsg.cmd)) {
|
||||
case AMSG_DATA:
|
||||
hdl->buf_wpos = 0;
|
||||
if (!siomix_aucat_rdata(hdl))
|
||||
if (!sioctl_aucat_rdata(hdl))
|
||||
return 0;
|
||||
break;
|
||||
case AMSG_MIXSET:
|
||||
DPRINTF("siomix_aucat_runmsg: got MIXSET\n");
|
||||
_siomix_onctl_cb(&hdl->siomix,
|
||||
ntohs(hdl->aucat.rmsg.u.mixset.addr),
|
||||
ntohs(hdl->aucat.rmsg.u.mixset.val));
|
||||
case AMSG_CTLSET:
|
||||
DPRINTF("sioctl_aucat_runmsg: got CTLSET\n");
|
||||
_sioctl_onctl_cb(&hdl->sioctl,
|
||||
ntohs(hdl->aucat.rmsg.u.ctlset.addr),
|
||||
ntohs(hdl->aucat.rmsg.u.ctlset.val));
|
||||
break;
|
||||
case AMSG_MIXSYNC:
|
||||
DPRINTF("siomix_aucat_runmsg: got MIXSYNC\n");
|
||||
case AMSG_CTLSYNC:
|
||||
DPRINTF("sioctl_aucat_runmsg: got CTLSYNC\n");
|
||||
hdl->dump_wait = 0;
|
||||
_siomix_ondesc_cb(&hdl->siomix, NULL, 0);
|
||||
_sioctl_ondesc_cb(&hdl->sioctl, NULL, 0);
|
||||
break;
|
||||
default:
|
||||
DPRINTF("sio_aucat_runmsg: unhandled message %u\n",
|
||||
hdl->aucat.rmsg.cmd);
|
||||
hdl->siomix.eof = 1;
|
||||
hdl->sioctl.eof = 1;
|
||||
return 0;
|
||||
}
|
||||
hdl->aucat.rstate = RSTATE_MSG;
|
||||
|
@ -137,52 +137,52 @@ siomix_aucat_runmsg(struct siomix_aucat_hdl *hdl)
|
|||
return 1;
|
||||
}
|
||||
|
||||
struct siomix_hdl *
|
||||
_siomix_aucat_open(const char *str, unsigned int mode, int nbio)
|
||||
struct sioctl_hdl *
|
||||
_sioctl_aucat_open(const char *str, unsigned int mode, int nbio)
|
||||
{
|
||||
struct siomix_aucat_hdl *hdl;
|
||||
struct sioctl_aucat_hdl *hdl;
|
||||
|
||||
hdl = malloc(sizeof(struct siomix_aucat_hdl));
|
||||
hdl = malloc(sizeof(struct sioctl_aucat_hdl));
|
||||
if (hdl == NULL)
|
||||
return NULL;
|
||||
if (!_aucat_open(&hdl->aucat, str, mode)) {
|
||||
free(hdl);
|
||||
return NULL;
|
||||
}
|
||||
_siomix_create(&hdl->siomix, &siomix_aucat_ops, mode, nbio);
|
||||
_sioctl_create(&hdl->sioctl, &sioctl_aucat_ops, mode, nbio);
|
||||
hdl->dump_wait = 0;
|
||||
return (struct siomix_hdl *)hdl;
|
||||
return (struct sioctl_hdl *)hdl;
|
||||
}
|
||||
|
||||
static void
|
||||
siomix_aucat_close(struct siomix_hdl *addr)
|
||||
sioctl_aucat_close(struct sioctl_hdl *addr)
|
||||
{
|
||||
struct siomix_aucat_hdl *hdl = (struct siomix_aucat_hdl *)addr;
|
||||
struct sioctl_aucat_hdl *hdl = (struct sioctl_aucat_hdl *)addr;
|
||||
|
||||
_aucat_close(&hdl->aucat, hdl->siomix.eof);
|
||||
_aucat_close(&hdl->aucat, hdl->sioctl.eof);
|
||||
free(hdl);
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_aucat_ondesc(struct siomix_hdl *addr)
|
||||
sioctl_aucat_ondesc(struct sioctl_hdl *addr)
|
||||
{
|
||||
struct siomix_aucat_hdl *hdl = (struct siomix_aucat_hdl *)addr;
|
||||
struct sioctl_aucat_hdl *hdl = (struct sioctl_aucat_hdl *)addr;
|
||||
|
||||
while (hdl->aucat.wstate != WSTATE_IDLE) {
|
||||
if (!_siomix_psleep(&hdl->siomix, POLLOUT))
|
||||
if (!_sioctl_psleep(&hdl->sioctl, POLLOUT))
|
||||
return 0;
|
||||
}
|
||||
AMSG_INIT(&hdl->aucat.wmsg);
|
||||
hdl->aucat.wmsg.cmd = htonl(AMSG_MIXSUB);
|
||||
hdl->aucat.wmsg.u.mixsub.desc = 1;
|
||||
hdl->aucat.wmsg.u.mixsub.val = 0;
|
||||
hdl->aucat.wmsg.cmd = htonl(AMSG_CTLSUB);
|
||||
hdl->aucat.wmsg.u.ctlsub.desc = 1;
|
||||
hdl->aucat.wmsg.u.ctlsub.val = 0;
|
||||
hdl->aucat.wtodo = sizeof(struct amsg);
|
||||
if (!_aucat_wmsg(&hdl->aucat, &hdl->siomix.eof))
|
||||
if (!_aucat_wmsg(&hdl->aucat, &hdl->sioctl.eof))
|
||||
return 0;
|
||||
hdl->dump_wait = 1;
|
||||
while (hdl->dump_wait) {
|
||||
DPRINTF("psleeping...\n");
|
||||
if (!_siomix_psleep(&hdl->siomix, 0))
|
||||
if (!_sioctl_psleep(&hdl->sioctl, 0))
|
||||
return 0;
|
||||
DPRINTF("psleeping done\n");
|
||||
}
|
||||
|
@ -191,73 +191,73 @@ siomix_aucat_ondesc(struct siomix_hdl *addr)
|
|||
}
|
||||
|
||||
static int
|
||||
siomix_aucat_onctl(struct siomix_hdl *addr)
|
||||
sioctl_aucat_onctl(struct sioctl_hdl *addr)
|
||||
{
|
||||
struct siomix_aucat_hdl *hdl = (struct siomix_aucat_hdl *)addr;
|
||||
struct sioctl_aucat_hdl *hdl = (struct sioctl_aucat_hdl *)addr;
|
||||
|
||||
while (hdl->aucat.wstate != WSTATE_IDLE) {
|
||||
if (!_siomix_psleep(&hdl->siomix, POLLOUT))
|
||||
if (!_sioctl_psleep(&hdl->sioctl, POLLOUT))
|
||||
return 0;
|
||||
}
|
||||
AMSG_INIT(&hdl->aucat.wmsg);
|
||||
hdl->aucat.wmsg.cmd = htonl(AMSG_MIXSUB);
|
||||
hdl->aucat.wmsg.u.mixsub.desc = 1;
|
||||
hdl->aucat.wmsg.u.mixsub.val = 1;
|
||||
hdl->aucat.wmsg.cmd = htonl(AMSG_CTLSUB);
|
||||
hdl->aucat.wmsg.u.ctlsub.desc = 1;
|
||||
hdl->aucat.wmsg.u.ctlsub.val = 1;
|
||||
hdl->aucat.wtodo = sizeof(struct amsg);
|
||||
if (!_aucat_wmsg(&hdl->aucat, &hdl->siomix.eof))
|
||||
if (!_aucat_wmsg(&hdl->aucat, &hdl->sioctl.eof))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_aucat_setctl(struct siomix_hdl *addr, unsigned int a, unsigned int v)
|
||||
sioctl_aucat_setctl(struct sioctl_hdl *addr, unsigned int a, unsigned int v)
|
||||
{
|
||||
struct siomix_aucat_hdl *hdl = (struct siomix_aucat_hdl *)addr;
|
||||
struct sioctl_aucat_hdl *hdl = (struct sioctl_aucat_hdl *)addr;
|
||||
|
||||
hdl->aucat.wstate = WSTATE_MSG;
|
||||
hdl->aucat.wtodo = sizeof(struct amsg);
|
||||
hdl->aucat.wmsg.cmd = htonl(AMSG_MIXSET);
|
||||
hdl->aucat.wmsg.u.mixset.addr = htons(a);
|
||||
hdl->aucat.wmsg.u.mixset.val = htons(v);
|
||||
return _aucat_wmsg(&hdl->aucat, &hdl->siomix.eof);
|
||||
hdl->aucat.wmsg.cmd = htonl(AMSG_CTLSET);
|
||||
hdl->aucat.wmsg.u.ctlset.addr = htons(a);
|
||||
hdl->aucat.wmsg.u.ctlset.val = htons(v);
|
||||
return _aucat_wmsg(&hdl->aucat, &hdl->sioctl.eof);
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_aucat_nfds(struct siomix_hdl *addr)
|
||||
sioctl_aucat_nfds(struct sioctl_hdl *addr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_aucat_pollfd(struct siomix_hdl *addr, struct pollfd *pfd, int events)
|
||||
sioctl_aucat_pollfd(struct sioctl_hdl *addr, struct pollfd *pfd, int events)
|
||||
{
|
||||
struct siomix_aucat_hdl *hdl = (struct siomix_aucat_hdl *)addr;
|
||||
struct sioctl_aucat_hdl *hdl = (struct sioctl_aucat_hdl *)addr;
|
||||
|
||||
return _aucat_pollfd(&hdl->aucat, pfd, events | POLLIN);
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_aucat_revents(struct siomix_hdl *addr, struct pollfd *pfd)
|
||||
sioctl_aucat_revents(struct sioctl_hdl *addr, struct pollfd *pfd)
|
||||
{
|
||||
struct siomix_aucat_hdl *hdl = (struct siomix_aucat_hdl *)addr;
|
||||
struct sioctl_aucat_hdl *hdl = (struct sioctl_aucat_hdl *)addr;
|
||||
int revents;
|
||||
|
||||
revents = _aucat_revents(&hdl->aucat, pfd);
|
||||
if (revents & POLLIN) {
|
||||
do {
|
||||
if (hdl->aucat.rstate == RSTATE_MSG) {
|
||||
if (!siomix_aucat_runmsg(hdl))
|
||||
if (!sioctl_aucat_runmsg(hdl))
|
||||
break;
|
||||
}
|
||||
if (hdl->aucat.rstate == RSTATE_DATA) {
|
||||
if (!siomix_aucat_rdata(hdl))
|
||||
if (!sioctl_aucat_rdata(hdl))
|
||||
break;
|
||||
}
|
||||
} while (0);
|
||||
revents &= ~POLLIN;
|
||||
}
|
||||
if (hdl->siomix.eof)
|
||||
if (hdl->sioctl.eof)
|
||||
return POLLHUP;
|
||||
DPRINTFN(3, "siomix_aucat_revents: revents = 0x%x\n", revents);
|
||||
DPRINTFN(3, "sioctl_aucat_revents: revents = 0x%x\n", revents);
|
||||
return revents;
|
||||
}
|
|
@ -18,38 +18,37 @@
|
|||
.Dt SIO_OPEN 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm siomix_open ,
|
||||
.Nm siomix_close ,
|
||||
.Nm siomix_ondesc ,
|
||||
.Nm siomix_onctl ,
|
||||
.Nm siomix_setctl ,
|
||||
.Nm siomix_nfds ,
|
||||
.Nm siomix_pollfd ,
|
||||
.Nm siomix_eof
|
||||
.Nd interface to audio mixer
|
||||
.Nm sioctl_open ,
|
||||
.Nm sioctl_close ,
|
||||
.Nm sioctl_ondesc ,
|
||||
.Nm sioctl_onctl ,
|
||||
.Nm sioctl_setctl ,
|
||||
.Nm sioctl_nfds ,
|
||||
.Nm sioctl_pollfd ,
|
||||
.Nm sioctl_eof
|
||||
.Nd interface to audio parameters
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <sndio.h>
|
||||
.Ft "struct siomix_hdl *"
|
||||
.Fn "siomix_open" "const char *name" "unsigned int mode" "int nbio_flag"
|
||||
.Ft "struct sioctl_hdl *"
|
||||
.Fn "sioctl_open" "const char *name" "unsigned int mode" "int nbio_flag"
|
||||
.Ft "void"
|
||||
.Fn "siomix_close" "struct siomix_hdl *hdl"
|
||||
.Fn "sioctl_close" "struct sioctl_hdl *hdl"
|
||||
.Ft "int"
|
||||
.Fn "siomix_ondesc" "struct siomix_hdl *hdl" "void (*cb)(void *arg, struct siomix_desc *desc, int val)" "void *arg"
|
||||
.Fn "sioctl_ondesc" "struct sioctl_hdl *hdl" "void (*cb)(void *arg, struct sioctl_desc *desc, int val)" "void *arg"
|
||||
.Ft "void"
|
||||
.Fn "siomix_onctl" "struct siomix_hdl *hdl" "void (*cb)(void *arg, unsigned int addr, unsigned int val)" "void *arg"
|
||||
.Fn "sioctl_onctl" "struct sioctl_hdl *hdl" "void (*cb)(void *arg, unsigned int addr, unsigned int val)" "void *arg"
|
||||
.Ft "int"
|
||||
.Fn "siomix_setctl" "struct siomix_hdl *hdl" "unsigned int addr" "unsigned int val"
|
||||
.Fn "sioctl_setctl" "struct sioctl_hdl *hdl" "unsigned int addr" "unsigned int val"
|
||||
.Ft "int"
|
||||
.Fn "siomix_nfds" "struct siomix_hdl *hdl"
|
||||
.Fn "sioctl_nfds" "struct sioctl_hdl *hdl"
|
||||
.Ft "int"
|
||||
.Fn "siomix_pollfd" "struct siomix_hdl *hdl" "struct pollfd *pfd" "int events"
|
||||
.Fn "sioctl_pollfd" "struct sioctl_hdl *hdl" "struct pollfd *pfd" "int events"
|
||||
.Ft "int"
|
||||
.Fn "siomix_revents" "struct siomix_hdl *hdl" "struct pollfd *pfd"
|
||||
.Fn "sioctl_revents" "struct sioctl_hdl *hdl" "struct pollfd *pfd"
|
||||
.Ft "int"
|
||||
.Fn "siomix_eof" "struct siomix_hdl *hdl"
|
||||
.Fn "sioctl_eof" "struct sioctl_hdl *hdl"
|
||||
.Sh DESCRIPTION
|
||||
The audio mixer of a sound device is the set of available controls,
|
||||
e.g. the volume control.
|
||||
Audio devices may expose a number of controls, like the playback volume control.
|
||||
Each control has an integer
|
||||
.Em address
|
||||
and an integer
|
||||
|
@ -62,9 +61,9 @@ When values change, asynchronous notifications are sent.
|
|||
.Pp
|
||||
Controls descriptions are available, allowing them to be grouped and
|
||||
represented in a human usable form.
|
||||
.Sh Opening and closing the mixer
|
||||
.Sh Opening and closing the control device
|
||||
First the application must call the
|
||||
.Fn siomix_open
|
||||
.Fn sioctl_open
|
||||
function to obtain a handle
|
||||
that will be passed as the
|
||||
.Ar hdl
|
||||
|
@ -74,92 +73,92 @@ The
|
|||
.Ar name
|
||||
parameter gives the device string discussed in
|
||||
.Xr sndio 7 .
|
||||
In most cases it should be set to SIOMIX_DEVANY to allow
|
||||
In most cases it should be set to SIOCTL_DEVANY to allow
|
||||
the user to select it using the
|
||||
.Ev AUDIODEVICE
|
||||
environment variable.
|
||||
The
|
||||
.Ar mode
|
||||
parameter is a bitmap of the SIOMIX_READ and SIOMIX_WRITE constants
|
||||
parameter is a bitmap of the SIOCTL_READ and SIOCTL_WRITE constants
|
||||
indicating whether control values can be read and
|
||||
modified respectively.
|
||||
.Pp
|
||||
If the
|
||||
.Ar nbio_flag
|
||||
argument is 1, then the
|
||||
.Fn siomix_setctl
|
||||
.Fn sioctl_setctl
|
||||
function (see below) may fail instead of blocking and
|
||||
the
|
||||
.Fn siomix_ondesc
|
||||
.Fn sioctl_ondesc
|
||||
function doesn't block.
|
||||
.Pp
|
||||
The
|
||||
.Fn siomix_close
|
||||
function closes the mixer and frees any allocated resources
|
||||
.Fn sioctl_close
|
||||
function closes the control device and frees any allocated resources
|
||||
associated with the handle.
|
||||
.Sh Mixer description
|
||||
.Sh Controls descriptions
|
||||
The
|
||||
.Fn siomix_ondesc
|
||||
function can be used to obtain the description of all available mixer controls
|
||||
.Fn sioctl_ondesc
|
||||
function can be used to obtain the description of all available controls
|
||||
and their initial values.
|
||||
It registers a call-back that is immediately invoked for all
|
||||
controls.
|
||||
It's called once with a NULL argument to indicate that the full
|
||||
description was sent and that the caller has a consistent
|
||||
representation of the mixer.
|
||||
representation of the controls set.
|
||||
.Pp
|
||||
Then, whenever a mixer control description changes, the call-back is
|
||||
Then, whenever a control description changes, the call-back is
|
||||
invoked with the updated information followed by a call with a NULL
|
||||
argument.
|
||||
.Pp
|
||||
Controls are described by the
|
||||
.Va siomix_ondesc
|
||||
.Va sioctl_ondesc
|
||||
stucture as follows:
|
||||
.Bd -literal
|
||||
struct siomix_chan {
|
||||
char str[SIOMIX_NAMEMAX]; /* stream name */
|
||||
struct sioctl_chan {
|
||||
char str[SIOCTL_NAMEMAX]; /* stream name */
|
||||
int unit; /* optional number */
|
||||
};
|
||||
|
||||
struct siomix_desc {
|
||||
struct sioctl_desc {
|
||||
unsigned int addr; /* control address */
|
||||
#define SIOMIX_NONE 0 /* control deleted */
|
||||
#define SIOMIX_NUM 2 /* integer in the 0..127 range */
|
||||
#define SIOMIX_SW 3 /* on/off switch (0 or 1) */
|
||||
#define SIOMIX_VEC 4 /* number, element of vector */
|
||||
#define SIOMIX_LIST 5 /* switch, element of a list */
|
||||
#define SIOCTL_NONE 0 /* control deleted */
|
||||
#define SIOCTL_NUM 2 /* integer in the 0..127 range */
|
||||
#define SIOCTL_SW 3 /* on/off switch (0 or 1) */
|
||||
#define SIOCTL_VEC 4 /* number, element of vector */
|
||||
#define SIOCTL_LIST 5 /* switch, element of a list */
|
||||
unsigned int type; /* one of above */
|
||||
char func[SIOMIX_NAMEMAX]; /* function name */
|
||||
struct siomix_chan group; /* group this control belongs to */
|
||||
struct siomix_chan chan0; /* affected channels */
|
||||
struct siomix_chan chan1; /* dito for SIOMIX_{VEC,LIST} */
|
||||
char func[SIOCTL_NAMEMAX]; /* function name */
|
||||
struct sioctl_chan group; /* group this control belongs to */
|
||||
struct sioctl_chan chan0; /* affected channels */
|
||||
struct sioctl_chan chan1; /* dito for SIOCTL_{VEC,LIST} */
|
||||
};
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Va addr
|
||||
attribute is the mixer control address, usable with
|
||||
.Fn siomix_setval
|
||||
attribute is the control address, usable with
|
||||
.Fn sioctl_setval
|
||||
to set its value.
|
||||
.Pp
|
||||
The
|
||||
.Va type
|
||||
attribute indicates what the structure describes.
|
||||
Possible types are:
|
||||
.Bl -tag -width "SIOMIX_LIST"
|
||||
.It SIOMIX_NONE
|
||||
.Bl -tag -width "SIOCTL_LIST"
|
||||
.It SIOCTL_NONE
|
||||
A previously valid control was deleted.
|
||||
.It SIOMIX_NUM
|
||||
A continuous control in the 0..SIOMIX_INTMAX range.
|
||||
.It SIOCTL_NUM
|
||||
A continuous control in the 0..SIOCTL_INTMAX range.
|
||||
For instance the volume of the speaker.
|
||||
.It SIOMIX_SW
|
||||
.It SIOCTL_SW
|
||||
A on/off switch control.
|
||||
For instance the switch to mute the speaker.
|
||||
.It SIOMIX_VEC
|
||||
.It SIOCTL_VEC
|
||||
Element of an array of continuous controls.
|
||||
For instance the knob to control the amount of signal flowing
|
||||
from the line input to the speaker.
|
||||
.It SIOMIX_LIST
|
||||
.It SIOCTL_LIST
|
||||
An element of an array of on/off switches.
|
||||
For instance the line-in position of the
|
||||
speaker source selector.
|
||||
|
@ -178,9 +177,9 @@ attributes indicate the names of the affected streams, and
|
|||
an optional channel sub-set.
|
||||
.Va chan1
|
||||
is meaningful for
|
||||
.Va SIOMIX_VEC
|
||||
.Va SIOCTL_VEC
|
||||
and
|
||||
.Va SIOMIX_LIST
|
||||
.Va SIOCTL_LIST
|
||||
only.
|
||||
.Pp
|
||||
Stream names in the
|
||||
|
@ -193,16 +192,16 @@ are strings usable as unique identifiers within the the given
|
|||
.Va namespace .
|
||||
.Sh Changing and reading control values
|
||||
Controls are changed with the
|
||||
.Fn siomix_setctl
|
||||
.Fn sioctl_setctl
|
||||
function, by giving the index of the control and the new value.
|
||||
The
|
||||
.Fn siomix_onctl
|
||||
.Fn sioctl_onctl
|
||||
function can be used to register a call-back which will be invoked whenever
|
||||
a control changes.
|
||||
Continuous values are in the 0..127 range.
|
||||
.Sh "Interface to" Xr poll 2
|
||||
The
|
||||
.Fn siomix_pollfd
|
||||
.Fn sioctl_pollfd
|
||||
function fills the array
|
||||
.Ar pfd
|
||||
of
|
||||
|
@ -216,12 +215,12 @@ the latter is a bit-mask of
|
|||
and
|
||||
.Va POLLOUT
|
||||
constants.
|
||||
.Fn siomix_pollfd
|
||||
.Fn sioctl_pollfd
|
||||
returns the number of
|
||||
.Va pollfd
|
||||
structures filled.
|
||||
The
|
||||
.Fn siomix_revents
|
||||
.Fn sioctl_revents
|
||||
function returns the bit-mask set by
|
||||
.Xr poll 2
|
||||
in the
|
||||
|
@ -232,20 +231,20 @@ structures.
|
|||
If
|
||||
.Va POLLOUT
|
||||
is set,
|
||||
.Fn siomix_setctl
|
||||
.Fn sioctl_setctl
|
||||
can be called without blocking.
|
||||
POLLHUP may be set if an error occurs, even if
|
||||
it is not selected with
|
||||
.Fn siomix_pollfd .
|
||||
.Fn sioctl_pollfd .
|
||||
POLLIN is not used yet.
|
||||
.Pp
|
||||
The
|
||||
.Fn siomix_nfds
|
||||
.Fn sioctl_nfds
|
||||
function returns the number of
|
||||
.Va pollfd
|
||||
structures the caller must preallocate in order to be sure
|
||||
that
|
||||
.Fn siomix_pollfd
|
||||
.Fn sioctl_pollfd
|
||||
will never overrun.
|
||||
.Sh SEE ALSO
|
||||
.Xr sndioctl 1 ,
|
|
@ -0,0 +1,67 @@
|
|||
/* $OpenBSD$ */
|
||||
/*
|
||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef SIOCTL_PRIV_H
|
||||
#define SIOCTL_PRIV_H
|
||||
|
||||
#include <sndio.h>
|
||||
|
||||
#define SIOCTL_MAXNFDS 4
|
||||
|
||||
/*
|
||||
* private ``handle'' structure
|
||||
*/
|
||||
struct sioctl_hdl {
|
||||
struct sioctl_ops *ops;
|
||||
void (*desc_cb)(void *, struct sioctl_desc *, int);
|
||||
void *desc_arg;
|
||||
void (*ctl_cb)(void *, unsigned int, unsigned int);
|
||||
void *ctl_arg;
|
||||
unsigned int mode; /* SIOCTL_READ | SIOCTL_WRITE */
|
||||
int nbio; /* true if non-blocking io */
|
||||
int eof; /* true if error occured */
|
||||
};
|
||||
|
||||
/*
|
||||
* operations every device should support
|
||||
*/
|
||||
struct sioctl_ops {
|
||||
void (*close)(struct sioctl_hdl *);
|
||||
int (*nfds)(struct sioctl_hdl *);
|
||||
int (*pollfd)(struct sioctl_hdl *, struct pollfd *, int);
|
||||
int (*revents)(struct sioctl_hdl *, struct pollfd *);
|
||||
int (*setctl)(struct sioctl_hdl *, unsigned int, unsigned int);
|
||||
int (*onctl)(struct sioctl_hdl *);
|
||||
int (*ondesc)(struct sioctl_hdl *);
|
||||
};
|
||||
|
||||
struct sioctl_hdl *_sioctl_aucat_open(const char *, unsigned int, int);
|
||||
struct sioctl_hdl *_sioctl_obsd_open(const char *, unsigned int, int);
|
||||
struct sioctl_hdl *_sioctl_fake_open(const char *, unsigned int, int);
|
||||
#ifdef USE_SUN_MIXER
|
||||
struct sioctl_hdl *_sioctl_sun_open(const char *, unsigned int, int);
|
||||
#endif
|
||||
#ifdef USE_ALSA_MIXER
|
||||
struct sioctl_hdl *_sioctl_alsa_open(const char *, unsigned int, int);
|
||||
#endif
|
||||
void _sioctl_create(struct sioctl_hdl *,
|
||||
struct sioctl_ops *, unsigned int, int);
|
||||
void _sioctl_ondesc_cb(struct sioctl_hdl *,
|
||||
struct sioctl_desc *, unsigned int);
|
||||
void _sioctl_onctl_cb(struct sioctl_hdl *, unsigned int, unsigned int);
|
||||
int _sioctl_psleep(struct sioctl_hdl *, int);
|
||||
|
||||
#endif /* !defined(SIOCTL_PRIV_H) */
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
/*
|
||||
* the way the sun mixer is designed doesn't let us representing
|
||||
* it easily with the siomix api. For now expose only few
|
||||
* it easily with the sioctl api. For now expose only few
|
||||
* white-listed controls the same way as we do in kernel
|
||||
* for the wskbd volume keys.
|
||||
*/
|
||||
|
@ -34,7 +34,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "siomix_priv.h"
|
||||
#include "sioctl_priv.h"
|
||||
#include "bsd-compat.h"
|
||||
|
||||
#define DEVPATH_PREFIX "/dev/mixer"
|
||||
|
@ -42,8 +42,8 @@
|
|||
sizeof(DEVPATH_PREFIX) - 1 + \
|
||||
sizeof(int) * 3)
|
||||
|
||||
#define SUN_TO_SIOMIX(v) (((v) * 127 + 127) / 255)
|
||||
#define SIOMIX_TO_SUN(v) (((v) * 255 + 63) / 127)
|
||||
#define SUN_TO_SIOCTL(v) (((v) * 127 + 127) / 255)
|
||||
#define SIOCTL_TO_SUN(v) (((v) * 255 + 63) / 127)
|
||||
|
||||
struct wskbd_vol
|
||||
{
|
||||
|
@ -56,35 +56,35 @@ struct wskbd_vol
|
|||
char *name;
|
||||
};
|
||||
|
||||
struct siomix_sun_hdl {
|
||||
struct siomix_hdl siomix;
|
||||
struct sioctl_sun_hdl {
|
||||
struct sioctl_hdl sioctl;
|
||||
struct wskbd_vol spkr, mic;
|
||||
int fd, events;
|
||||
};
|
||||
|
||||
static void siomix_sun_close(struct siomix_hdl *);
|
||||
static int siomix_sun_nfds(struct siomix_hdl *);
|
||||
static int siomix_sun_pollfd(struct siomix_hdl *, struct pollfd *, int);
|
||||
static int siomix_sun_revents(struct siomix_hdl *, struct pollfd *);
|
||||
static int siomix_sun_setctl(struct siomix_hdl *, unsigned int, unsigned int);
|
||||
static int siomix_sun_onctl(struct siomix_hdl *);
|
||||
static int siomix_sun_ondesc(struct siomix_hdl *);
|
||||
static void sioctl_sun_close(struct sioctl_hdl *);
|
||||
static int sioctl_sun_nfds(struct sioctl_hdl *);
|
||||
static int sioctl_sun_pollfd(struct sioctl_hdl *, struct pollfd *, int);
|
||||
static int sioctl_sun_revents(struct sioctl_hdl *, struct pollfd *);
|
||||
static int sioctl_sun_setctl(struct sioctl_hdl *, unsigned int, unsigned int);
|
||||
static int sioctl_sun_onctl(struct sioctl_hdl *);
|
||||
static int sioctl_sun_ondesc(struct sioctl_hdl *);
|
||||
|
||||
/*
|
||||
* operations every device should support
|
||||
*/
|
||||
struct siomix_ops siomix_sun_ops = {
|
||||
siomix_sun_close,
|
||||
siomix_sun_nfds,
|
||||
siomix_sun_pollfd,
|
||||
siomix_sun_revents,
|
||||
siomix_sun_setctl,
|
||||
siomix_sun_onctl,
|
||||
siomix_sun_ondesc
|
||||
struct sioctl_ops sioctl_sun_ops = {
|
||||
sioctl_sun_close,
|
||||
sioctl_sun_nfds,
|
||||
sioctl_sun_pollfd,
|
||||
sioctl_sun_revents,
|
||||
sioctl_sun_setctl,
|
||||
sioctl_sun_onctl,
|
||||
sioctl_sun_ondesc
|
||||
};
|
||||
|
||||
static int
|
||||
initmute(struct siomix_sun_hdl *hdl, struct mixer_devinfo *info)
|
||||
initmute(struct sioctl_sun_hdl *hdl, struct mixer_devinfo *info)
|
||||
{
|
||||
struct mixer_devinfo mi;
|
||||
|
||||
|
@ -99,7 +99,7 @@ initmute(struct siomix_sun_hdl *hdl, struct mixer_devinfo *info)
|
|||
}
|
||||
|
||||
static int
|
||||
initvol(struct siomix_sun_hdl *hdl, struct wskbd_vol *vol, char *cn, char *dn)
|
||||
initvol(struct sioctl_sun_hdl *hdl, struct wskbd_vol *vol, char *cn, char *dn)
|
||||
{
|
||||
struct mixer_devinfo dev, cls;
|
||||
|
||||
|
@ -126,7 +126,7 @@ initvol(struct siomix_sun_hdl *hdl, struct wskbd_vol *vol, char *cn, char *dn)
|
|||
}
|
||||
|
||||
static void
|
||||
init(struct siomix_sun_hdl *hdl)
|
||||
init(struct sioctl_sun_hdl *hdl)
|
||||
{
|
||||
static struct {
|
||||
char *cn, *dn;
|
||||
|
@ -163,7 +163,7 @@ init(struct siomix_sun_hdl *hdl)
|
|||
}
|
||||
|
||||
static int
|
||||
setvol(struct siomix_sun_hdl *hdl, struct wskbd_vol *vol, int addr, int val)
|
||||
setvol(struct sioctl_sun_hdl *hdl, struct wskbd_vol *vol, int addr, int val)
|
||||
{
|
||||
struct mixer_ctrl ctrl;
|
||||
int i;
|
||||
|
@ -180,14 +180,14 @@ setvol(struct siomix_sun_hdl *hdl, struct wskbd_vol *vol, int addr, int val)
|
|||
ctrl.un.value.num_channels = vol->nch;
|
||||
for (i = 0; i < vol->nch; i++) {
|
||||
ctrl.un.value.level[i] =
|
||||
SIOMIX_TO_SUN(vol->level_val[i]);
|
||||
SIOCTL_TO_SUN(vol->level_val[i]);
|
||||
}
|
||||
DPRINTF("vol %d setting to %d\n", addr, vol->level_val[addr]);
|
||||
if (ioctl(hdl->fd, AUDIO_MIXER_WRITE, &ctrl) < 0) {
|
||||
DPRINTF("level write failed\n");
|
||||
return 0;
|
||||
}
|
||||
_siomix_onctl_cb(&hdl->siomix, vol->base_addr + addr, val);
|
||||
_sioctl_onctl_cb(&hdl->sioctl, vol->base_addr + addr, val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ setvol(struct siomix_sun_hdl *hdl, struct wskbd_vol *vol, int addr, int val)
|
|||
return 0;
|
||||
}
|
||||
for (i = 0; i < vol->nch; i++) {
|
||||
_siomix_onctl_cb(&hdl->siomix,
|
||||
_sioctl_onctl_cb(&hdl->sioctl,
|
||||
vol->base_addr + 32 + i, val);
|
||||
}
|
||||
return 1;
|
||||
|
@ -217,13 +217,13 @@ setvol(struct siomix_sun_hdl *hdl, struct wskbd_vol *vol, int addr, int val)
|
|||
}
|
||||
|
||||
static int
|
||||
scanvol(struct siomix_sun_hdl *hdl, struct wskbd_vol *vol)
|
||||
scanvol(struct sioctl_sun_hdl *hdl, struct wskbd_vol *vol)
|
||||
{
|
||||
struct siomix_desc desc;
|
||||
struct sioctl_desc desc;
|
||||
struct mixer_ctrl ctrl;
|
||||
int i, val;
|
||||
|
||||
memset(&desc, 0, sizeof(struct siomix_desc));
|
||||
memset(&desc, 0, sizeof(struct sioctl_desc));
|
||||
strlcpy(desc.group.str, "hw", sizeof(desc.group.str));
|
||||
desc.group.unit = -1;
|
||||
if (vol->level_idx >= 0) {
|
||||
|
@ -234,17 +234,17 @@ scanvol(struct siomix_sun_hdl *hdl, struct wskbd_vol *vol)
|
|||
DPRINTF("level read failed\n");
|
||||
return 0;
|
||||
}
|
||||
desc.type = SIOMIX_NUM;
|
||||
desc.type = SIOCTL_NUM;
|
||||
desc.chan1.str[0] = 0;
|
||||
desc.chan1.unit = -1;
|
||||
strlcpy(desc.func, "level", SIOMIX_NAMEMAX);
|
||||
strlcpy(desc.chan0.str, vol->name, SIOMIX_NAMEMAX);
|
||||
strlcpy(desc.func, "level", SIOCTL_NAMEMAX);
|
||||
strlcpy(desc.chan0.str, vol->name, SIOCTL_NAMEMAX);
|
||||
for (i = 0; i < vol->nch; i++) {
|
||||
desc.chan0.unit = i;
|
||||
desc.addr = vol->base_addr + i;
|
||||
val = SUN_TO_SIOMIX(ctrl.un.value.level[i]);
|
||||
val = SUN_TO_SIOCTL(ctrl.un.value.level[i]);
|
||||
vol->level_val[i] = val;
|
||||
_siomix_ondesc_cb(&hdl->siomix, &desc, val);
|
||||
_sioctl_ondesc_cb(&hdl->sioctl, &desc, val);
|
||||
}
|
||||
}
|
||||
if (vol->mute_idx >= 0) {
|
||||
|
@ -254,24 +254,24 @@ scanvol(struct siomix_sun_hdl *hdl, struct wskbd_vol *vol)
|
|||
DPRINTF("mute read failed\n");
|
||||
return 0;
|
||||
}
|
||||
desc.type = SIOMIX_SW;
|
||||
desc.type = SIOCTL_SW;
|
||||
desc.chan1.str[0] = 0;
|
||||
desc.chan1.unit = -1;
|
||||
strlcpy(desc.func, "mute", SIOMIX_NAMEMAX);
|
||||
strlcpy(desc.chan0.str, vol->name, SIOMIX_NAMEMAX);
|
||||
strlcpy(desc.func, "mute", SIOCTL_NAMEMAX);
|
||||
strlcpy(desc.chan0.str, vol->name, SIOCTL_NAMEMAX);
|
||||
val = ctrl.un.ord ? 1 : 0;
|
||||
vol->mute_val = val;
|
||||
for (i = 0; i < vol->nch; i++) {
|
||||
desc.chan0.unit = i;
|
||||
desc.addr = vol->base_addr + 32 + i;
|
||||
_siomix_ondesc_cb(&hdl->siomix, &desc, val);
|
||||
_sioctl_ondesc_cb(&hdl->sioctl, &desc, val);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
siomix_sun_getfd(const char *str, unsigned int mode, int nbio)
|
||||
sioctl_sun_getfd(const char *str, unsigned int mode, int nbio)
|
||||
{
|
||||
const char *p;
|
||||
char path[DEVPATH_MAX];
|
||||
|
@ -283,7 +283,7 @@ siomix_sun_getfd(const char *str, unsigned int mode, int nbio)
|
|||
#endif
|
||||
p = _sndio_parsetype(str, "rsnd");
|
||||
if (p == NULL) {
|
||||
DPRINTF("siomix_sun_getfd: %s: \"rsnd\" expected\n", str);
|
||||
DPRINTF("sioctl_sun_getfd: %s: \"rsnd\" expected\n", str);
|
||||
return -1;
|
||||
}
|
||||
switch (*p) {
|
||||
|
@ -291,19 +291,19 @@ siomix_sun_getfd(const char *str, unsigned int mode, int nbio)
|
|||
p++;
|
||||
break;
|
||||
default:
|
||||
DPRINTF("siomix_sun_getfd: %s: '/' expected\n", str);
|
||||
DPRINTF("sioctl_sun_getfd: %s: '/' expected\n", str);
|
||||
return -1;
|
||||
}
|
||||
p = _sndio_parsenum(p, &devnum, 255);
|
||||
if (p == NULL || *p != '\0') {
|
||||
DPRINTF("siomix_sun_getfd: %s: number expected after '/'\n", str);
|
||||
DPRINTF("sioctl_sun_getfd: %s: number expected after '/'\n", str);
|
||||
return -1;
|
||||
}
|
||||
snprintf(path, sizeof(path), DEVPATH_PREFIX "%u", devnum);
|
||||
if (mode == (SIOMIX_READ | SIOMIX_WRITE))
|
||||
if (mode == (SIOCTL_READ | SIOCTL_WRITE))
|
||||
flags = O_RDWR;
|
||||
else
|
||||
flags = (mode & SIOMIX_WRITE) ? O_WRONLY : O_RDONLY;
|
||||
flags = (mode & SIOCTL_WRITE) ? O_WRONLY : O_RDONLY;
|
||||
while ((fd = open(path, flags | O_NONBLOCK | O_CLOEXEC)) < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
@ -313,33 +313,33 @@ siomix_sun_getfd(const char *str, unsigned int mode, int nbio)
|
|||
return fd;
|
||||
}
|
||||
|
||||
struct siomix_hdl *
|
||||
siomix_sun_fdopen(int fd, unsigned int mode, int nbio)
|
||||
struct sioctl_hdl *
|
||||
sioctl_sun_fdopen(int fd, unsigned int mode, int nbio)
|
||||
{
|
||||
struct siomix_sun_hdl *hdl;
|
||||
struct sioctl_sun_hdl *hdl;
|
||||
|
||||
#ifdef DEBUG
|
||||
_sndio_debug_init();
|
||||
#endif
|
||||
hdl = malloc(sizeof(struct siomix_sun_hdl));
|
||||
hdl = malloc(sizeof(struct sioctl_sun_hdl));
|
||||
if (hdl == NULL)
|
||||
return NULL;
|
||||
_siomix_create(&hdl->siomix, &siomix_sun_ops, mode, nbio);
|
||||
_sioctl_create(&hdl->sioctl, &sioctl_sun_ops, mode, nbio);
|
||||
hdl->fd = fd;
|
||||
init(hdl);
|
||||
return (struct siomix_hdl *)hdl;
|
||||
return (struct sioctl_hdl *)hdl;
|
||||
}
|
||||
|
||||
struct siomix_hdl *
|
||||
_siomix_sun_open(const char *str, unsigned int mode, int nbio)
|
||||
struct sioctl_hdl *
|
||||
_sioctl_sun_open(const char *str, unsigned int mode, int nbio)
|
||||
{
|
||||
struct siomix_hdl *hdl;
|
||||
struct sioctl_hdl *hdl;
|
||||
int fd;
|
||||
|
||||
fd = siomix_sun_getfd(str, mode, nbio);
|
||||
fd = sioctl_sun_getfd(str, mode, nbio);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
hdl = siomix_sun_fdopen(fd, mode, nbio);
|
||||
hdl = sioctl_sun_fdopen(fd, mode, nbio);
|
||||
if (hdl != NULL)
|
||||
return hdl;
|
||||
while (close(fd) < 0 && errno == EINTR)
|
||||
|
@ -348,66 +348,66 @@ _siomix_sun_open(const char *str, unsigned int mode, int nbio)
|
|||
}
|
||||
|
||||
static void
|
||||
siomix_sun_close(struct siomix_hdl *addr)
|
||||
sioctl_sun_close(struct sioctl_hdl *addr)
|
||||
{
|
||||
struct siomix_sun_hdl *hdl = (struct siomix_sun_hdl *)addr;
|
||||
struct sioctl_sun_hdl *hdl = (struct sioctl_sun_hdl *)addr;
|
||||
|
||||
close(hdl->fd);
|
||||
free(hdl);
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_sun_ondesc(struct siomix_hdl *addr)
|
||||
sioctl_sun_ondesc(struct sioctl_hdl *addr)
|
||||
{
|
||||
struct siomix_sun_hdl *hdl = (struct siomix_sun_hdl *)addr;
|
||||
struct sioctl_sun_hdl *hdl = (struct sioctl_sun_hdl *)addr;
|
||||
|
||||
if (!scanvol(hdl, &hdl->spkr) ||
|
||||
!scanvol(hdl, &hdl->mic)) {
|
||||
hdl->siomix.eof = 1;
|
||||
hdl->sioctl.eof = 1;
|
||||
return 0;
|
||||
}
|
||||
_siomix_ondesc_cb(&hdl->siomix, NULL, 0);
|
||||
_sioctl_ondesc_cb(&hdl->sioctl, NULL, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_sun_onctl(struct siomix_hdl *addr)
|
||||
sioctl_sun_onctl(struct sioctl_hdl *addr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_sun_setctl(struct siomix_hdl *arg, unsigned int addr, unsigned int val)
|
||||
sioctl_sun_setctl(struct sioctl_hdl *arg, unsigned int addr, unsigned int val)
|
||||
{
|
||||
struct siomix_sun_hdl *hdl = (struct siomix_sun_hdl *)arg;
|
||||
struct sioctl_sun_hdl *hdl = (struct sioctl_sun_hdl *)arg;
|
||||
|
||||
if (!setvol(hdl, &hdl->spkr, addr, val) ||
|
||||
!setvol(hdl, &hdl->mic, addr, val)) {
|
||||
hdl->siomix.eof = 1;
|
||||
hdl->sioctl.eof = 1;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_sun_nfds(struct siomix_hdl *addr)
|
||||
sioctl_sun_nfds(struct sioctl_hdl *addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_sun_pollfd(struct siomix_hdl *addr, struct pollfd *pfd, int events)
|
||||
sioctl_sun_pollfd(struct sioctl_hdl *addr, struct pollfd *pfd, int events)
|
||||
{
|
||||
struct siomix_sun_hdl *hdl = (struct siomix_sun_hdl *)addr;
|
||||
struct sioctl_sun_hdl *hdl = (struct sioctl_sun_hdl *)addr;
|
||||
|
||||
hdl->events = events;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
siomix_sun_revents(struct siomix_hdl *addr, struct pollfd *pfd)
|
||||
sioctl_sun_revents(struct sioctl_hdl *addr, struct pollfd *pfd)
|
||||
{
|
||||
struct siomix_sun_hdl *hdl = (struct siomix_sun_hdl *)addr;
|
||||
struct sioctl_sun_hdl *hdl = (struct sioctl_sun_hdl *)addr;
|
||||
|
||||
return hdl->events & POLLOUT;
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/* $OpenBSD$ */
|
||||
/*
|
||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef SIOMIX_PRIV_H
|
||||
#define SIOMIX_PRIV_H
|
||||
|
||||
#include <sndio.h>
|
||||
|
||||
#define SIOMIX_MAXNFDS 4
|
||||
|
||||
/*
|
||||
* private ``handle'' structure
|
||||
*/
|
||||
struct siomix_hdl {
|
||||
struct siomix_ops *ops;
|
||||
void (*desc_cb)(void *, struct siomix_desc *, int);
|
||||
void *desc_arg;
|
||||
void (*ctl_cb)(void *, unsigned int, unsigned int);
|
||||
void *ctl_arg;
|
||||
unsigned int mode; /* SIOMIX_READ | SIOMIX_WRITE */
|
||||
int nbio; /* true if non-blocking io */
|
||||
int eof; /* true if error occured */
|
||||
};
|
||||
|
||||
/*
|
||||
* operations every device should support
|
||||
*/
|
||||
struct siomix_ops {
|
||||
void (*close)(struct siomix_hdl *);
|
||||
int (*nfds)(struct siomix_hdl *);
|
||||
int (*pollfd)(struct siomix_hdl *, struct pollfd *, int);
|
||||
int (*revents)(struct siomix_hdl *, struct pollfd *);
|
||||
int (*setctl)(struct siomix_hdl *, unsigned int, unsigned int);
|
||||
int (*onctl)(struct siomix_hdl *);
|
||||
int (*ondesc)(struct siomix_hdl *);
|
||||
};
|
||||
|
||||
struct siomix_hdl *_siomix_aucat_open(const char *, unsigned int, int);
|
||||
struct siomix_hdl *_siomix_obsd_open(const char *, unsigned int, int);
|
||||
struct siomix_hdl *_siomix_fake_open(const char *, unsigned int, int);
|
||||
#ifdef USE_SUN_MIXER
|
||||
struct siomix_hdl *_siomix_sun_open(const char *, unsigned int, int);
|
||||
#endif
|
||||
#ifdef USE_ALSA_MIXER
|
||||
struct siomix_hdl *_siomix_alsa_open(const char *, unsigned int, int);
|
||||
#endif
|
||||
void _siomix_create(struct siomix_hdl *,
|
||||
struct siomix_ops *, unsigned int, int);
|
||||
void _siomix_ondesc_cb(struct siomix_hdl *,
|
||||
struct siomix_desc *, unsigned int);
|
||||
void _siomix_onctl_cb(struct siomix_hdl *, unsigned int, unsigned int);
|
||||
int _siomix_psleep(struct siomix_hdl *, int);
|
||||
|
||||
#endif /* !defined(SIOMIX_PRIV_H) */
|
|
@ -24,21 +24,21 @@
|
|||
*/
|
||||
#define SIO_DEVANY "default"
|
||||
#define MIO_PORTANY "default"
|
||||
#define SIOMIX_DEVANY "default"
|
||||
#define SIOCTL_DEVANY "default"
|
||||
|
||||
/*
|
||||
* limits
|
||||
*/
|
||||
#define SIOMIX_NAMEMAX 12 /* max name length */
|
||||
#define SIOMIX_INTMAX 127 /* max channel number */
|
||||
#define SIOMIX_HALF 64 /* also bool threshold */
|
||||
#define SIOCTL_NAMEMAX 12 /* max name length */
|
||||
#define SIOCTL_INTMAX 127 /* max channel number */
|
||||
#define SIOCTL_HALF 64 /* also bool threshold */
|
||||
|
||||
/*
|
||||
* private ``handle'' structure
|
||||
*/
|
||||
struct sio_hdl;
|
||||
struct mio_hdl;
|
||||
struct siomix_hdl;
|
||||
struct sioctl_hdl;
|
||||
|
||||
/*
|
||||
* parameters of a full-duplex stream
|
||||
|
@ -96,26 +96,26 @@ struct sio_cap {
|
|||
/*
|
||||
* subset of channels of a stream
|
||||
*/
|
||||
struct siomix_chan {
|
||||
char str[SIOMIX_NAMEMAX]; /* stream name */
|
||||
struct sioctl_chan {
|
||||
char str[SIOCTL_NAMEMAX]; /* stream name */
|
||||
int unit; /* optional stream number */
|
||||
};
|
||||
|
||||
/*
|
||||
* description of a control (index, value) pair
|
||||
*/
|
||||
struct siomix_desc {
|
||||
struct sioctl_desc {
|
||||
unsigned int addr; /* control address */
|
||||
#define SIOMIX_NONE 0 /* deleted */
|
||||
#define SIOMIX_NUM 2 /* integer in the 0..127 range */
|
||||
#define SIOMIX_SW 3 /* on/off switch (0 or 1) */
|
||||
#define SIOMIX_VEC 4 /* number, element of vector */
|
||||
#define SIOMIX_LIST 5 /* switch, element of a list */
|
||||
#define SIOCTL_NONE 0 /* deleted */
|
||||
#define SIOCTL_NUM 2 /* integer in the 0..127 range */
|
||||
#define SIOCTL_SW 3 /* on/off switch (0 or 1) */
|
||||
#define SIOCTL_VEC 4 /* number, element of vector */
|
||||
#define SIOCTL_LIST 5 /* switch, element of a list */
|
||||
unsigned int type; /* one of above */
|
||||
char func[SIOMIX_NAMEMAX]; /* function name */
|
||||
struct siomix_chan group; /* group this control belongs to */
|
||||
struct siomix_chan chan0; /* affected channels */
|
||||
struct siomix_chan chan1; /* dito for SIOMIX_{VEC,LIST} */
|
||||
char func[SIOCTL_NAMEMAX]; /* function name */
|
||||
struct sioctl_chan group; /* group this control belongs to */
|
||||
struct sioctl_chan chan0; /* affected channels */
|
||||
struct sioctl_chan chan1; /* dito for SIOCTL_{VEC,LIST} */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -125,8 +125,8 @@ struct siomix_desc {
|
|||
#define SIO_REC 2
|
||||
#define MIO_OUT 4
|
||||
#define MIO_IN 8
|
||||
#define SIOMIX_READ 0x100
|
||||
#define SIOMIX_WRITE 0x200
|
||||
#define SIOCTL_READ 0x100
|
||||
#define SIOCTL_WRITE 0x200
|
||||
|
||||
/*
|
||||
* default bytes per sample for the given bits per sample
|
||||
|
@ -180,24 +180,24 @@ int mio_pollfd(struct mio_hdl *, struct pollfd *, int);
|
|||
int mio_revents(struct mio_hdl *, struct pollfd *);
|
||||
int mio_eof(struct mio_hdl *);
|
||||
|
||||
struct siomix_hdl *siomix_open(const char *, unsigned int, int);
|
||||
void siomix_close(struct siomix_hdl *);
|
||||
int siomix_ondesc(struct siomix_hdl *,
|
||||
void (*)(void *, struct siomix_desc *, int), void *);
|
||||
int siomix_onctl(struct siomix_hdl *,
|
||||
struct sioctl_hdl *sioctl_open(const char *, unsigned int, int);
|
||||
void sioctl_close(struct sioctl_hdl *);
|
||||
int sioctl_ondesc(struct sioctl_hdl *,
|
||||
void (*)(void *, struct sioctl_desc *, int), void *);
|
||||
int sioctl_onctl(struct sioctl_hdl *,
|
||||
void (*)(void *, unsigned int, unsigned int), void *);
|
||||
int siomix_setctl(struct siomix_hdl *, unsigned int, unsigned int);
|
||||
int siomix_nfds(struct siomix_hdl *);
|
||||
int siomix_pollfd(struct siomix_hdl *, struct pollfd *, int);
|
||||
int siomix_revents(struct siomix_hdl *, struct pollfd *);
|
||||
int siomix_eof(struct siomix_hdl *);
|
||||
int sioctl_setctl(struct sioctl_hdl *, unsigned int, unsigned int);
|
||||
int sioctl_nfds(struct sioctl_hdl *);
|
||||
int sioctl_pollfd(struct sioctl_hdl *, struct pollfd *, int);
|
||||
int sioctl_revents(struct sioctl_hdl *, struct pollfd *);
|
||||
int sioctl_eof(struct sioctl_hdl *);
|
||||
|
||||
int mio_rmidi_getfd(const char *, unsigned int, int);
|
||||
struct mio_hdl *mio_rmidi_fdopen(int, unsigned int, int);
|
||||
int sio_sun_getfd(const char *, unsigned int, int);
|
||||
struct sio_hdl *sio_sun_fdopen(int, unsigned int, int);
|
||||
int siomix_sun_getfd(const char *, unsigned int, int);
|
||||
struct siomix_hdl *siomix_sun_fdopen(int, unsigned int, int);
|
||||
int sioctl_sun_getfd(const char *, unsigned int, int);
|
||||
struct sioctl_hdl *sioctl_sun_fdopen(int, unsigned int, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
.Os
|
||||
.Sh NAME
|
||||
.Nm sndioctl
|
||||
.Nd control audio mixer parameters
|
||||
.Nd control audio parameters
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Bk -words
|
||||
|
@ -34,7 +34,7 @@
|
|||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility can display or change mixer parameters of
|
||||
utility can display or change parameters of
|
||||
.Xr sndio 7
|
||||
audio devices.
|
||||
The options are as follows:
|
||||
|
@ -42,14 +42,14 @@ The options are as follows:
|
|||
.It Fl d
|
||||
Dump the raw list of available parameters and exit.
|
||||
Useful to debug device drivers or programs using the
|
||||
.Xr siomix_open 3
|
||||
.Xr sioctl_open 3
|
||||
interface.
|
||||
.It Fl f Ar device
|
||||
Use this
|
||||
.Xr sndio 7
|
||||
mixer device.
|
||||
audio device.
|
||||
.It Fl m
|
||||
Monitor and display mixer changes.
|
||||
Monitor and display audio parameters changes.
|
||||
.It Fl i
|
||||
Display characteristics of requested parameters
|
||||
instead of their values.
|
||||
|
@ -68,7 +68,7 @@ Unless
|
|||
or
|
||||
.Fl i
|
||||
are used, displayed parameters are valid commands.
|
||||
The set of available controls depends on the mixer device.
|
||||
The set of available controls depends on the control device.
|
||||
.Pp
|
||||
Commands use the following two formats to display and set
|
||||
parameters respectively:
|
||||
|
@ -137,7 +137,7 @@ Numbers are specified as discussed above.
|
|||
Note that a vector of switches is equivalent to
|
||||
a list.
|
||||
.Sh SEE ALSO
|
||||
.Xr siomix_open 3
|
||||
.Xr sioctl_open 3
|
||||
.Sh EXAMPLES
|
||||
The following will set all
|
||||
.Ar level
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
struct info {
|
||||
struct info *next;
|
||||
struct siomix_desc desc;
|
||||
struct sioctl_desc desc;
|
||||
unsigned ctladdr;
|
||||
#define MODE_IGNORE 0 /* ignore this value */
|
||||
#define MODE_PRINT 1 /* print-only, don't change value */
|
||||
|
@ -40,7 +40,7 @@ struct info {
|
|||
int curval, newval;
|
||||
};
|
||||
|
||||
int cmpdesc(struct siomix_desc *, struct siomix_desc *);
|
||||
int cmpdesc(struct sioctl_desc *, struct sioctl_desc *);
|
||||
int isdiag(struct info *);
|
||||
struct info *selpos(struct info *);
|
||||
struct info *vecent(struct info *, char *, int);
|
||||
|
@ -51,7 +51,7 @@ struct info *nextent(struct info *, int);
|
|||
int matchpar(struct info *, char *, int);
|
||||
int matchent(struct info *, char *, int);
|
||||
int ismono(struct info *);
|
||||
void print_chan(struct siomix_chan *, int);
|
||||
void print_chan(struct sioctl_chan *, int);
|
||||
void print_desc(struct info *, int);
|
||||
void print_val(struct info *, int);
|
||||
void print_par(struct info *, int, char *);
|
||||
|
@ -63,18 +63,18 @@ void dump(void);
|
|||
int cmd(char *);
|
||||
void commit(void);
|
||||
void list(void);
|
||||
void ondesc(void *, struct siomix_desc *, int);
|
||||
void ondesc(void *, struct sioctl_desc *, int);
|
||||
void onctl(void *, unsigned, unsigned);
|
||||
|
||||
struct siomix_hdl *hdl;
|
||||
struct sioctl_hdl *hdl;
|
||||
struct info *infolist;
|
||||
int i_flag = 0, v_flag = 0, m_flag = 0;
|
||||
|
||||
/*
|
||||
* compare two siomix_desc structures, used to sort infolist
|
||||
* compare two sioctl_desc structures, used to sort infolist
|
||||
*/
|
||||
int
|
||||
cmpdesc(struct siomix_desc *d1, struct siomix_desc *d2)
|
||||
cmpdesc(struct sioctl_desc *d1, struct sioctl_desc *d2)
|
||||
{
|
||||
int res;
|
||||
|
||||
|
@ -94,8 +94,8 @@ cmpdesc(struct siomix_desc *d1, struct siomix_desc *d2)
|
|||
if (res != 0)
|
||||
return res;
|
||||
res = d1->chan0.unit - d2->chan0.unit;
|
||||
if (d1->type == SIOMIX_VEC ||
|
||||
d1->type == SIOMIX_LIST) {
|
||||
if (d1->type == SIOCTL_VEC ||
|
||||
d1->type == SIOCTL_LIST) {
|
||||
if (res != 0)
|
||||
return res;
|
||||
res = strcmp(d1->chan1.str, d2->chan1.str);
|
||||
|
@ -128,7 +128,7 @@ selpos(struct info *i)
|
|||
return i;
|
||||
i = i->next;
|
||||
}
|
||||
fprintf(stderr, "selpos: not found, bogus mixer\n");
|
||||
fprintf(stderr, "selpos: not found, bogus control\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -284,15 +284,15 @@ ismono(struct info *g)
|
|||
|
||||
p1 = g;
|
||||
switch (g->desc.type) {
|
||||
case SIOMIX_NUM:
|
||||
case SIOMIX_SW:
|
||||
case SIOCTL_NUM:
|
||||
case SIOCTL_SW:
|
||||
for (p2 = g; p2 != NULL; p2 = nextpar(p2)) {
|
||||
if (p2->curval != p1->curval)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case SIOMIX_VEC:
|
||||
case SIOMIX_LIST:
|
||||
case SIOCTL_VEC:
|
||||
case SIOCTL_LIST:
|
||||
for (p2 = g; p2 != NULL; p2 = nextpar(p2)) {
|
||||
for (e2 = p2; e2 != NULL; e2 = nextent(e2, 0)) {
|
||||
if (!isdiag(e2)) {
|
||||
|
@ -318,7 +318,7 @@ ismono(struct info *g)
|
|||
* print a sub-stream, eg. "spkr[4-7]"
|
||||
*/
|
||||
void
|
||||
print_chan(struct siomix_chan *c, int mono)
|
||||
print_chan(struct sioctl_chan *c, int mono)
|
||||
{
|
||||
printf("%s", c->str);
|
||||
if (!mono && c->unit >= 0) {
|
||||
|
@ -336,12 +336,12 @@ print_desc(struct info *p, int mono)
|
|||
int more;
|
||||
|
||||
switch (p->desc.type) {
|
||||
case SIOMIX_NUM:
|
||||
case SIOMIX_SW:
|
||||
case SIOCTL_NUM:
|
||||
case SIOCTL_SW:
|
||||
printf("*");
|
||||
break;
|
||||
case SIOMIX_VEC:
|
||||
case SIOMIX_LIST:
|
||||
case SIOCTL_VEC:
|
||||
case SIOCTL_LIST:
|
||||
more = 0;
|
||||
for (e = p; e != NULL; e = nextent(e, mono)) {
|
||||
if (mono) {
|
||||
|
@ -369,12 +369,12 @@ print_val(struct info *p, int mono)
|
|||
int more;
|
||||
|
||||
switch (p->desc.type) {
|
||||
case SIOMIX_NUM:
|
||||
case SIOMIX_SW:
|
||||
case SIOCTL_NUM:
|
||||
case SIOCTL_SW:
|
||||
printf("%u", p->curval);
|
||||
break;
|
||||
case SIOMIX_VEC:
|
||||
case SIOMIX_LIST:
|
||||
case SIOCTL_VEC:
|
||||
case SIOCTL_LIST:
|
||||
more = 0;
|
||||
for (e = p; e != NULL; e = nextent(e, mono)) {
|
||||
if (mono) {
|
||||
|
@ -429,8 +429,8 @@ parse_name(char **line, char *name)
|
|||
return 0;
|
||||
}
|
||||
while (IS_IDENT(*p)) {
|
||||
if (len >= SIOMIX_NAMEMAX - 1) {
|
||||
name[SIOMIX_NAMEMAX - 1] = '\0';
|
||||
if (len >= SIOCTL_NAMEMAX - 1) {
|
||||
name[SIOCTL_NAMEMAX - 1] = '\0';
|
||||
fprintf(stderr, "%s...: too long\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
@ -448,8 +448,8 @@ parse_name(char **line, char *name)
|
|||
int
|
||||
parse_dec(char **line, int *num)
|
||||
{
|
||||
#define MAXQ (SIOMIX_INTMAX / 10)
|
||||
#define MAXR (SIOMIX_INTMAX % 10)
|
||||
#define MAXQ (SIOCTL_INTMAX / 10)
|
||||
#define MAXR (SIOCTL_INTMAX % 10)
|
||||
char *p = *line;
|
||||
unsigned int dig, val;
|
||||
|
||||
|
@ -530,7 +530,7 @@ parse_modeval(char **line, int *rmode, int *rval)
|
|||
}
|
||||
|
||||
/*
|
||||
* dump the whole mixer, useful for debugging
|
||||
* dump the whole controls list, useful for debugging
|
||||
*/
|
||||
void
|
||||
dump(void)
|
||||
|
@ -543,12 +543,12 @@ dump(void)
|
|||
printf(".%s", i->desc.func);
|
||||
printf("=");
|
||||
switch (i->desc.type) {
|
||||
case SIOMIX_NUM:
|
||||
case SIOMIX_SW:
|
||||
case SIOCTL_NUM:
|
||||
case SIOCTL_SW:
|
||||
printf("* (%u)", i->curval);
|
||||
break;
|
||||
case SIOMIX_VEC:
|
||||
case SIOMIX_LIST:
|
||||
case SIOCTL_VEC:
|
||||
case SIOCTL_LIST:
|
||||
print_chan(&i->desc.chan1, 0);
|
||||
printf(":* (%u)", i->curval);
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ cmd(char *line)
|
|||
{
|
||||
char *pos = line;
|
||||
struct info *i, *e, *g;
|
||||
char func[SIOMIX_NAMEMAX], astr[SIOMIX_NAMEMAX], vstr[SIOMIX_NAMEMAX];
|
||||
char func[SIOCTL_NAMEMAX], astr[SIOCTL_NAMEMAX], vstr[SIOCTL_NAMEMAX];
|
||||
int aunit, vunit;
|
||||
unsigned npar = 0, nent = 0;
|
||||
int val, comma, mode;
|
||||
|
@ -602,8 +602,8 @@ cmd(char *line)
|
|||
}
|
||||
npar = 0;
|
||||
switch (g->desc.type) {
|
||||
case SIOMIX_NUM:
|
||||
case SIOMIX_SW:
|
||||
case SIOCTL_NUM:
|
||||
case SIOCTL_SW:
|
||||
if (!parse_modeval(&pos, &mode, &val))
|
||||
return 0;
|
||||
for (i = g; i != NULL; i = nextpar(i)) {
|
||||
|
@ -614,8 +614,8 @@ cmd(char *line)
|
|||
npar++;
|
||||
}
|
||||
break;
|
||||
case SIOMIX_VEC:
|
||||
case SIOMIX_LIST:
|
||||
case SIOCTL_VEC:
|
||||
case SIOCTL_LIST:
|
||||
for (i = g; i != NULL; i = nextpar(i)) {
|
||||
if (!matchpar(i, astr, aunit))
|
||||
continue;
|
||||
|
@ -641,7 +641,7 @@ cmd(char *line)
|
|||
if (!parse_modeval(&pos, &mode, &val))
|
||||
return 0;
|
||||
} else {
|
||||
val = SIOMIX_INTMAX;
|
||||
val = SIOCTL_INTMAX;
|
||||
mode = MODE_SET;
|
||||
}
|
||||
nent = 0;
|
||||
|
@ -677,7 +677,7 @@ cmd(char *line)
|
|||
}
|
||||
|
||||
/*
|
||||
* write on the mixer device entries with the ``set'' flag
|
||||
* write the controls with the ``set'' flag on the device
|
||||
*/
|
||||
void
|
||||
commit(void)
|
||||
|
@ -696,8 +696,8 @@ commit(void)
|
|||
break;
|
||||
case MODE_ADD:
|
||||
val = i->curval + i->newval;
|
||||
if (val > SIOMIX_INTMAX)
|
||||
val = SIOMIX_INTMAX;
|
||||
if (val > SIOCTL_INTMAX)
|
||||
val = SIOCTL_INTMAX;
|
||||
break;
|
||||
case MODE_SUB:
|
||||
val = i->curval - i->newval;
|
||||
|
@ -705,16 +705,16 @@ commit(void)
|
|||
val = 0;
|
||||
break;
|
||||
case MODE_TOGGLE:
|
||||
val = (i->curval >= SIOMIX_HALF) ? 0 : SIOMIX_INTMAX;
|
||||
val = (i->curval >= SIOCTL_HALF) ? 0 : SIOCTL_INTMAX;
|
||||
}
|
||||
switch (i->desc.type) {
|
||||
case SIOMIX_NUM:
|
||||
case SIOMIX_SW:
|
||||
siomix_setctl(hdl, i->ctladdr, val);
|
||||
case SIOCTL_NUM:
|
||||
case SIOCTL_SW:
|
||||
sioctl_setctl(hdl, i->ctladdr, val);
|
||||
break;
|
||||
case SIOMIX_VEC:
|
||||
case SIOMIX_LIST:
|
||||
siomix_setctl(hdl, i->ctladdr, val);
|
||||
case SIOCTL_VEC:
|
||||
case SIOCTL_LIST:
|
||||
sioctl_setctl(hdl, i->ctladdr, val);
|
||||
}
|
||||
i->curval = val;
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ list(void)
|
|||
* existing label widged rather than inserting a new one.
|
||||
*/
|
||||
void
|
||||
ondesc(void *arg, struct siomix_desc *d, int curval)
|
||||
ondesc(void *arg, struct sioctl_desc *d, int curval)
|
||||
{
|
||||
struct info *i, **pi;
|
||||
int cmp;
|
||||
|
@ -774,7 +774,7 @@ ondesc(void *arg, struct siomix_desc *d, int curval)
|
|||
}
|
||||
}
|
||||
|
||||
if (d->type == SIOMIX_NONE)
|
||||
if (d->type == SIOCTL_NONE)
|
||||
return;
|
||||
|
||||
/*
|
||||
|
@ -783,7 +783,7 @@ ondesc(void *arg, struct siomix_desc *d, int curval)
|
|||
for (pi = &infolist; (i = *pi) != NULL; pi = &i->next) {
|
||||
cmp = cmpdesc(d, &i->desc);
|
||||
if (cmp == 0) {
|
||||
fprintf(stderr, "fatal: duplicate mixer knob:\n");
|
||||
fprintf(stderr, "fatal: duplicate control:\n");
|
||||
print_par(i, 0, "duplicate");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -825,7 +825,7 @@ onctl(void *arg, unsigned addr, unsigned val)
|
|||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *devname = SIOMIX_DEVANY;
|
||||
char *devname = SIOCTL_DEVANY;
|
||||
int i, c, d_flag = 0;
|
||||
struct info *g;
|
||||
struct pollfd *pfds;
|
||||
|
@ -857,16 +857,16 @@ main(int argc, char **argv)
|
|||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
hdl = siomix_open(devname, SIOMIX_READ | SIOMIX_WRITE, 0);
|
||||
hdl = sioctl_open(devname, SIOCTL_READ | SIOCTL_WRITE, 0);
|
||||
if (hdl == NULL) {
|
||||
fprintf(stderr, "%s: can't open mixer device\n", devname);
|
||||
fprintf(stderr, "%s: can't open control device\n", devname);
|
||||
exit(1);
|
||||
}
|
||||
if (!siomix_ondesc(hdl, ondesc, NULL)) {
|
||||
fprintf(stderr, "%s: can't get mixer description\n", devname);
|
||||
if (!sioctl_ondesc(hdl, ondesc, NULL)) {
|
||||
fprintf(stderr, "%s: can't get device description\n", devname);
|
||||
exit(1);
|
||||
}
|
||||
siomix_onctl(hdl, onctl, NULL);
|
||||
sioctl_onctl(hdl, onctl, NULL);
|
||||
|
||||
if (d_flag) {
|
||||
if (argc > 0) {
|
||||
|
@ -889,13 +889,13 @@ main(int argc, char **argv)
|
|||
list();
|
||||
}
|
||||
if (m_flag) {
|
||||
pfds = malloc(sizeof(struct pollfd) * siomix_nfds(hdl));
|
||||
pfds = malloc(sizeof(struct pollfd) * sioctl_nfds(hdl));
|
||||
if (pfds == NULL) {
|
||||
perror("malloc");
|
||||
exit(1);
|
||||
}
|
||||
for (;;) {
|
||||
nfds = siomix_pollfd(hdl, pfds, POLLIN);
|
||||
nfds = sioctl_pollfd(hdl, pfds, POLLIN);
|
||||
if (nfds == 0)
|
||||
break;
|
||||
while (poll(pfds, nfds, -1) < 0) {
|
||||
|
@ -904,7 +904,7 @@ main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
revents = siomix_revents(hdl, pfds);
|
||||
revents = sioctl_revents(hdl, pfds);
|
||||
if (revents & POLLHUP) {
|
||||
fprintf(stderr, "disconnected\n");
|
||||
break;
|
||||
|
@ -912,6 +912,6 @@ main(int argc, char **argv)
|
|||
}
|
||||
free(pfds);
|
||||
}
|
||||
siomix_close(hdl);
|
||||
sioctl_close(hdl);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ clean:
|
|||
# ---------------------------------------------------------- dependencies ---
|
||||
|
||||
OBJS = \
|
||||
abuf.o utils.o dev.o dev_siomix.o dsp.o file.o listen.o midi.o miofile.o \
|
||||
abuf.o utils.o dev.o dev_sioctl.o dsp.o file.o listen.o midi.o miofile.o \
|
||||
opt.o siofile.o sndiod.o sock.o
|
||||
|
||||
sndiod: ${OBJS}
|
||||
|
@ -56,7 +56,7 @@ sndiod: ${OBJS}
|
|||
abuf.o: abuf.c abuf.h utils.h
|
||||
dev.o: dev.c ../bsd-compat/bsd-compat.h abuf.h defs.h dev.h \
|
||||
dsp.h siofile.h file.h midi.h miofile.h sysex.h utils.h
|
||||
dev_siomix.o: dev_siomix.c abuf.h defs.h dev.h dsp.h siofile.h file.h \
|
||||
dev_sioctl.o: dev_sioctl.c abuf.h defs.h dev.h dsp.h siofile.h file.h \
|
||||
utils.h
|
||||
dsp.o: dsp.c dsp.h defs.h utils.h
|
||||
file.o: file.c file.h utils.h
|
||||
|
|
|
@ -37,12 +37,12 @@
|
|||
#define MODE_MIDIOUT 0x04 /* allowed to read midi */
|
||||
#define MODE_MIDIIN 0x08 /* allowed to write midi */
|
||||
#define MODE_MON 0x10 /* allowed to monitor */
|
||||
#define MODE_MIXREAD 0x100 /* allowed to read mixer settings */
|
||||
#define MODE_MIXWRITE 0x200 /* allowed to change mixer settings */
|
||||
#define MODE_CTLREAD 0x100 /* allowed to read controls */
|
||||
#define MODE_CTLWRITE 0x200 /* allowed to change controls */
|
||||
#define MODE_RECMASK (MODE_REC | MODE_MON)
|
||||
#define MODE_AUDIOMASK (MODE_PLAY | MODE_REC | MODE_MON)
|
||||
#define MODE_MIDIMASK (MODE_MIDIIN | MODE_MIDIOUT)
|
||||
#define MODE_MIXMASK (MODE_MIXREAD | MODE_MIXWRITE)
|
||||
#define MODE_CTLMASK (MODE_CTLREAD | MODE_CTLWRITE)
|
||||
|
||||
/*
|
||||
* underrun/overrun policies, must be the same as SIO_ constants
|
||||
|
|
|
@ -1314,7 +1314,7 @@ dev_reopen(struct dev *d)
|
|||
}
|
||||
|
||||
/* add new device controls */
|
||||
dev_siomix_open(d);
|
||||
dev_sioctl_open(d);
|
||||
|
||||
/* start the device if needed */
|
||||
if (pstate == DEV_RUN)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "abuf.h"
|
||||
#include "dsp.h"
|
||||
#include "siofile.h"
|
||||
#include "dev_siomix.h"
|
||||
#include "dev_sioctl.h"
|
||||
|
||||
#define CTLADDR_SLOT_LEVEL(n) (n)
|
||||
#define CTLADDR_MASTER (DEV_NSLOT)
|
||||
|
@ -161,7 +161,7 @@ struct dev {
|
|||
* audio device (while opened)
|
||||
*/
|
||||
struct dev_sio sio;
|
||||
struct dev_siomix siomix;
|
||||
struct dev_sioctl sioctl;
|
||||
struct aparams par; /* encoding */
|
||||
int pchan, rchan; /* play & rec channels */
|
||||
adata_t *rbuf; /* rec buffer */
|
||||
|
|
|
@ -27,29 +27,29 @@
|
|||
#include "dev.h"
|
||||
#include "dsp.h"
|
||||
#include "file.h"
|
||||
#include "dev_siomix.h"
|
||||
#include "dev_sioctl.h"
|
||||
#include "utils.h"
|
||||
#include "bsd-compat.h"
|
||||
|
||||
void dev_siomix_ondesc(void *, struct siomix_desc *, int);
|
||||
void dev_siomix_onctl(void *, unsigned int, unsigned int);
|
||||
int dev_siomix_pollfd(void *, struct pollfd *);
|
||||
int dev_siomix_revents(void *, struct pollfd *);
|
||||
void dev_siomix_in(void *);
|
||||
void dev_siomix_out(void *);
|
||||
void dev_siomix_hup(void *);
|
||||
void dev_sioctl_ondesc(void *, struct sioctl_desc *, int);
|
||||
void dev_sioctl_onctl(void *, unsigned int, unsigned int);
|
||||
int dev_sioctl_pollfd(void *, struct pollfd *);
|
||||
int dev_sioctl_revents(void *, struct pollfd *);
|
||||
void dev_sioctl_in(void *);
|
||||
void dev_sioctl_out(void *);
|
||||
void dev_sioctl_hup(void *);
|
||||
|
||||
struct fileops dev_siomix_ops = {
|
||||
"siomix",
|
||||
dev_siomix_pollfd,
|
||||
dev_siomix_revents,
|
||||
dev_siomix_in,
|
||||
dev_siomix_out,
|
||||
dev_siomix_hup
|
||||
struct fileops dev_sioctl_ops = {
|
||||
"sioctl",
|
||||
dev_sioctl_pollfd,
|
||||
dev_sioctl_revents,
|
||||
dev_sioctl_in,
|
||||
dev_sioctl_out,
|
||||
dev_sioctl_hup
|
||||
};
|
||||
|
||||
void
|
||||
dev_siomix_ondesc(void *arg, struct siomix_desc *desc, int val)
|
||||
dev_sioctl_ondesc(void *arg, struct sioctl_desc *desc, int val)
|
||||
{
|
||||
struct dev *d = arg;
|
||||
int addr;
|
||||
|
@ -65,7 +65,7 @@ dev_siomix_ondesc(void *arg, struct siomix_desc *desc, int val)
|
|||
}
|
||||
|
||||
void
|
||||
dev_siomix_onctl(void *arg, unsigned int addr, unsigned int val)
|
||||
dev_sioctl_onctl(void *arg, unsigned int addr, unsigned int val)
|
||||
{
|
||||
struct dev *d = arg;
|
||||
struct ctl *c;
|
||||
|
@ -92,32 +92,32 @@ dev_siomix_onctl(void *arg, unsigned int addr, unsigned int val)
|
|||
}
|
||||
|
||||
/*
|
||||
* open the mixer device.
|
||||
* open the control device.
|
||||
*/
|
||||
void
|
||||
dev_siomix_open(struct dev *d)
|
||||
dev_sioctl_open(struct dev *d)
|
||||
{
|
||||
if (d->siomix.hdl == NULL)
|
||||
if (d->sioctl.hdl == NULL)
|
||||
return;
|
||||
siomix_ondesc(d->siomix.hdl, dev_siomix_ondesc, d);
|
||||
siomix_onctl(d->siomix.hdl, dev_siomix_onctl, d);
|
||||
d->siomix.file = file_new(&dev_siomix_ops, d, "mix",
|
||||
siomix_nfds(d->siomix.hdl));
|
||||
sioctl_ondesc(d->sioctl.hdl, dev_sioctl_ondesc, d);
|
||||
sioctl_onctl(d->sioctl.hdl, dev_sioctl_onctl, d);
|
||||
d->sioctl.file = file_new(&dev_sioctl_ops, d, "mix",
|
||||
sioctl_nfds(d->sioctl.hdl));
|
||||
}
|
||||
|
||||
/*
|
||||
* close the mixer device.
|
||||
* close the control device.
|
||||
*/
|
||||
void
|
||||
dev_siomix_close(struct dev *d)
|
||||
dev_sioctl_close(struct dev *d)
|
||||
{
|
||||
if (d->siomix.hdl == NULL)
|
||||
if (d->sioctl.hdl == NULL)
|
||||
return;
|
||||
file_del(d->siomix.file);
|
||||
file_del(d->sioctl.file);
|
||||
}
|
||||
|
||||
int
|
||||
dev_siomix_pollfd(void *arg, struct pollfd *pfd)
|
||||
dev_sioctl_pollfd(void *arg, struct pollfd *pfd)
|
||||
{
|
||||
struct dev *d = arg;
|
||||
struct ctl *c;
|
||||
|
@ -127,31 +127,31 @@ dev_siomix_pollfd(void *arg, struct pollfd *pfd)
|
|||
if (c->dirty)
|
||||
events |= POLLOUT;
|
||||
}
|
||||
return siomix_pollfd(d->siomix.hdl, pfd, events);
|
||||
return sioctl_pollfd(d->sioctl.hdl, pfd, events);
|
||||
}
|
||||
|
||||
int
|
||||
dev_siomix_revents(void *arg, struct pollfd *pfd)
|
||||
dev_sioctl_revents(void *arg, struct pollfd *pfd)
|
||||
{
|
||||
struct dev *d = arg;
|
||||
|
||||
return siomix_revents(d->siomix.hdl, pfd);
|
||||
return sioctl_revents(d->sioctl.hdl, pfd);
|
||||
}
|
||||
|
||||
void
|
||||
dev_siomix_in(void *arg)
|
||||
dev_sioctl_in(void *arg)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
dev_siomix_out(void *arg)
|
||||
dev_sioctl_out(void *arg)
|
||||
{
|
||||
struct dev *d = arg;
|
||||
struct ctl *c;
|
||||
int cnt;
|
||||
|
||||
/*
|
||||
* for each dirty ctl, call siomix_setctl() and dev_unref(). As
|
||||
* for each dirty ctl, call sioctl_setctl() and dev_unref(). As
|
||||
* dev_unref() may destroy the ctl_list, we must call it after
|
||||
* we've finished iterating on it.
|
||||
*/
|
||||
|
@ -159,7 +159,7 @@ dev_siomix_out(void *arg)
|
|||
for (c = d->ctl_list; c != NULL; c = c->next) {
|
||||
if (!c->dirty)
|
||||
continue;
|
||||
if (!siomix_setctl(d->siomix.hdl,
|
||||
if (!sioctl_setctl(d->sioctl.hdl,
|
||||
c->addr - CTLADDR_END, c->curval)) {
|
||||
ctl_log(c);
|
||||
log_puts(": set failed\n");
|
||||
|
@ -177,9 +177,9 @@ dev_siomix_out(void *arg)
|
|||
}
|
||||
|
||||
void
|
||||
dev_siomix_hup(void *arg)
|
||||
dev_sioctl_hup(void *arg)
|
||||
{
|
||||
struct dev *d = arg;
|
||||
|
||||
dev_siomix_close(d);
|
||||
dev_sioctl_close(d);
|
||||
}
|
|
@ -14,19 +14,19 @@
|
|||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef DEV_SIOMIX_H
|
||||
#define DEV_SIOMIX_H
|
||||
#ifndef DEV_SIOCTL_H
|
||||
#define DEV_SIOCTL_H
|
||||
|
||||
#include "file.h"
|
||||
|
||||
struct dev;
|
||||
|
||||
struct dev_siomix {
|
||||
struct siomix_hdl *hdl;
|
||||
struct dev_sioctl {
|
||||
struct sioctl_hdl *hdl;
|
||||
struct file *file;
|
||||
};
|
||||
|
||||
void dev_siomix_open(struct dev *);
|
||||
void dev_siomix_close(struct dev *);
|
||||
void dev_sioctl_open(struct dev *);
|
||||
void dev_sioctl_close(struct dev *);
|
||||
|
||||
#endif /* !defined(DEV_SIOMIX_H) */
|
||||
#endif /* !defined(DEV_SIOCTL_H) */
|
|
@ -26,7 +26,7 @@
|
|||
#include "abuf.h"
|
||||
#include "defs.h"
|
||||
#include "dev.h"
|
||||
#include "dev_siomix.h"
|
||||
#include "dev_sioctl.h"
|
||||
#include "dsp.h"
|
||||
#include "file.h"
|
||||
#include "siofile.h"
|
||||
|
@ -88,11 +88,11 @@ dev_sio_timeout(void *arg)
|
|||
* open the device using one of the provided paths
|
||||
*/
|
||||
static struct sio_hdl *
|
||||
dev_sio_openlist(struct dev *d, unsigned int mode, struct siomix_hdl **rmixhdl)
|
||||
dev_sio_openlist(struct dev *d, unsigned int mode, struct sioctl_hdl **rctlhdl)
|
||||
{
|
||||
struct name *n;
|
||||
struct sio_hdl *hdl;
|
||||
struct siomix_hdl *mixhdl;
|
||||
struct sioctl_hdl *ctlhdl;
|
||||
|
||||
n = d->path_list;
|
||||
while (1) {
|
||||
|
@ -106,15 +106,15 @@ dev_sio_openlist(struct dev *d, unsigned int mode, struct siomix_hdl **rmixhdl)
|
|||
log_puts(n->str);
|
||||
log_puts("\n");
|
||||
}
|
||||
mixhdl = siomix_open(n->str,
|
||||
SIOMIX_READ | SIOMIX_WRITE, 0);
|
||||
if (mixhdl == NULL) {
|
||||
ctlhdl = sioctl_open(n->str,
|
||||
SIOCTL_READ | SIOCTL_WRITE, 0);
|
||||
if (ctlhdl == NULL) {
|
||||
if (log_level >= 1) {
|
||||
dev_log(d);
|
||||
log_puts(": no mixer\n");
|
||||
log_puts(": no control device\n");
|
||||
}
|
||||
}
|
||||
*rmixhdl = mixhdl;
|
||||
*rctlhdl = ctlhdl;
|
||||
return hdl;
|
||||
}
|
||||
n = n->next;
|
||||
|
@ -131,16 +131,16 @@ dev_sio_open(struct dev *d)
|
|||
struct sio_par par;
|
||||
unsigned int mode = d->mode & (MODE_PLAY | MODE_REC);
|
||||
|
||||
d->sio.hdl = dev_sio_openlist(d, mode, &d->siomix.hdl);
|
||||
d->sio.hdl = dev_sio_openlist(d, mode, &d->sioctl.hdl);
|
||||
if (d->sio.hdl == NULL) {
|
||||
if (mode != (SIO_PLAY | SIO_REC))
|
||||
return 0;
|
||||
d->sio.hdl = dev_sio_openlist(d, SIO_PLAY, &d->siomix.hdl);
|
||||
d->sio.hdl = dev_sio_openlist(d, SIO_PLAY, &d->sioctl.hdl);
|
||||
if (d->sio.hdl != NULL)
|
||||
mode = SIO_PLAY;
|
||||
else {
|
||||
d->sio.hdl = dev_sio_openlist(d,
|
||||
SIO_REC, &d->siomix.hdl);
|
||||
SIO_REC, &d->sioctl.hdl);
|
||||
if (d->sio.hdl != NULL)
|
||||
mode = SIO_REC;
|
||||
else
|
||||
|
@ -253,13 +253,13 @@ dev_sio_open(struct dev *d)
|
|||
sio_onmove(d->sio.hdl, dev_sio_onmove, d);
|
||||
d->sio.file = file_new(&dev_sio_ops, d, "dev", sio_nfds(d->sio.hdl));
|
||||
timo_set(&d->sio.watchdog, dev_sio_timeout, d);
|
||||
dev_siomix_open(d);
|
||||
dev_sioctl_open(d);
|
||||
return 1;
|
||||
bad_close:
|
||||
sio_close(d->sio.hdl);
|
||||
if (d->siomix.hdl) {
|
||||
siomix_close(d->siomix.hdl);
|
||||
d->siomix.hdl = NULL;
|
||||
if (d->sioctl.hdl) {
|
||||
sioctl_close(d->sioctl.hdl);
|
||||
d->sioctl.hdl = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -272,11 +272,11 @@ dev_sio_open(struct dev *d)
|
|||
int
|
||||
dev_sio_reopen(struct dev *d)
|
||||
{
|
||||
struct siomix_hdl *mixhdl;
|
||||
struct sioctl_hdl *ctlhdl;
|
||||
struct sio_par par;
|
||||
struct sio_hdl *hdl;
|
||||
|
||||
hdl = dev_sio_openlist(d, d->mode & (MODE_PLAY | MODE_REC), &mixhdl);
|
||||
hdl = dev_sio_openlist(d, d->mode & (MODE_PLAY | MODE_REC), &ctlhdl);
|
||||
if (hdl == NULL) {
|
||||
if (log_level >= 1) {
|
||||
dev_log(d);
|
||||
|
@ -317,10 +317,10 @@ dev_sio_reopen(struct dev *d)
|
|||
timo_del(&d->sio.watchdog);
|
||||
file_del(d->sio.file);
|
||||
sio_close(d->sio.hdl);
|
||||
dev_siomix_close(d);
|
||||
if (d->siomix.hdl) {
|
||||
siomix_close(d->siomix.hdl);
|
||||
d->siomix.hdl = NULL;
|
||||
dev_sioctl_close(d);
|
||||
if (d->sioctl.hdl) {
|
||||
sioctl_close(d->sioctl.hdl);
|
||||
d->sioctl.hdl = NULL;
|
||||
}
|
||||
|
||||
/* update parameters */
|
||||
|
@ -335,21 +335,21 @@ dev_sio_reopen(struct dev *d)
|
|||
d->rchan = par.rchan;
|
||||
|
||||
d->sio.hdl = hdl;
|
||||
d->siomix.hdl = mixhdl;
|
||||
d->sioctl.hdl = ctlhdl;
|
||||
d->sio.file = file_new(&dev_sio_ops, d, "dev", sio_nfds(hdl));
|
||||
sio_onmove(hdl, dev_sio_onmove, d);
|
||||
return 1;
|
||||
bad_close:
|
||||
sio_close(hdl);
|
||||
if (mixhdl)
|
||||
siomix_close(mixhdl);
|
||||
if (ctlhdl)
|
||||
sioctl_close(ctlhdl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
dev_sio_close(struct dev *d)
|
||||
{
|
||||
dev_siomix_close(d);
|
||||
dev_sioctl_close(d);
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 3) {
|
||||
dev_log(d);
|
||||
|
@ -359,9 +359,9 @@ dev_sio_close(struct dev *d)
|
|||
timo_del(&d->sio.watchdog);
|
||||
file_del(d->sio.file);
|
||||
sio_close(d->sio.hdl);
|
||||
if (d->siomix.hdl) {
|
||||
siomix_close(d->siomix.hdl);
|
||||
d->siomix.hdl = NULL;
|
||||
if (d->sioctl.hdl) {
|
||||
sioctl_close(d->sioctl.hdl);
|
||||
d->sioctl.hdl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -823,9 +823,9 @@ sock_hello(struct sock *f)
|
|||
case MODE_REC:
|
||||
case MODE_PLAY:
|
||||
case MODE_PLAY | MODE_REC:
|
||||
case MODE_MIXREAD:
|
||||
case MODE_MIXWRITE:
|
||||
case MODE_MIXREAD | MODE_MIXWRITE:
|
||||
case MODE_CTLREAD:
|
||||
case MODE_CTLWRITE:
|
||||
case MODE_CTLREAD | MODE_CTLWRITE:
|
||||
break;
|
||||
default:
|
||||
#ifdef DEBUG
|
||||
|
@ -863,7 +863,7 @@ sock_hello(struct sock *f)
|
|||
return 0;
|
||||
return 1;
|
||||
}
|
||||
if (mode & MODE_MIXMASK) {
|
||||
if (mode & MODE_CTLMASK) {
|
||||
d = dev_bynum(p->devnum);
|
||||
if (d == NULL) {
|
||||
if (log_level >= 2) {
|
||||
|
@ -883,7 +883,7 @@ sock_hello(struct sock *f)
|
|||
return 0;
|
||||
}
|
||||
f->ctldesc = xmalloc(SOCK_CTLDESC_SIZE *
|
||||
sizeof(struct amsg_mix_desc));
|
||||
sizeof(struct amsg_ctl_desc));
|
||||
f->ctlops = 0;
|
||||
f->ctlsyncpending = 0;
|
||||
return 1;
|
||||
|
@ -1208,14 +1208,14 @@ sock_execmsg(struct sock *f)
|
|||
dev_onctl(s->dev,
|
||||
CTLADDR_SLOT_LEVEL(f->slot - s->dev->slot), ctl);
|
||||
break;
|
||||
case AMSG_MIXSUB:
|
||||
case AMSG_CTLSUB:
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 3) {
|
||||
sock_log(f);
|
||||
log_puts(": MIXSUB message, desc = ");
|
||||
log_putx(m->u.mixsub.desc);
|
||||
log_puts(": CTLSUB message, desc = ");
|
||||
log_putx(m->u.ctlsub.desc);
|
||||
log_puts(", val = ");
|
||||
log_putx(m->u.mixsub.val);
|
||||
log_putx(m->u.ctlsub.val);
|
||||
log_puts("\n");
|
||||
}
|
||||
#endif
|
||||
|
@ -1223,13 +1223,13 @@ sock_execmsg(struct sock *f)
|
|||
#ifdef DEBUG
|
||||
if (log_level >= 1) {
|
||||
sock_log(f);
|
||||
log_puts(": MIXSUB, wrong state\n");
|
||||
log_puts(": CTLSUB, wrong state\n");
|
||||
}
|
||||
#endif
|
||||
sock_close(f);
|
||||
return 0;
|
||||
}
|
||||
if (m->u.mixsub.desc) {
|
||||
if (m->u.ctlsub.desc) {
|
||||
if (!(f->ctlops & SOCK_CTLDESC)) {
|
||||
ctl = f->ctlslot->mask;
|
||||
c = f->ctlslot->dev->ctl_list;
|
||||
|
@ -1242,37 +1242,37 @@ sock_execmsg(struct sock *f)
|
|||
f->ctlsyncpending = 1;
|
||||
} else
|
||||
f->ctlops &= ~SOCK_CTLDESC;
|
||||
if (m->u.mixsub.val) {
|
||||
if (m->u.ctlsub.val) {
|
||||
f->ctlops |= SOCK_CTLVAL;
|
||||
} else
|
||||
f->ctlops &= ~SOCK_CTLVAL;
|
||||
f->rstate = SOCK_RMSG;
|
||||
f->rtodo = sizeof(struct amsg);
|
||||
break;
|
||||
case AMSG_MIXSET:
|
||||
case AMSG_CTLSET:
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 3) {
|
||||
sock_log(f);
|
||||
log_puts(": MIXSET message\n");
|
||||
log_puts(": CTLSET message\n");
|
||||
}
|
||||
#endif
|
||||
if (f->pstate < SOCK_INIT || f->ctlslot == NULL) {
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 1) {
|
||||
sock_log(f);
|
||||
log_puts(": MIXSET, wrong state\n");
|
||||
log_puts(": CTLSET, wrong state\n");
|
||||
}
|
||||
#endif
|
||||
sock_close(f);
|
||||
return 0;
|
||||
}
|
||||
if (!dev_setctl(f->ctlslot->dev,
|
||||
ntohs(m->u.mixset.addr),
|
||||
ntohs(m->u.mixset.val))) {
|
||||
ntohs(m->u.ctlset.addr),
|
||||
ntohs(m->u.ctlset.val))) {
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 1) {
|
||||
sock_log(f);
|
||||
log_puts(": MIXSET, wrong addr/val\n");
|
||||
log_puts(": CTLSET, wrong addr/val\n");
|
||||
}
|
||||
#endif
|
||||
sock_close(f);
|
||||
|
@ -1369,7 +1369,7 @@ int
|
|||
sock_buildmsg(struct sock *f)
|
||||
{
|
||||
unsigned int size, mask;
|
||||
struct amsg_mix_desc *desc;
|
||||
struct amsg_ctl_desc *desc;
|
||||
struct ctl *c, **pc;
|
||||
|
||||
/*
|
||||
|
@ -1528,24 +1528,24 @@ sock_buildmsg(struct sock *f)
|
|||
continue;
|
||||
}
|
||||
if (size == SOCK_CTLDESC_SIZE *
|
||||
sizeof(struct amsg_mix_desc))
|
||||
sizeof(struct amsg_ctl_desc))
|
||||
break;
|
||||
c->desc_mask &= ~mask;
|
||||
c->val_mask &= ~mask;
|
||||
strlcpy(desc->group.str, c->group.str,
|
||||
AMSG_MIX_NAMEMAX);
|
||||
AMSG_CTL_NAMEMAX);
|
||||
desc->group.unit = ntohs(c->group.unit);
|
||||
strlcpy(desc->chan0.str, c->chan0.str,
|
||||
AMSG_MIX_NAMEMAX);
|
||||
AMSG_CTL_NAMEMAX);
|
||||
desc->chan0.unit = ntohs(c->chan0.unit);
|
||||
strlcpy(desc->chan1.str, c->chan1.str,
|
||||
AMSG_MIX_NAMEMAX);
|
||||
AMSG_CTL_NAMEMAX);
|
||||
desc->chan1.unit = ntohs(c->chan1.unit);
|
||||
desc->type = c->type;
|
||||
strlcpy(desc->func, c->func, AMSG_MIX_NAMEMAX);
|
||||
strlcpy(desc->func, c->func, AMSG_CTL_NAMEMAX);
|
||||
desc->addr = htons(c->addr);
|
||||
desc->curval = htons(c->curval);
|
||||
size += sizeof(struct amsg_mix_desc);
|
||||
size += sizeof(struct amsg_ctl_desc);
|
||||
desc++;
|
||||
|
||||
/* if this is a deleted entry unref it */
|
||||
|
@ -1569,7 +1569,7 @@ sock_buildmsg(struct sock *f)
|
|||
#ifdef DEBUG
|
||||
if (log_level >= 3) {
|
||||
sock_log(f);
|
||||
log_puts(": building mixer DATA message\n");
|
||||
log_puts(": building control DATA message\n");
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
|
@ -1582,15 +1582,15 @@ sock_buildmsg(struct sock *f)
|
|||
continue;
|
||||
c->val_mask &= ~mask;
|
||||
AMSG_INIT(&f->wmsg);
|
||||
f->wmsg.cmd = htonl(AMSG_MIXSET);
|
||||
f->wmsg.u.mixset.addr = htons(c->addr);
|
||||
f->wmsg.u.mixset.val = htons(c->curval);
|
||||
f->wmsg.cmd = htonl(AMSG_CTLSET);
|
||||
f->wmsg.u.ctlset.addr = htons(c->addr);
|
||||
f->wmsg.u.ctlset.val = htons(c->curval);
|
||||
f->wtodo = sizeof(struct amsg);
|
||||
f->wstate = SOCK_WMSG;
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 3) {
|
||||
sock_log(f);
|
||||
log_puts(": building mixer MIXSET message\n");
|
||||
log_puts(": building CTLSET message\n");
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
|
@ -1598,13 +1598,13 @@ sock_buildmsg(struct sock *f)
|
|||
}
|
||||
if (f->ctlslot && f->ctlsyncpending) {
|
||||
f->ctlsyncpending = 0;
|
||||
f->wmsg.cmd = htonl(AMSG_MIXSYNC);
|
||||
f->wmsg.cmd = htonl(AMSG_CTLSYNC);
|
||||
f->wtodo = sizeof(struct amsg);
|
||||
f->wstate = SOCK_WMSG;
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 3) {
|
||||
sock_log(f);
|
||||
log_puts(": building mixer MIXSYNC message\n");
|
||||
log_puts(": building CTLSYNC message\n");
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
|
|
|
@ -59,11 +59,11 @@ struct sock {
|
|||
struct midi *midi; /* midi endpoint */
|
||||
struct port *port; /* midi port */
|
||||
struct ctlslot *ctlslot;
|
||||
struct amsg_mix_desc *ctldesc; /* temporary buffer */
|
||||
struct amsg_ctl_desc *ctldesc; /* temporary buffer */
|
||||
#define SOCK_CTLDESC 1 /* dump desc and send changes */
|
||||
#define SOCK_CTLVAL 2 /* send value changes */
|
||||
unsigned int ctlops; /* bitmap of above */
|
||||
int ctlsyncpending; /* mixsync waiting to be transmitted */
|
||||
int ctlsyncpending; /* CTLSYNC waiting to be transmitted */
|
||||
};
|
||||
|
||||
struct sock *sock_new(int fd);
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
|
||||
char *dev_name;
|
||||
struct pollfd pfds[16];
|
||||
struct siomix_hdl *hdl;
|
||||
unsigned int master_addr, master_val = SIOMIX_INTMAX;
|
||||
struct sioctl_hdl *hdl;
|
||||
unsigned int master_addr, master_val = SIOCTL_INTMAX;
|
||||
int master_found = 0;
|
||||
int verbose;
|
||||
|
||||
|
@ -59,7 +59,7 @@ KeySym *inc_map, *dec_map;
|
|||
* new control
|
||||
*/
|
||||
static void
|
||||
mixer_ondesc(void *unused, struct siomix_desc *desc, int val)
|
||||
dev_ondesc(void *unused, struct sioctl_desc *desc, int val)
|
||||
{
|
||||
if (desc == NULL)
|
||||
return;
|
||||
|
@ -80,7 +80,7 @@ mixer_ondesc(void *unused, struct siomix_desc *desc, int val)
|
|||
* control value changed
|
||||
*/
|
||||
static void
|
||||
mixer_onctl(void *unused, unsigned int addr, unsigned int val)
|
||||
dev_onctl(void *unused, unsigned int addr, unsigned int val)
|
||||
{
|
||||
if (addr == master_addr) {
|
||||
if (verbose)
|
||||
|
@ -93,13 +93,13 @@ mixer_onctl(void *unused, unsigned int addr, unsigned int val)
|
|||
* if there's an error, close connection to sndiod
|
||||
*/
|
||||
static void
|
||||
mixer_disconnect(void)
|
||||
dev_disconnect(void)
|
||||
{
|
||||
if (!siomix_eof(hdl))
|
||||
if (!sioctl_eof(hdl))
|
||||
return;
|
||||
if (verbose)
|
||||
fprintf(stderr, "%s: mixer device disconnected\n", dev_name);
|
||||
siomix_close(hdl);
|
||||
fprintf(stderr, "%s: dev device disconnected\n", dev_name);
|
||||
sioctl_close(hdl);
|
||||
hdl = NULL;
|
||||
}
|
||||
|
||||
|
@ -107,20 +107,20 @@ mixer_disconnect(void)
|
|||
* connect to sndiod
|
||||
*/
|
||||
static int
|
||||
mixer_connect(void)
|
||||
dev_connect(void)
|
||||
{
|
||||
if (hdl != NULL)
|
||||
return 1;
|
||||
hdl = siomix_open(dev_name, SIOMIX_READ | SIOMIX_WRITE, 0);
|
||||
hdl = sioctl_open(dev_name, SIOCTL_READ | SIOCTL_WRITE, 0);
|
||||
if (hdl == NULL) {
|
||||
if (verbose)
|
||||
fprintf(stderr, "%s: couldn't open mixer device\n",
|
||||
fprintf(stderr, "%s: couldn't open dev device\n",
|
||||
dev_name);
|
||||
return 0;
|
||||
}
|
||||
master_found = 0;
|
||||
siomix_ondesc(hdl, mixer_ondesc, NULL);
|
||||
siomix_onctl(hdl, mixer_onctl, NULL);
|
||||
sioctl_ondesc(hdl, dev_ondesc, NULL);
|
||||
sioctl_onctl(hdl, dev_onctl, NULL);
|
||||
if (!master_found)
|
||||
fprintf(stderr, "%s: warning, couldn't find master control\n",
|
||||
dev_name);
|
||||
|
@ -131,15 +131,15 @@ mixer_connect(void)
|
|||
* send master volume message and to the server
|
||||
*/
|
||||
static void
|
||||
mixer_incrvol(int incr)
|
||||
dev_incrvol(int incr)
|
||||
{
|
||||
int vol;
|
||||
|
||||
if (!mixer_connect())
|
||||
if (!dev_connect())
|
||||
return;
|
||||
vol = master_val + incr;
|
||||
if (vol > SIOMIX_INTMAX)
|
||||
vol = SIOMIX_INTMAX;
|
||||
if (vol > SIOCTL_INTMAX)
|
||||
vol = SIOCTL_INTMAX;
|
||||
if (vol < 0)
|
||||
vol = 0;
|
||||
if (master_val != (unsigned int)vol) {
|
||||
|
@ -149,8 +149,8 @@ mixer_incrvol(int incr)
|
|||
fprintf(stderr, "%s: setting volume to %d\n",
|
||||
dev_name, vol);
|
||||
}
|
||||
siomix_setctl(hdl, master_addr, master_val);
|
||||
mixer_disconnect();
|
||||
sioctl_setctl(hdl, master_addr, master_val);
|
||||
dev_disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ main(int argc, char **argv)
|
|||
/*
|
||||
* parse command line options
|
||||
*/
|
||||
dev_name = SIOMIX_DEVANY;
|
||||
dev_name = SIOCTL_DEVANY;
|
||||
verbose = 0;
|
||||
background = 0;
|
||||
while ((c = getopt(argc, argv, "Df:q:v")) != -1) {
|
||||
|
@ -262,7 +262,7 @@ main(int argc, char **argv)
|
|||
for (scr = 0; scr != ScreenCount(dpy); scr++)
|
||||
XSelectInput(dpy, RootWindow(dpy, scr), KeyPress);
|
||||
|
||||
(void)mixer_connect();
|
||||
(void)dev_connect();
|
||||
|
||||
grab_keys();
|
||||
|
||||
|
@ -289,21 +289,21 @@ main(int argc, char **argv)
|
|||
continue;
|
||||
if (xev.xkey.keycode == inc_code &&
|
||||
inc_map[xev.xkey.state & ShiftMask] == KEY_INC) {
|
||||
mixer_incrvol(VOL_INC);
|
||||
dev_incrvol(VOL_INC);
|
||||
} else if (xev.xkey.keycode == dec_code &&
|
||||
dec_map[xev.xkey.state & ShiftMask] == KEY_DEC) {
|
||||
mixer_incrvol(-VOL_INC);
|
||||
dev_incrvol(-VOL_INC);
|
||||
}
|
||||
}
|
||||
nfds = (hdl != NULL) ? siomix_pollfd(hdl, pfds, 0) : 0;
|
||||
nfds = (hdl != NULL) ? sioctl_pollfd(hdl, pfds, 0) : 0;
|
||||
pfds[nfds].fd = ConnectionNumber(dpy);
|
||||
pfds[nfds].events = POLLIN;
|
||||
while (poll(pfds, nfds + 1, -1) < 0 && errno == EINTR)
|
||||
; /* nothing */
|
||||
if (hdl) {
|
||||
revents = siomix_revents(hdl, pfds);
|
||||
revents = sioctl_revents(hdl, pfds);
|
||||
if (revents & POLLHUP)
|
||||
mixer_disconnect();
|
||||
dev_disconnect();
|
||||
else if (revents & POLLIN) {
|
||||
/* what */
|
||||
}
|
||||
|
@ -313,6 +313,6 @@ main(int argc, char **argv)
|
|||
XFree(dec_map);
|
||||
XCloseDisplay(dpy);
|
||||
if (hdl)
|
||||
siomix_close(hdl);
|
||||
sioctl_close(hdl);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue