fix stupid functions names and file names, no binary change

This commit is contained in:
Alexandre Ratchov 2011-03-31 11:52:54 +02:00
parent 7b9076e617
commit 2873ad8ad2
6 changed files with 326 additions and 326 deletions

View File

@ -97,7 +97,7 @@ clean:
# object files, sorted following dependencies to allow the
# loader to determine dependencies in a single pass
#
OBJS = mio.o mio_rmidi.o mio_thru.o sndio.o alsa.o aucat.o sun.o \
OBJS = mio.o mio_rmidi.o mio_thru.o sio.o sio_alsa.o sio_aucat.o sio_sun.o \
getpeereid.o issetugid.o strlcpy.o strtonum.o
.c.o:
@ -124,12 +124,12 @@ strlcpy.o: ../bsd-compat/strlcpy.c
strtonum.o: ../bsd-compat/strtonum.c
${CC} ${CFLAGS} ${SO_CFLAGS} ${INCLUDE} ${DEFS} -c -o strtonum.o ../bsd-compat/strtonum.c
alsa.o: alsa.c sndio_priv.h sndio.h
aucat.o: aucat.c ../aucat/amsg.h ../aucat/conf.h sndio_priv.h \
sio_alsa.o: sio_alsa.c sio_priv.h sndio.h
sio_aucat.o: sio_aucat.c ../aucat/amsg.h ../aucat/conf.h sio_priv.h \
sndio.h ../bsd-compat/bsd-compat.h
mio.o: mio.c mio_priv.h sndio.h ../bsd-compat/bsd-compat.h
mio_rmidi.o: mio_rmidi.c mio_priv.h sndio.h
mio_thru.o: mio_thru.c ../aucat/amsg.h ../aucat/conf.h mio_priv.h \
sndio.h ../bsd-compat/bsd-compat.h
sndio.o: sndio.c sndio_priv.h sndio.h ../bsd-compat/bsd-compat.h
sun.o: sun.c sndio_priv.h sndio.h
sio.o: sio.c sio_priv.h sndio.h ../bsd-compat/bsd-compat.h
sio_sun.o: sio_sun.c sio_priv.h sndio.h

View File

@ -28,7 +28,7 @@
#include <string.h>
#include <unistd.h>
#include "sndio_priv.h"
#include "sio_priv.h"
#ifdef COMPAT_ISSETUGID
#include "bsd-compat.h"
#endif
@ -75,7 +75,7 @@ sio_open(const char *str, unsigned mode, int nbio)
if (str == NULL && !issetugid())
str = getenv("AUDIODEVICE");
if (str == NULL) {
hdl = sio_open_aucat("0", mode, nbio);
hdl = sio_aucat_open("0", mode, nbio);
if (hdl != NULL)
return hdl;
#ifdef USE_SUN
@ -84,7 +84,7 @@ sio_open(const char *str, unsigned mode, int nbio)
minor(sb.st_rdev) & 0xf);
} else
strlcpy(buf, "0", sizeof(buf));
hdl = sio_open_sun(buf, mode, nbio);
hdl = sio_sun_open(buf, mode, nbio);
if (hdl != NULL)
return hdl;
#endif
@ -103,10 +103,10 @@ sio_open(const char *str, unsigned mode, int nbio)
*/
if (stat(str, &sb) < 0 || !S_ISCHR(sb.st_mode)) {
snprintf(buf, sizeof(buf), "0.%s", str);
return sio_open_aucat(buf, mode, nbio);
return sio_aucat_open(buf, mode, nbio);
}
snprintf(buf, sizeof(buf), "%u", minor(sb.st_rdev) & 0xf);
return sio_open_sun(buf, mode, nbio);
return sio_sun_open(buf, mode, nbio);
#else
return NULL;
#endif
@ -114,11 +114,11 @@ sio_open(const char *str, unsigned mode, int nbio)
len = sep - str;
if (len == (sizeof(prefix_aucat) - 1) &&
memcmp(str, prefix_aucat, len) == 0)
return sio_open_aucat(sep + 1, mode, nbio);
return sio_aucat_open(sep + 1, mode, nbio);
#ifdef USE_SUN
if (len == (sizeof(prefix_sun) - 1) &&
memcmp(str, prefix_sun, len) == 0)
return sio_open_sun(sep + 1, mode, nbio);
return sio_sun_open(sep + 1, mode, nbio);
#endif
#ifdef USE_ALSA
if (len == (sizeof(prefix_alsa) - 1) &&

View File

@ -33,7 +33,7 @@
#include <unistd.h>
#include <values.h>
#include "sndio_priv.h"
#include "sio_priv.h"
#ifdef DEBUG
#define DALSA(str, err) fprintf(stderr, "%s: %s\n", str, snd_strerror(err))
@ -41,7 +41,7 @@
#define DALSA(str, err) do {} while (0)
#endif
struct alsa_hdl {
struct sio_alsa_hdl {
struct sio_hdl sio;
struct sio_par par;
struct pollfd *pfds;
@ -61,41 +61,41 @@ struct alsa_hdl {
int nfds, infds, onfds;
};
static void alsa_close(struct sio_hdl *);
static int alsa_start(struct sio_hdl *);
static int alsa_stop(struct sio_hdl *);
static int alsa_setpar(struct sio_hdl *, struct sio_par *);
static int alsa_getpar(struct sio_hdl *, struct sio_par *);
static int alsa_getcap(struct sio_hdl *, struct sio_cap *);
static size_t alsa_read(struct sio_hdl *, void *, size_t);
static size_t alsa_write(struct sio_hdl *, const void *, size_t);
static int alsa_nfds(struct sio_hdl *);
static int alsa_pollfd(struct sio_hdl *, struct pollfd *, int);
static int alsa_revents(struct sio_hdl *, struct pollfd *);
static int alsa_setvol(struct sio_hdl *, unsigned);
static void alsa_getvol(struct sio_hdl *);
static void sio_alsa_close(struct sio_hdl *);
static int sio_alsa_start(struct sio_hdl *);
static int sio_alsa_stop(struct sio_hdl *);
static int sio_alsa_setpar(struct sio_hdl *, struct sio_par *);
static int sio_alsa_getpar(struct sio_hdl *, struct sio_par *);
static int sio_alsa_getcap(struct sio_hdl *, struct sio_cap *);
static size_t sio_alsa_read(struct sio_hdl *, void *, size_t);
static size_t sio_alsa_write(struct sio_hdl *, const void *, size_t);
static int sio_alsa_nfds(struct sio_hdl *);
static int sio_alsa_pollfd(struct sio_hdl *, struct pollfd *, int);
static int sio_alsa_revents(struct sio_hdl *, struct pollfd *);
static int sio_alsa_setvol(struct sio_hdl *, unsigned);
static void sio_alsa_getvol(struct sio_hdl *);
static struct sio_ops alsa_ops = {
alsa_close,
alsa_setpar,
alsa_getpar,
alsa_getcap,
alsa_write,
alsa_read,
alsa_start,
alsa_stop,
alsa_nfds,
alsa_pollfd,
alsa_revents,
alsa_setvol,
alsa_getvol
static struct sio_ops sio_alsa_ops = {
sio_alsa_close,
sio_alsa_setpar,
sio_alsa_getpar,
sio_alsa_getcap,
sio_alsa_write,
sio_alsa_read,
sio_alsa_start,
sio_alsa_stop,
sio_alsa_nfds,
sio_alsa_pollfd,
sio_alsa_revents,
sio_alsa_setvol,
sio_alsa_getvol
};
/*
* convert ALSA format to sio_par encoding
*/
static int
alsa_fmttopar(struct alsa_hdl *hdl, snd_pcm_format_t fmt, struct sio_par *par)
sio_alsa_fmttopar(struct sio_alsa_hdl *hdl, snd_pcm_format_t fmt, struct sio_par *par)
{
switch (fmt) {
case SND_PCM_FORMAT_U8:
@ -147,7 +147,7 @@ alsa_fmttopar(struct alsa_hdl *hdl, snd_pcm_format_t fmt, struct sio_par *par)
par->le = 0;
break;
default:
DPRINTF("alsa_fmttopar: 0x%x: unsupported format\n", fmt);
DPRINTF("sio_alsa_fmttopar: 0x%x: unsupported format\n", fmt);
hdl->sio.eof = 1;
return 0;
}
@ -161,7 +161,7 @@ alsa_fmttopar(struct alsa_hdl *hdl, snd_pcm_format_t fmt, struct sio_par *par)
* convert sio_par encoding to ALSA format
*/
static void
alsa_enctofmt(struct alsa_hdl *hdl, snd_pcm_format_t *rfmt, struct sio_par *enc)
sio_alsa_enctofmt(struct sio_alsa_hdl *hdl, snd_pcm_format_t *rfmt, struct sio_par *enc)
{
if (enc->bits == 8) {
if (enc->sig == ~0U || !enc->sig)
@ -220,12 +220,12 @@ alsa_enctofmt(struct alsa_hdl *hdl, snd_pcm_format_t *rfmt, struct sio_par *enc)
*/
#if 0
static int
alsa_tryinfo(struct alsa_hdl *hdl, struct sio_enc *enc,
sio_alsa_tryinfo(struct sio_alsa_hdl *hdl, struct sio_enc *enc,
unsigned pchan, unsigned rchan, unsigned rate)
{
snd_pcm_format_t fmt;
alsa_enctofmt(hdl, &fmt, enc);
sio_alsa_enctofmt(hdl, &fmt, enc);
if (hdl->sio.mode & SIO_PLAY) {
if (snd_pcm_hw_params_test_format(hdl->out_pcm, hdl->out_hwp,
fmt) < 0)
@ -267,25 +267,25 @@ alsa_tryinfo(struct alsa_hdl *hdl, struct sio_enc *enc,
* guess device capabilities
*/
static int
alsa_getcap(struct sio_hdl *sh, struct sio_cap *cap)
sio_alsa_getcap(struct sio_hdl *sh, struct sio_cap *cap)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
DPRINTF("alsa_getcap: not implemented\n");
DPRINTF("sio_alsa_getcap: not implemented\n");
hdl->sio.eof = 1;
return 0;
}
static void
alsa_getvol(struct sio_hdl *sh)
sio_alsa_getvol(struct sio_hdl *sh)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
sio_onvol_cb(&hdl->sio, SIO_MAXVOL);
}
int
alsa_setvol(struct sio_hdl *sh, unsigned vol)
sio_alsa_setvol(struct sio_hdl *sh, unsigned vol)
{
return 1;
}
@ -293,15 +293,15 @@ alsa_setvol(struct sio_hdl *sh, unsigned vol)
struct sio_hdl *
sio_open_alsa(const char *str, unsigned mode, int nbio)
{
struct alsa_hdl *hdl;
struct sio_alsa_hdl *hdl;
char path[PATH_MAX];
struct sio_par par;
int err;
hdl = malloc(sizeof(struct alsa_hdl));
hdl = malloc(sizeof(struct sio_alsa_hdl));
if (hdl == NULL)
return NULL;
sio_create(&hdl->sio, &alsa_ops, mode, nbio);
sio_create(&hdl->sio, &sio_alsa_ops, mode, nbio);
snprintf(path, sizeof(path), "hw:%s", str);
@ -406,9 +406,9 @@ bad_free:
}
static void
alsa_close(struct sio_hdl *sh)
sio_alsa_close(struct sio_hdl *sh)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
if (hdl->sio.mode & SIO_PLAY) {
snd_pcm_close(hdl->out_pcm);
@ -424,12 +424,12 @@ alsa_close(struct sio_hdl *sh)
}
static int
alsa_start(struct sio_hdl *sh)
sio_alsa_start(struct sio_hdl *sh)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
int err;
DPRINTF("alsa_start:\n");
DPRINTF("sio_alsa_start:\n");
hdl->ibpf = hdl->par.rchan * hdl->par.bps;
hdl->obpf = hdl->par.pchan * hdl->par.bps;
@ -448,7 +448,7 @@ alsa_start(struct sio_hdl *sh)
if (hdl->sio.mode & SIO_PLAY) {
err = snd_pcm_prepare(hdl->out_pcm);
if (err < 0) {
DALSA("alsa_start: prepare playback failed", err);
DALSA("sio_alsa_start: prepare playback failed", err);
hdl->sio.eof = 1;
return 0;
}
@ -456,7 +456,7 @@ alsa_start(struct sio_hdl *sh)
if (hdl->sio.mode & SIO_REC) {
err = snd_pcm_prepare(hdl->in_pcm);
if (err < 0) {
DALSA("alsa_start: prepare record failed", err);
DALSA("sio_alsa_start: prepare record failed", err);
hdl->sio.eof = 1;
return 0;
}
@ -468,7 +468,7 @@ alsa_start(struct sio_hdl *sh)
} else {
err = snd_pcm_start(hdl->in_pcm);
if (err < 0) {
DALSA("alsa_start: start record failed", err);
DALSA("sio_alsa_start: start record failed", err);
hdl->sio.eof = 1;
return 0;
}
@ -477,15 +477,15 @@ alsa_start(struct sio_hdl *sh)
}
static int
alsa_stop(struct sio_hdl *sh)
sio_alsa_stop(struct sio_hdl *sh)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
int err;
if (hdl->sio.mode & SIO_PLAY) {
err = snd_pcm_drop(hdl->out_pcm);
if (err < 0) {
DALSA("alsa_stop: drop/close playback failed", err);
DALSA("sio_alsa_stop: drop/close playback failed", err);
hdl->sio.eof = 1;
return 0;
}
@ -493,7 +493,7 @@ alsa_stop(struct sio_hdl *sh)
if (hdl->sio.mode & SIO_REC) {
err = snd_pcm_drop(hdl->in_pcm);
if (err < 0) {
DALSA("alsa_stop: drop/close record failed", err);
DALSA("sio_alsa_stop: drop/close record failed", err);
hdl->sio.eof = 1;
return 0;
}
@ -503,9 +503,9 @@ alsa_stop(struct sio_hdl *sh)
}
static int
alsa_setpar(struct sio_hdl *sh, struct sio_par *par)
sio_alsa_setpar(struct sio_hdl *sh, struct sio_par *par)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
unsigned bufsz, round;
unsigned irate, orate, req_rate;
unsigned ich, och;
@ -517,7 +517,7 @@ alsa_setpar(struct sio_hdl *sh, struct sio_par *par)
/*
* set encoding
*/
alsa_enctofmt(hdl, &ofmt, par);
sio_alsa_enctofmt(hdl, &ofmt, par);
DPRINTF("ofmt = %u\n", ofmt);
if (hdl->sio.mode & SIO_PLAY) {
err = snd_pcm_hw_params_any(hdl->out_pcm, hdl->out_hwp);
@ -586,7 +586,7 @@ alsa_setpar(struct sio_hdl *sh, struct sio_par *par)
hdl->sio.eof = 1;
return 0;
}
if (!alsa_fmttopar(hdl, ofmt, &hdl->par))
if (!sio_alsa_fmttopar(hdl, ofmt, &hdl->par))
return 0;
/*
@ -678,7 +678,7 @@ alsa_setpar(struct sio_hdl *sh, struct sio_par *par)
} else
return 1;
DPRINTF("alsa_setpar: trying bufsz = %u, round = %u\n", bufsz, round);
DPRINTF("sio_alsa_setpar: trying bufsz = %u, round = %u\n", bufsz, round);
obufsz = bufsz;
if (hdl->sio.mode & SIO_PLAY) {
@ -689,7 +689,7 @@ alsa_setpar(struct sio_hdl *sh, struct sio_par *par)
hdl->sio.eof = 1;
return 0;
}
DPRINTF("alsa_setpar: obufsz: ok\n");
DPRINTF("sio_alsa_setpar: obufsz: ok\n");
}
ibufsz = obufsz;
if (hdl->sio.mode & SIO_REC) {
@ -719,7 +719,7 @@ alsa_setpar(struct sio_hdl *sh, struct sio_par *par)
hdl->sio.eof = 1;
return 0;
}
DPRINTF("alsa_setpar: onfr: ok\n");
DPRINTF("sio_alsa_setpar: onfr: ok\n");
}
infr = onfr;
if (hdl->sio.mode & SIO_REC) {
@ -740,7 +740,7 @@ alsa_setpar(struct sio_hdl *sh, struct sio_par *par)
}
hdl->par.round = onfr;
DPRINTF("alsa_setpar: got bufsz = %u, round = %u\n",
DPRINTF("sio_alsa_setpar: got bufsz = %u, round = %u\n",
hdl->par.bufsz, hdl->par.round);
@ -754,7 +754,7 @@ alsa_setpar(struct sio_hdl *sh, struct sio_par *par)
hdl->sio.eof = 1;
return 0;
}
DPRINTF("alsa_setpar: out_hwp: ok\n");
DPRINTF("sio_alsa_setpar: out_hwp: ok\n");
}
if (hdl->sio.mode & SIO_REC) {
err = snd_pcm_hw_params(hdl->in_pcm, hdl->in_hwp);
@ -824,14 +824,14 @@ alsa_setpar(struct sio_hdl *sh, struct sio_par *par)
return 0;
}
}
DPRINTF("alsa_setpar: done\n");
DPRINTF("sio_alsa_setpar: done\n");
return 1;
}
static int
alsa_getpar(struct sio_hdl *sh, struct sio_par *par)
sio_alsa_getpar(struct sio_hdl *sh, struct sio_par *par)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
*par = hdl->par;
return 1;
@ -841,7 +841,7 @@ alsa_getpar(struct sio_hdl *sh, struct sio_par *par)
* drop recorded samples to compensate xruns
*/
static int
alsa_rdrop(struct alsa_hdl *hdl)
sio_alsa_rdrop(struct sio_alsa_hdl *hdl)
{
#define DROP_NMAX 0x1000
static char dropbuf[DROP_NMAX];
@ -854,41 +854,41 @@ alsa_rdrop(struct alsa_hdl *hdl)
if (todo > drop_nmax)
todo = drop_nmax;
while ((n = snd_pcm_readi(hdl->in_pcm, dropbuf, todo)) < 0) {
DALSA("alsa_rdrop: readi", n);
DALSA("sio_alsa_rdrop: readi", n);
hdl->sio.eof = 1;
return 0;
}
if (n == 0) {
DPRINTF("alsa_rdrop: eof\n");
DPRINTF("sio_alsa_rdrop: eof\n");
hdl->sio.eof = 1;
return 0;
}
hdl->offset -= (int)n;
//hdl->isfr += (int)n;
DPRINTF("alsa_rdrop: dropped %ld/%ld frames\n", n, todo);
DPRINTF("sio_alsa_rdrop: dropped %ld/%ld frames\n", n, todo);
}
return 1;
}
static size_t
alsa_read(struct sio_hdl *sh, void *buf, size_t len)
sio_alsa_read(struct sio_hdl *sh, void *buf, size_t len)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
snd_pcm_sframes_t n;
snd_pcm_uframes_t todo;
if (!alsa_rdrop(hdl))
if (!sio_alsa_rdrop(hdl))
return 0;
todo = len / hdl->ibpf;
while ((n = snd_pcm_readi(hdl->in_pcm, buf, todo)) < 0) {
if (n == -ESTRPIPE)
continue;
DALSA("alsa_read: read", n);
DALSA("sio_alsa_read: read", n);
hdl->sio.eof = 1;
return 0;
}
if (n == 0) {
DPRINTF("alsa_read: eof\n");
DPRINTF("sio_alsa_read: eof\n");
hdl->sio.eof = 1;
return 0;
}
@ -898,7 +898,7 @@ alsa_read(struct sio_hdl *sh, void *buf, size_t len)
}
static size_t
alsa_autostart(struct alsa_hdl *hdl)
sio_alsa_autostart(struct sio_alsa_hdl *hdl)
{
int state, err;
@ -906,16 +906,16 @@ alsa_autostart(struct alsa_hdl *hdl)
if (state == SND_PCM_STATE_PREPARED) {
err = snd_pcm_start(hdl->out_pcm);
if (err < 0) {
DALSA("alsa_autostart: failed", err);
DALSA("sio_alsa_autostart: failed", err);
hdl->sio.eof = 1;
return 0;
}
} else {
DPRINTF("alsa_autostart: bad state");
DPRINTF("sio_alsa_autostart: bad state");
hdl->sio.eof = 1;
return 0;
}
DPRINTF("alsa_autostart: started\n");
DPRINTF("sio_alsa_autostart: started\n");
sio_onmove_cb(&hdl->sio, 0);
return 1;
}
@ -924,7 +924,7 @@ alsa_autostart(struct alsa_hdl *hdl)
* insert silence to play to compensate xruns
*/
static int
alsa_wsil(struct alsa_hdl *hdl)
sio_alsa_wsil(struct sio_alsa_hdl *hdl)
{
#define ZERO_NMAX 0x1000
static char zero[ZERO_NMAX];
@ -933,40 +933,40 @@ alsa_wsil(struct alsa_hdl *hdl)
int zero_nmax = ZERO_NMAX / hdl->obpf;
while (hdl->offset < 0) {
DPRINTF("alsa_wsil:\n");
DPRINTF("sio_alsa_wsil:\n");
todo = (int)-hdl->offset;
if (todo > zero_nmax)
todo = zero_nmax;
if ((n = snd_pcm_writei(hdl->out_pcm, zero, todo)) < 0) {
DALSA("alsa_wsil", n);
DALSA("sio_alsa_wsil", n);
hdl->sio.eof = 1;
return 0;
}
hdl->offset += (int)n;
//hdl->osfr += (int)n;
DPRINTF("alsa_wsil: inserted %ld/%ld frames\n", n, todo);
DPRINTF("sio_alsa_wsil: inserted %ld/%ld frames\n", n, todo);
}
return 1;
}
static size_t
alsa_write(struct sio_hdl *sh, const void *buf, size_t len)
sio_alsa_write(struct sio_hdl *sh, const void *buf, size_t len)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
ssize_t n, todo;
if (!alsa_wsil(hdl))
if (!sio_alsa_wsil(hdl))
return 0;
todo = len / hdl->obpf;
if (hdl->filling && todo > hdl->filltodo)
todo = hdl->filltodo;
DPRINTF("alsa_write: len = %zd, todo = %zd\n", len, todo);
DPRINTF("sio_alsa_write: len = %zd, todo = %zd\n", len, todo);
while ((n = snd_pcm_writei(hdl->out_pcm, buf, todo)) < 0) {
if (n == -EINTR)
continue;
if (n != -EAGAIN) {
DALSA("alsa_write", n);
DALSA("sio_alsa_write", n);
hdl->sio.eof = 1;
}
return 0;
@ -976,7 +976,7 @@ alsa_write(struct sio_hdl *sh, const void *buf, size_t len)
hdl->filltodo -= n;
if (hdl->filltodo == 0) {
hdl->filling = 0;
if (!alsa_autostart(hdl))
if (!sio_alsa_autostart(hdl))
return 0;
}
}
@ -986,21 +986,21 @@ alsa_write(struct sio_hdl *sh, const void *buf, size_t len)
}
static int
alsa_nfds(struct sio_hdl *sh)
sio_alsa_nfds(struct sio_hdl *sh)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
return hdl->nfds;
}
static int
alsa_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
sio_alsa_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
int i;
DPRINTF("alsa_pollfd: count = %d\n",
DPRINTF("sio_alsa_pollfd: count = %d\n",
snd_pcm_poll_descriptors_count(hdl->out_pcm));
memset(pfd, 0, sizeof(struct pollfd) * hdl->nfds);
@ -1013,33 +1013,33 @@ alsa_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
hdl->infds = snd_pcm_poll_descriptors(hdl->in_pcm,
pfd + hdl->onfds, hdl->nfds - hdl->onfds);
}
DPRINTF("alsa_pollfd: events = %x, nfds = %d + %d\n",
DPRINTF("sio_alsa_pollfd: events = %x, nfds = %d + %d\n",
events, hdl->onfds, hdl->infds);
for (i = 0; i < hdl->onfds + hdl->infds; i++) {
DPRINTF("alsa_pollfd: pfds[%d].events = %x\n",
DPRINTF("sio_alsa_pollfd: pfds[%d].events = %x\n",
i, pfd[i].events);
}
return hdl->onfds + hdl->infds;
}
int
alsa_revents(struct sio_hdl *sh, struct pollfd *pfd)
sio_alsa_revents(struct sio_hdl *sh, struct pollfd *pfd)
{
struct alsa_hdl *hdl = (struct alsa_hdl *)sh;
struct sio_alsa_hdl *hdl = (struct sio_alsa_hdl *)sh;
snd_pcm_sframes_t idelay, odelay;
snd_pcm_state_t istate, ostate;
int hw_ptr, nfds;
unsigned short revents, all_revents;
int err;
DPRINTF("alsa_revents:\n");
DPRINTF("sio_alsa_revents:\n");
all_revents = nfds = 0;
if (hdl->sio.mode & SIO_PLAY) {
revents = 0;
ostate = snd_pcm_state(hdl->out_pcm);
if (ostate == SND_PCM_STATE_XRUN) {
fprintf(stderr, "alsa_revents: play xrun\n");
fprintf(stderr, "sio_alsa_revents: play xrun\n");
}
err = snd_pcm_poll_descriptors_revents(hdl->out_pcm, pfd, hdl->onfds, &revents);
if (err < 0) {
@ -1048,7 +1048,7 @@ alsa_revents(struct sio_hdl *sh, struct pollfd *pfd)
return POLLHUP;
}
if (revents & POLLERR)
DPRINTF("alsa_revents: play POLLERR\n");
DPRINTF("sio_alsa_revents: play POLLERR\n");
all_revents |= revents;
nfds += hdl->onfds;
}
@ -1056,21 +1056,21 @@ alsa_revents(struct sio_hdl *sh, struct pollfd *pfd)
revents = 0;
istate = snd_pcm_state(hdl->in_pcm);
if (istate == SND_PCM_STATE_XRUN) {
printf("alsa_revents: record xrun\n");
printf("sio_alsa_revents: record xrun\n");
}
err = snd_pcm_poll_descriptors_revents(hdl->in_pcm, pfd + nfds, hdl->infds, &revents);
if (err < 0) {
DALSA("alsa_revents: snd_pcm_poll_descriptors_revents/rec", err);
DALSA("sio_alsa_revents: snd_pcm_poll_descriptors_revents/rec", err);
hdl->sio.eof = 1;
return POLLHUP;
}
if (revents & POLLERR)
DPRINTF("alsa_revents: record xrun?\n");
DPRINTF("sio_alsa_revents: record xrun?\n");
all_revents |= revents;
nfds += hdl->infds;
}
revents = all_revents;
DPRINTF("alsa_revents: revents = %x\n", revents);
DPRINTF("sio_alsa_revents: revents = %x\n", revents);
#if 0
if ((revents & POLLOUT) && (hdl->sio.mode & SIO_PLAY) &&
@ -1078,18 +1078,18 @@ alsa_revents(struct sio_hdl *sh, struct pollfd *pfd)
ostate == SND_PCM_STATE_PREPARED)) {
err = snd_pcm_avail_update(hdl->out_pcm);
if (err < 0) {
DALSA("alsa_revents: play snd_pcm_avail_update", err);
DALSA("sio_alsa_revents: play snd_pcm_avail_update", err);
hdl->sio.eof = 1;
return POLLHUP;
}
err = snd_pcm_delay(hdl->out_pcm, &odelay);
if (err < 0) {
DALSA("alsa_revents: play snd_pcm_delay", err);
DALSA("sio_alsa_revents: play snd_pcm_delay", err);
hdl->sio.eof = 1;
return POLLHUP;
}
if (odelay < 0) {
printf("alsa_revents: play xrun (delay)\n");
printf("sio_alsa_revents: play xrun (delay)\n");
}
hw_ptr = hdl->osfr - odelay;
hdl->odelta += hw_ptr - hdl->ohfr;
@ -1104,18 +1104,18 @@ alsa_revents(struct sio_hdl *sh, struct pollfd *pfd)
istate == SND_PCM_STATE_PREPARED)) {
err = snd_pcm_avail_update(hdl->in_pcm);
if (err < 0) {
DALSA("alsa_revents: rec snd_pcm_avail_update", err);
DALSA("sio_alsa_revents: rec snd_pcm_avail_update", err);
hdl->sio.eof = 1;
return POLLHUP;
}
err = snd_pcm_delay(hdl->in_pcm, &idelay);
if (err < 0) {
DALSA("alsa_revents: record snd_pcm_delay", err);
DALSA("sio_alsa_revents: record snd_pcm_delay", err);
hdl->sio.eof = 1;
return POLLHUP;
}
if (idelay < 0) {
printf("alsa_revents: record xrun (delay)\n");
printf("sio_alsa_revents: record xrun (delay)\n");
}
hw_ptr = hdl->isfr + idelay;
hdl->idelta += hw_ptr - hdl->ihfr;
@ -1134,9 +1134,9 @@ alsa_revents(struct sio_hdl *sh, struct pollfd *pfd)
if (hdl->sio.started) {
if (hdl->filling)
revents |= POLLOUT;
if ((hdl->sio.mode & SIO_PLAY) && !alsa_wsil(hdl))
if ((hdl->sio.mode & SIO_PLAY) && !sio_alsa_wsil(hdl))
revents &= ~POLLOUT;
if ((hdl->sio.mode & SIO_REC) && !alsa_rdrop(hdl))
if ((hdl->sio.mode & SIO_REC) && !sio_alsa_rdrop(hdl))
revents &= ~POLLIN;
}
#endif

View File

@ -28,12 +28,12 @@
#include <unistd.h>
#include "amsg.h"
#include "sndio_priv.h"
#include "sio_priv.h"
#ifdef COMPAT_STRLCPY
#include "bsd-compat.h"
#endif
struct aucat_hdl {
struct sio_aucat_hdl {
struct sio_hdl sio;
int fd; /* socket */
struct amsg rmsg, wmsg; /* temporary messages */
@ -49,39 +49,39 @@ struct aucat_hdl {
int delta; /* some of received deltas */
};
static void aucat_close(struct sio_hdl *);
static int aucat_start(struct sio_hdl *);
static int aucat_stop(struct sio_hdl *);
static int aucat_setpar(struct sio_hdl *, struct sio_par *);
static int aucat_getpar(struct sio_hdl *, struct sio_par *);
static int aucat_getcap(struct sio_hdl *, struct sio_cap *);
static size_t aucat_read(struct sio_hdl *, void *, size_t);
static size_t aucat_write(struct sio_hdl *, const void *, size_t);
static int aucat_pollfd(struct sio_hdl *, struct pollfd *, int);
static int aucat_revents(struct sio_hdl *, struct pollfd *);
static int aucat_setvol(struct sio_hdl *, unsigned);
static void aucat_getvol(struct sio_hdl *);
static void sio_aucat_close(struct sio_hdl *);
static int sio_aucat_start(struct sio_hdl *);
static int sio_aucat_stop(struct sio_hdl *);
static int sio_aucat_setpar(struct sio_hdl *, struct sio_par *);
static int sio_aucat_getpar(struct sio_hdl *, struct sio_par *);
static int sio_aucat_getcap(struct sio_hdl *, struct sio_cap *);
static size_t sio_aucat_read(struct sio_hdl *, void *, size_t);
static size_t sio_aucat_write(struct sio_hdl *, const void *, size_t);
static int sio_aucat_pollfd(struct sio_hdl *, struct pollfd *, int);
static int sio_aucat_revents(struct sio_hdl *, struct pollfd *);
static int sio_aucat_setvol(struct sio_hdl *, unsigned);
static void sio_aucat_getvol(struct sio_hdl *);
static struct sio_ops aucat_ops = {
aucat_close,
aucat_setpar,
aucat_getpar,
aucat_getcap,
aucat_write,
aucat_read,
aucat_start,
aucat_stop,
aucat_pollfd,
aucat_revents,
aucat_setvol,
aucat_getvol
static struct sio_ops sio_aucat_ops = {
sio_aucat_close,
sio_aucat_setpar,
sio_aucat_getpar,
sio_aucat_getcap,
sio_aucat_write,
sio_aucat_read,
sio_aucat_start,
sio_aucat_stop,
sio_aucat_pollfd,
sio_aucat_revents,
sio_aucat_setvol,
sio_aucat_getvol
};
/*
* read a message, return 0 if blocked
*/
static int
aucat_rmsg(struct aucat_hdl *hdl)
sio_aucat_rmsg(struct sio_aucat_hdl *hdl)
{
ssize_t n;
unsigned char *data;
@ -94,12 +94,12 @@ aucat_rmsg(struct aucat_hdl *hdl)
continue;
if (errno != EAGAIN) {
hdl->sio.eof = 1;
DPERROR("aucat_rmsg: read");
DPERROR("sio_aucat_rmsg: read");
}
return 0;
}
if (n == 0) {
DPRINTF("aucat_rmsg: eof\n");
DPRINTF("sio_aucat_rmsg: eof\n");
hdl->sio.eof = 1;
return 0;
}
@ -112,7 +112,7 @@ aucat_rmsg(struct aucat_hdl *hdl)
* write a message, return 0 if blocked
*/
static int
aucat_wmsg(struct aucat_hdl *hdl)
sio_aucat_wmsg(struct sio_aucat_hdl *hdl)
{
ssize_t n;
unsigned char *data;
@ -125,7 +125,7 @@ aucat_wmsg(struct aucat_hdl *hdl)
continue;
if (errno != EAGAIN) {
hdl->sio.eof = 1;
DPERROR("aucat_wmsg: write");
DPERROR("sio_aucat_wmsg: write");
}
return 0;
}
@ -138,15 +138,15 @@ aucat_wmsg(struct aucat_hdl *hdl)
* execute the next message, return 0 if blocked
*/
static int
aucat_runmsg(struct aucat_hdl *hdl)
sio_aucat_runmsg(struct sio_aucat_hdl *hdl)
{
if (!aucat_rmsg(hdl))
if (!sio_aucat_rmsg(hdl))
return 0;
switch (hdl->rmsg.cmd) {
case AMSG_DATA:
if (hdl->rmsg.u.data.size == 0 ||
hdl->rmsg.u.data.size % hdl->rbpf) {
DPRINTF("aucat_runmsg: bad data message\n");
DPRINTF("sio_aucat_runmsg: bad data message\n");
hdl->sio.eof = 1;
return 0;
}
@ -185,7 +185,7 @@ aucat_runmsg(struct aucat_hdl *hdl)
hdl->rtodo = 0xdeadbeef;
break;
default:
DPRINTF("aucat_runmsg: unknown message\n");
DPRINTF("sio_aucat_runmsg: unknown message\n");
hdl->sio.eof = 1;
return 0;
}
@ -193,12 +193,12 @@ aucat_runmsg(struct aucat_hdl *hdl)
}
struct sio_hdl *
sio_open_aucat(const char *str, unsigned mode, int nbio)
sio_aucat_open(const char *str, unsigned mode, int nbio)
{
extern char *__progname;
int s;
char unit[4], *sep, *opt;
struct aucat_hdl *hdl;
struct sio_aucat_hdl *hdl;
struct sockaddr_un ca;
socklen_t len = sizeof(struct sockaddr_un);
uid_t uid;
@ -223,10 +223,10 @@ sio_open_aucat(const char *str, unsigned mode, int nbio)
"/tmp/aucat-%u/softaudio%s", uid, unit);
ca.sun_family = AF_UNIX;
hdl = malloc(sizeof(struct aucat_hdl));
hdl = malloc(sizeof(struct sio_aucat_hdl));
if (hdl == NULL)
return NULL;
sio_create(&hdl->sio, &aucat_ops, mode, nbio);
sio_create(&hdl->sio, &sio_aucat_ops, mode, nbio);
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0)
@ -270,10 +270,10 @@ sio_open_aucat(const char *str, unsigned mode, int nbio)
strlcpy(hdl->wmsg.u.hello.opt, opt,
sizeof(hdl->wmsg.u.hello.opt));
hdl->wtodo = sizeof(struct amsg);
if (!aucat_wmsg(hdl))
if (!sio_aucat_wmsg(hdl))
goto bad_connect;
hdl->rtodo = sizeof(struct amsg);
if (!aucat_rmsg(hdl)) {
if (!sio_aucat_rmsg(hdl)) {
DPRINTF("sio_open_aucat: mode refused\n");
goto bad_connect;
}
@ -291,18 +291,18 @@ sio_open_aucat(const char *str, unsigned mode, int nbio)
}
static void
aucat_close(struct sio_hdl *sh)
sio_aucat_close(struct sio_hdl *sh)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
char dummy[1];
if (!hdl->sio.eof && hdl->sio.started)
(void)aucat_stop(&hdl->sio);
(void)sio_aucat_stop(&hdl->sio);
if (!hdl->sio.eof) {
AMSG_INIT(&hdl->wmsg);
hdl->wmsg.cmd = AMSG_BYE;
hdl->wtodo = sizeof(struct amsg);
if (!aucat_wmsg(hdl))
if (!sio_aucat_wmsg(hdl))
goto bad_close;
while (read(hdl->fd, dummy, 1) < 0 && errno == EINTR)
; /* nothing */
@ -314,9 +314,9 @@ aucat_close(struct sio_hdl *sh)
}
static int
aucat_start(struct sio_hdl *sh)
sio_aucat_start(struct sio_hdl *sh)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
struct sio_par par;
/*
@ -333,12 +333,12 @@ aucat_start(struct sio_hdl *sh)
AMSG_INIT(&hdl->wmsg);
hdl->wmsg.cmd = AMSG_START;
hdl->wtodo = sizeof(struct amsg);
if (!aucat_wmsg(hdl))
if (!sio_aucat_wmsg(hdl))
return 0;
hdl->rstate = STATE_MSG;
hdl->rtodo = sizeof(struct amsg);
if (fcntl(hdl->fd, F_SETFL, O_NONBLOCK) < 0) {
DPERROR("aucat_start: fcntl(0)");
DPERROR("sio_aucat_start: fcntl(0)");
hdl->sio.eof = 1;
return 0;
}
@ -346,15 +346,15 @@ aucat_start(struct sio_hdl *sh)
}
static int
aucat_stop(struct sio_hdl *sh)
sio_aucat_stop(struct sio_hdl *sh)
{
#define ZERO_MAX 0x400
static unsigned char zero[ZERO_MAX];
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
unsigned n, count;
if (fcntl(hdl->fd, F_SETFL, 0) < 0) {
DPERROR("aucat_stop: fcntl(0)");
DPERROR("sio_aucat_stop: fcntl(0)");
hdl->sio.eof = 1;
return 0;
}
@ -363,7 +363,7 @@ aucat_stop(struct sio_hdl *sh)
* complete message or data block in progress
*/
if (hdl->wstate == STATE_MSG) {
if (!aucat_wmsg(hdl))
if (!sio_aucat_wmsg(hdl))
return 0;
if (hdl->wmsg.cmd == AMSG_DATA) {
hdl->wstate = STATE_DATA;
@ -377,7 +377,7 @@ aucat_stop(struct sio_hdl *sh)
count = hdl->wtodo;
if (count > ZERO_MAX)
count = ZERO_MAX;
n = aucat_write(&hdl->sio, zero, count);
n = sio_aucat_write(&hdl->sio, zero, count);
if (n == 0)
return 0;
}
@ -389,7 +389,7 @@ aucat_stop(struct sio_hdl *sh)
AMSG_INIT(&hdl->wmsg);
hdl->wmsg.cmd = AMSG_STOP;
hdl->wtodo = sizeof(struct amsg);
if (!aucat_wmsg(hdl))
if (!sio_aucat_wmsg(hdl))
return 0;
if (hdl->rstate == STATE_IDLE) {
hdl->rstate = STATE_MSG;
@ -402,11 +402,11 @@ aucat_stop(struct sio_hdl *sh)
while (hdl->rstate != STATE_IDLE) {
switch (hdl->rstate) {
case STATE_MSG:
if (!aucat_runmsg(hdl))
if (!sio_aucat_runmsg(hdl))
return 0;
break;
case STATE_DATA:
if (!aucat_read(&hdl->sio, zero, ZERO_MAX))
if (!sio_aucat_read(&hdl->sio, zero, ZERO_MAX))
return 0;
break;
}
@ -415,9 +415,9 @@ aucat_stop(struct sio_hdl *sh)
}
static int
aucat_setpar(struct sio_hdl *sh, struct sio_par *par)
sio_aucat_setpar(struct sio_hdl *sh, struct sio_par *par)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
AMSG_INIT(&hdl->wmsg);
hdl->wmsg.cmd = AMSG_SETPAR;
@ -434,26 +434,26 @@ aucat_setpar(struct sio_hdl *sh, struct sio_par *par)
if (hdl->sio.mode & SIO_PLAY)
hdl->wmsg.u.par.pchan = par->pchan;
hdl->wtodo = sizeof(struct amsg);
if (!aucat_wmsg(hdl))
if (!sio_aucat_wmsg(hdl))
return 0;
return 1;
}
static int
aucat_getpar(struct sio_hdl *sh, struct sio_par *par)
sio_aucat_getpar(struct sio_hdl *sh, struct sio_par *par)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
AMSG_INIT(&hdl->wmsg);
hdl->wmsg.cmd = AMSG_GETPAR;
hdl->wtodo = sizeof(struct amsg);
if (!aucat_wmsg(hdl))
if (!sio_aucat_wmsg(hdl))
return 0;
hdl->rtodo = sizeof(struct amsg);
if (!aucat_rmsg(hdl))
if (!sio_aucat_rmsg(hdl))
return 0;
if (hdl->rmsg.cmd != AMSG_GETPAR) {
DPRINTF("aucat_getpar: protocol err\n");
DPRINTF("sio_aucat_getpar: protocol err\n");
hdl->sio.eof = 1;
return 0;
}
@ -475,22 +475,22 @@ aucat_getpar(struct sio_hdl *sh, struct sio_par *par)
}
static int
aucat_getcap(struct sio_hdl *sh, struct sio_cap *cap)
sio_aucat_getcap(struct sio_hdl *sh, struct sio_cap *cap)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
unsigned i, bps, le, sig, chan, rindex, rmult;
static unsigned rates[] = { 8000, 11025, 12000 };
AMSG_INIT(&hdl->wmsg);
hdl->wmsg.cmd = AMSG_GETCAP;
hdl->wtodo = sizeof(struct amsg);
if (!aucat_wmsg(hdl))
if (!sio_aucat_wmsg(hdl))
return 0;
hdl->rtodo = sizeof(struct amsg);
if (!aucat_rmsg(hdl))
if (!sio_aucat_rmsg(hdl))
return 0;
if (hdl->rmsg.cmd != AMSG_GETCAP) {
DPRINTF("aucat_getcap: protocol err\n");
DPRINTF("sio_aucat_getcap: protocol err\n");
hdl->sio.eof = 1;
return 0;
}
@ -563,19 +563,19 @@ aucat_getcap(struct sio_hdl *sh, struct sio_cap *cap)
}
static size_t
aucat_read(struct sio_hdl *sh, void *buf, size_t len)
sio_aucat_read(struct sio_hdl *sh, void *buf, size_t len)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
ssize_t n;
while (hdl->rstate != STATE_DATA) {
switch (hdl->rstate) {
case STATE_MSG:
if (!aucat_runmsg(hdl))
if (!sio_aucat_runmsg(hdl))
return 0;
break;
case STATE_IDLE:
DPRINTF("aucat_read: unexpected idle state\n");
DPRINTF("sio_aucat_read: unexpected idle state\n");
hdl->sio.eof = 1;
return 0;
}
@ -587,12 +587,12 @@ aucat_read(struct sio_hdl *sh, void *buf, size_t len)
continue;
if (errno != EAGAIN) {
hdl->sio.eof = 1;
DPERROR("aucat_read: read");
DPERROR("sio_aucat_read: read");
}
return 0;
}
if (n == 0) {
DPRINTF("aucat_read: eof\n");
DPRINTF("sio_aucat_read: eof\n");
hdl->sio.eof = 1;
return 0;
}
@ -606,7 +606,7 @@ aucat_read(struct sio_hdl *sh, void *buf, size_t len)
}
static int
aucat_buildmsg(struct aucat_hdl *hdl, size_t len)
sio_aucat_buildmsg(struct sio_aucat_hdl *hdl, size_t len)
{
unsigned sz;
@ -636,19 +636,19 @@ aucat_buildmsg(struct aucat_hdl *hdl, size_t len)
}
static size_t
aucat_write(struct sio_hdl *sh, const void *buf, size_t len)
sio_aucat_write(struct sio_hdl *sh, const void *buf, size_t len)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
ssize_t n;
while (hdl->wstate != STATE_DATA) {
switch (hdl->wstate) {
case STATE_IDLE:
if (!aucat_buildmsg(hdl, len))
if (!sio_aucat_buildmsg(hdl, len))
return 0;
/* PASSTHROUGH */
case STATE_MSG:
if (!aucat_wmsg(hdl))
if (!sio_aucat_wmsg(hdl))
return 0;
if (hdl->wmsg.cmd == AMSG_DATA) {
hdl->wstate = STATE_DATA;
@ -657,7 +657,7 @@ aucat_write(struct sio_hdl *sh, const void *buf, size_t len)
hdl->wstate = STATE_IDLE;
break;
default:
DPRINTF("aucat_write: bad state\n");
DPRINTF("sio_aucat_write: bad state\n");
abort();
}
}
@ -668,7 +668,7 @@ aucat_write(struct sio_hdl *sh, const void *buf, size_t len)
if (len > hdl->wtodo)
len = hdl->wtodo;
if (len == 0) {
DPRINTF("aucat_write: len == 0\n");
DPRINTF("sio_aucat_write: len == 0\n");
abort();
}
while ((n = write(hdl->fd, buf, len)) < 0) {
@ -676,7 +676,7 @@ aucat_write(struct sio_hdl *sh, const void *buf, size_t len)
continue;
if (errno != EAGAIN) {
hdl->sio.eof = 1;
DPERROR("aucat_write: write");
DPERROR("sio_aucat_write: write");
}
return 0;
}
@ -691,9 +691,9 @@ aucat_write(struct sio_hdl *sh, const void *buf, size_t len)
}
static int
aucat_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
sio_aucat_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
hdl->events = events;
if (hdl->maxwrite <= 0)
@ -707,14 +707,14 @@ aucat_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
}
static int
aucat_revents(struct sio_hdl *sh, struct pollfd *pfd)
sio_aucat_revents(struct sio_hdl *sh, struct pollfd *pfd)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
int revents = pfd->revents;
if (revents & POLLIN) {
while (hdl->rstate == STATE_MSG) {
if (!aucat_runmsg(hdl)) {
if (!sio_aucat_runmsg(hdl)) {
revents &= ~POLLIN;
break;
}
@ -731,18 +731,18 @@ aucat_revents(struct sio_hdl *sh, struct pollfd *pfd)
}
static int
aucat_setvol(struct sio_hdl *sh, unsigned vol)
sio_aucat_setvol(struct sio_hdl *sh, unsigned vol)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
hdl->reqvol = vol;
return 1;
}
static void
aucat_getvol(struct sio_hdl *sh)
sio_aucat_getvol(struct sio_hdl *sh)
{
struct aucat_hdl *hdl = (struct aucat_hdl *)sh;
struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh;
sio_onvol_cb(&hdl->sio, hdl->reqvol);
return;

View File

@ -77,9 +77,9 @@ struct sio_ops {
void (*getvol)(struct sio_hdl *);
};
struct sio_hdl *sio_open_aucat(const char *, unsigned, int);
struct sio_hdl *sio_aucat_open(const char *, unsigned, int);
#ifdef USE_SUN
struct sio_hdl *sio_open_sun(const char *, unsigned, int);
struct sio_hdl *sio_sun_open(const char *, unsigned, int);
#endif
#ifdef USE_ALSA
struct sio_hdl *sio_open_alsa(const char *, unsigned, int);

View File

@ -17,11 +17,11 @@
/*
* TODO:
*
* remove filling code from sun_write() and create sun_fill()
* remove filling code from sio_sun_write() and create sio_sun_fill()
*
* allow block size to be set
*
* call hdl->cb_pos() from sun_read() and sun_write(), or better:
* call hdl->cb_pos() from sio_sun_read() and sio_sun_write(), or better:
* implement generic blocking sio_read() and sio_write() with poll(2)
* and use non-blocking sio_ops only
*/
@ -41,9 +41,9 @@
#include <string.h>
#include <unistd.h>
#include "sndio_priv.h"
#include "sio_priv.h"
struct sun_hdl {
struct sio_sun_hdl {
struct sio_hdl sio;
int fd;
int filling;
@ -55,28 +55,28 @@ struct sun_hdl {
int mix_fd, mix_index; /* /dev/mixerN stuff */
};
static void sun_close(struct sio_hdl *);
static int sun_start(struct sio_hdl *);
static int sun_stop(struct sio_hdl *);
static int sun_setpar(struct sio_hdl *, struct sio_par *);
static int sun_getpar(struct sio_hdl *, struct sio_par *);
static int sun_getcap(struct sio_hdl *, struct sio_cap *);
static size_t sun_read(struct sio_hdl *, void *, size_t);
static size_t sun_write(struct sio_hdl *, const void *, size_t);
static int sun_pollfd(struct sio_hdl *, struct pollfd *, int);
static int sun_revents(struct sio_hdl *, struct pollfd *);
static void sio_sun_close(struct sio_hdl *);
static int sio_sun_start(struct sio_hdl *);
static int sio_sun_stop(struct sio_hdl *);
static int sio_sun_setpar(struct sio_hdl *, struct sio_par *);
static int sio_sun_getpar(struct sio_hdl *, struct sio_par *);
static int sio_sun_getcap(struct sio_hdl *, struct sio_cap *);
static size_t sio_sun_read(struct sio_hdl *, void *, size_t);
static size_t sio_sun_write(struct sio_hdl *, const void *, size_t);
static int sio_sun_pollfd(struct sio_hdl *, struct pollfd *, int);
static int sio_sun_revents(struct sio_hdl *, struct pollfd *);
static struct sio_ops sun_ops = {
sun_close,
sun_setpar,
sun_getpar,
sun_getcap,
sun_write,
sun_read,
sun_start,
sun_stop,
sun_pollfd,
sun_revents,
static struct sio_ops sio_sun_ops = {
sio_sun_close,
sio_sun_setpar,
sio_sun_getpar,
sio_sun_getcap,
sio_sun_write,
sio_sun_read,
sio_sun_start,
sio_sun_stop,
sio_sun_pollfd,
sio_sun_revents,
NULL, /* setvol */
NULL, /* getvol */
};
@ -85,7 +85,7 @@ static struct sio_ops sun_ops = {
* convert sun encoding to sio_par encoding
*/
static int
sun_infotoenc(struct sun_hdl *hdl, struct audio_prinfo *ai, struct sio_par *par)
sio_sun_infotoenc(struct sio_sun_hdl *hdl, struct audio_prinfo *ai, struct sio_par *par)
{
par->msb = ai->msb;
par->bits = ai->precision;
@ -116,7 +116,7 @@ sun_infotoenc(struct sun_hdl *hdl, struct audio_prinfo *ai, struct sio_par *par)
par->sig = 0;
break;
default:
DPRINTF("sun_infotoenc: unsupported encoding\n");
DPRINTF("sio_sun_infotoenc: unsupported encoding\n");
hdl->sio.eof = 1;
return 0;
}
@ -127,7 +127,7 @@ sun_infotoenc(struct sun_hdl *hdl, struct audio_prinfo *ai, struct sio_par *par)
* convert sio_par encoding to sun encoding
*/
static void
sun_enctoinfo(struct sun_hdl *hdl, unsigned *renc, struct sio_par *par)
sio_sun_enctoinfo(struct sio_sun_hdl *hdl, unsigned *renc, struct sio_par *par)
{
if (par->le == ~0U && par->sig == ~0U) {
*renc = ~0U;
@ -149,7 +149,7 @@ sun_enctoinfo(struct sun_hdl *hdl, unsigned *renc, struct sio_par *par)
* device can use them; return 1 on success, 0 on failure or error
*/
static int
sun_tryinfo(struct sun_hdl *hdl, struct sio_enc *enc,
sio_sun_tryinfo(struct sio_sun_hdl *hdl, struct sio_enc *enc,
unsigned pchan, unsigned rchan, unsigned rate)
{
struct audio_info aui;
@ -181,12 +181,12 @@ sun_tryinfo(struct sun_hdl *hdl, struct sio_enc *enc,
if (ioctl(hdl->fd, AUDIO_SETINFO, &aui) < 0) {
if (errno == EINVAL)
return 0;
DPERROR("sun_tryinfo: setinfo");
DPERROR("sio_sun_tryinfo: setinfo");
hdl->sio.eof = 1;
return 0;
}
if (ioctl(hdl->fd, AUDIO_GETINFO, &aui) < 0) {
DPERROR("sun_tryinfo: getinfo");
DPERROR("sio_sun_tryinfo: getinfo");
hdl->sio.eof = 1;
return 0;
}
@ -209,7 +209,7 @@ sun_tryinfo(struct sun_hdl *hdl, struct sio_enc *enc,
* guess device capabilities
*/
static int
sun_getcap(struct sio_hdl *sh, struct sio_cap *cap)
sio_sun_getcap(struct sio_hdl *sh, struct sio_cap *cap)
{
#define NCHANS (sizeof(chans) / sizeof(chans[0]))
#define NRATES (sizeof(rates) / sizeof(rates[0]))
@ -220,14 +220,14 @@ sun_getcap(struct sio_hdl *sh, struct sio_cap *cap)
8000, 11025, 12000, 16000, 22050, 24000,
32000, 44100, 48000, 64000, 88200, 96000
};
struct sun_hdl *hdl = (struct sun_hdl *)sh;
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
struct sio_par savepar;
struct audio_encoding ae;
unsigned nenc = 0, nconf = 0;
unsigned enc_map = 0, rchan_map = 0, pchan_map = 0, rate_map;
unsigned i, j, conf;
if (!sun_getpar(&hdl->sio, &savepar))
if (!sio_sun_getpar(&hdl->sio, &savepar))
return 0;
/*
@ -237,7 +237,7 @@ sun_getcap(struct sio_hdl *sh, struct sio_cap *cap)
if (ioctl(hdl->fd, AUDIO_GETENC, &ae) < 0) {
if (errno == EINVAL)
break;
DPERROR("sun_getcap: getenc");
DPERROR("sio_sun_getcap: getenc");
hdl->sio.eof = 1;
return 0;
}
@ -282,14 +282,14 @@ sun_getcap(struct sio_hdl *sh, struct sio_cap *cap)
if (hdl->sio.mode & SIO_PLAY) {
memcpy(&cap->pchan, chans, NCHANS * sizeof(unsigned));
for (i = 0; i < NCHANS; i++) {
if (sun_tryinfo(hdl, NULL, chans[i], 0, 0))
if (sio_sun_tryinfo(hdl, NULL, chans[i], 0, 0))
pchan_map |= (1 << i);
}
}
if (hdl->sio.mode & SIO_REC) {
memcpy(&cap->rchan, chans, NCHANS * sizeof(unsigned));
for (i = 0; i < NCHANS; i++) {
if (sun_tryinfo(hdl, NULL, 0, chans[i], 0))
if (sio_sun_tryinfo(hdl, NULL, 0, chans[i], 0))
rchan_map |= (1 << i);
}
}
@ -305,7 +305,7 @@ sun_getcap(struct sio_hdl *sh, struct sio_cap *cap)
for (j = 0; j < nenc; j++) {
rate_map = 0;
for (i = 0; i < NRATES; i++) {
if (sun_tryinfo(hdl, &cap->enc[j], 0, 0, rates[i]))
if (sio_sun_tryinfo(hdl, &cap->enc[j], 0, 0, rates[i]))
rate_map |= (1 << i);
}
for (conf = 0; conf < nconf; conf++) {
@ -325,7 +325,7 @@ sun_getcap(struct sio_hdl *sh, struct sio_cap *cap)
}
}
cap->nconf = nconf;
if (!sun_setpar(&hdl->sio, &savepar))
if (!sio_sun_setpar(&hdl->sio, &savepar))
return 0;
return 1;
#undef NCHANS
@ -333,18 +333,18 @@ sun_getcap(struct sio_hdl *sh, struct sio_cap *cap)
}
struct sio_hdl *
sio_open_sun(const char *str, unsigned mode, int nbio)
sio_sun_open(const char *str, unsigned mode, int nbio)
{
int fd, flags, fullduplex;
struct audio_info aui;
struct sun_hdl *hdl;
struct sio_sun_hdl *hdl;
struct sio_par par;
char path[PATH_MAX];
hdl = malloc(sizeof(struct sun_hdl));
hdl = malloc(sizeof(struct sio_sun_hdl));
if (hdl == NULL)
return NULL;
sio_create(&hdl->sio, &sun_ops, mode, nbio);
sio_create(&hdl->sio, &sio_sun_ops, mode, nbio);
snprintf(path, sizeof(path), "/dev/audio%s", str);
if (mode == (SIO_PLAY | SIO_REC))
@ -413,9 +413,9 @@ sio_open_sun(const char *str, unsigned mode, int nbio)
}
static void
sun_close(struct sio_hdl *sh)
sio_sun_close(struct sio_hdl *sh)
{
struct sun_hdl *hdl = (struct sun_hdl *)sh;
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
while (close(hdl->fd) < 0 && errno == EINTR)
; /* retry */
@ -423,10 +423,10 @@ sun_close(struct sio_hdl *sh)
}
static int
sun_start(struct sio_hdl *sh)
sio_sun_start(struct sio_hdl *sh)
{
struct sio_par par;
struct sun_hdl *hdl = (struct sun_hdl *)sh;
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
struct audio_info aui;
if (!sio_getpar(&hdl->sio, &par))
@ -443,7 +443,7 @@ sun_start(struct sio_hdl *sh)
if (hdl->sio.mode & SIO_PLAY) {
/*
* keep the device paused and let sun_write() trigger the
* keep the device paused and let sio_sun_write() trigger the
* start later, to avoid buffer underruns
*/
hdl->filling = 1;
@ -455,7 +455,7 @@ sun_start(struct sio_hdl *sh)
if (hdl->sio.mode & SIO_REC)
aui.record.pause = 0;
if (ioctl(hdl->fd, AUDIO_SETINFO, &aui) < 0) {
DPERROR("sun_start: setinfo");
DPERROR("sio_sun_start: setinfo");
hdl->sio.eof = 1;
return 0;
}
@ -466,14 +466,14 @@ sun_start(struct sio_hdl *sh)
}
static int
sun_stop(struct sio_hdl *sh)
sio_sun_stop(struct sio_hdl *sh)
{
struct sun_hdl *hdl = (struct sun_hdl *)sh;
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
struct audio_info aui;
int mode;
if (ioctl(hdl->fd, AUDIO_GETINFO, &aui) < 0) {
DPERROR("sun_stop: getinfo");
DPERROR("sio_sun_stop: getinfo");
hdl->sio.eof = 1;
return 0;
}
@ -490,14 +490,14 @@ sun_stop(struct sio_hdl *sh)
if (hdl->sio.mode & SIO_REC)
aui.record.pause = 1;
if (ioctl(hdl->fd, AUDIO_SETINFO, &aui) < 0) {
DPERROR("sun_stop: setinfo1");
DPERROR("sio_sun_stop: setinfo1");
hdl->sio.eof = 1;
return 0;
}
AUDIO_INITINFO(&aui);
aui.mode = mode;
if (ioctl(hdl->fd, AUDIO_SETINFO, &aui) < 0) {
DPERROR("sun_stop: setinfo2");
DPERROR("sio_sun_stop: setinfo2");
hdl->sio.eof = 1;
return 0;
}
@ -505,10 +505,10 @@ sun_stop(struct sio_hdl *sh)
}
static int
sun_setpar(struct sio_hdl *sh, struct sio_par *par)
sio_sun_setpar(struct sio_hdl *sh, struct sio_par *par)
{
#define NRETRIES 8
struct sun_hdl *hdl = (struct sun_hdl *)sh;
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
struct audio_info aui;
unsigned i, infr, ibpf, onfr, obpf;
unsigned bufsz, round;
@ -520,10 +520,10 @@ sun_setpar(struct sio_hdl *sh, struct sio_par *par)
*/
rate = par->rate;
prec = par->bits;
sun_enctoinfo(hdl, &enc, par);
sio_sun_enctoinfo(hdl, &enc, par);
for (i = 0;; i++) {
if (i == NRETRIES) {
DPRINTF("sun_setpar: couldn't set parameters\n");
DPRINTF("sio_sun_setpar: couldn't set parameters\n");
hdl->sio.eof = 1;
return 0;
}
@ -540,15 +540,15 @@ sun_setpar(struct sio_hdl *sh, struct sio_par *par)
aui.record.encoding = enc;
aui.record.channels = par->rchan;
}
DPRINTF("sun_setpar: %i: trying pars = %u/%u/%u\n",
DPRINTF("sio_sun_setpar: %i: trying pars = %u/%u/%u\n",
i, rate, prec, enc);
if (ioctl(hdl->fd, AUDIO_SETINFO, &aui) < 0 && errno != EINVAL) {
DPERROR("sun_setpar: setinfo(pars)");
DPERROR("sio_sun_setpar: setinfo(pars)");
hdl->sio.eof = 1;
return 0;
}
if (ioctl(hdl->fd, AUDIO_GETINFO, &aui) < 0) {
DPERROR("sun_setpar: getinfo(pars)");
DPERROR("sio_sun_setpar: getinfo(pars)");
hdl->sio.eof = 1;
return 0;
}
@ -563,7 +563,7 @@ sun_setpar(struct sio_hdl *sh, struct sio_par *par)
case AUDIO_ENCODING_ULINEAR:
break;
default:
DPRINTF("sun_setpar: couldn't set linear encoding\n");
DPRINTF("sio_sun_setpar: couldn't set linear encoding\n");
hdl->sio.eof = 1;
return 0;
}
@ -619,7 +619,7 @@ sun_setpar(struct sio_hdl *sh, struct sio_par *par)
* get the play/record frame size in bytes
*/
if (ioctl(hdl->fd, AUDIO_GETINFO, &aui) < 0) {
DPERROR("sun_setpar: GETINFO");
DPERROR("sio_sun_setpar: GETINFO");
hdl->sio.eof = 1;
return 0;
}
@ -628,7 +628,7 @@ sun_setpar(struct sio_hdl *sh, struct sio_par *par)
obpf = (hdl->sio.mode & SIO_PLAY) ?
aui.play.channels * aui.play.bps : 1;
DPRINTF("sun_setpar: bpf = (%u, %u)\n", ibpf, obpf);
DPRINTF("sio_sun_setpar: bpf = (%u, %u)\n", ibpf, obpf);
/*
* try to set parameters until the device accepts
@ -643,25 +643,25 @@ sun_setpar(struct sio_hdl *sh, struct sio_par *par)
if (hdl->sio.mode & SIO_PLAY)
aui.play.block_size = round * obpf;
if (ioctl(hdl->fd, AUDIO_SETINFO, &aui) < 0) {
DPERROR("sun_setpar2: SETINFO");
DPERROR("sio_sun_setpar2: SETINFO");
hdl->sio.eof = 1;
return 0;
}
if (ioctl(hdl->fd, AUDIO_GETINFO, &aui) < 0) {
DPERROR("sun_setpar2: GETINFO");
DPERROR("sio_sun_setpar2: GETINFO");
hdl->sio.eof = 1;
return 0;
}
infr = aui.record.block_size / ibpf;
onfr = aui.play.block_size / obpf;
DPRINTF("sun_setpar: %i: trying round = %u -> (%u, %u)\n",
DPRINTF("sio_sun_setpar: %i: trying round = %u -> (%u, %u)\n",
i, round, infr, onfr);
/*
* if half-duplex or both block sizes match, we're done
*/
if (hdl->sio.mode != (SIO_REC | SIO_PLAY) || infr == onfr) {
DPRINTF("sun_setpar: blocksize ok\n");
DPRINTF("sio_sun_setpar: blocksize ok\n");
return 1;
}
@ -674,30 +674,30 @@ sun_setpar(struct sio_hdl *sh, struct sio_par *par)
else
round = infr < onfr ? onfr : infr;
}
DPRINTF("sun_setpar: couldn't find a working blocksize\n");
DPRINTF("sio_sun_setpar: couldn't find a working blocksize\n");
hdl->sio.eof = 1;
return 0;
#undef NRETRIES
}
static int
sun_getpar(struct sio_hdl *sh, struct sio_par *par)
sio_sun_getpar(struct sio_hdl *sh, struct sio_par *par)
{
struct sun_hdl *hdl = (struct sun_hdl *)sh;
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
struct audio_info aui;
if (ioctl(hdl->fd, AUDIO_GETINFO, &aui) < 0) {
DPERROR("sun_getpar: getinfo");
DPERROR("sio_sun_getpar: getinfo");
hdl->sio.eof = 1;
return 0;
}
if (hdl->sio.mode & SIO_PLAY) {
par->rate = aui.play.sample_rate;
if (!sun_infotoenc(hdl, &aui.play, par))
if (!sio_sun_infotoenc(hdl, &aui.play, par))
return 0;
} else if (hdl->sio.mode & SIO_REC) {
par->rate = aui.record.sample_rate;
if (!sun_infotoenc(hdl, &aui.record, par))
if (!sio_sun_infotoenc(hdl, &aui.record, par))
return 0;
} else
return 0;
@ -717,7 +717,7 @@ sun_getpar(struct sio_hdl *sh, struct sio_par *par)
* drop recorded samples to compensate xruns
*/
static int
sun_rdrop(struct sun_hdl *hdl)
sio_sun_rdrop(struct sio_sun_hdl *hdl)
{
#define DROP_NMAX 0x1000
static char dropbuf[DROP_NMAX];
@ -731,41 +731,41 @@ sun_rdrop(struct sun_hdl *hdl)
if (errno == EINTR)
continue;
if (errno != EAGAIN) {
DPERROR("sun_rdrop: read");
DPERROR("sio_sun_rdrop: read");
hdl->sio.eof = 1;
}
return 0;
}
if (n == 0) {
DPRINTF("sun_rdrop: eof\n");
DPRINTF("sio_sun_rdrop: eof\n");
hdl->sio.eof = 1;
return 0;
}
hdl->offset -= (int)n / (int)hdl->ibpf;
DPRINTF("sun_rdrop: dropped %ld/%ld bytes\n", n, todo);
DPRINTF("sio_sun_rdrop: dropped %ld/%ld bytes\n", n, todo);
}
return 1;
}
static size_t
sun_read(struct sio_hdl *sh, void *buf, size_t len)
sio_sun_read(struct sio_hdl *sh, void *buf, size_t len)
{
struct sun_hdl *hdl = (struct sun_hdl *)sh;
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
ssize_t n;
if (!sun_rdrop(hdl))
if (!sio_sun_rdrop(hdl))
return 0;
while ((n = read(hdl->fd, buf, len)) < 0) {
if (errno == EINTR)
continue;
if (errno != EAGAIN) {
DPERROR("sun_read: read");
DPERROR("sio_sun_read: read");
hdl->sio.eof = 1;
}
return 0;
}
if (n == 0) {
DPRINTF("sun_read: eof\n");
DPRINTF("sio_sun_read: eof\n");
hdl->sio.eof = 1;
return 0;
}
@ -773,7 +773,7 @@ sun_read(struct sio_hdl *sh, void *buf, size_t len)
}
static size_t
sun_autostart(struct sun_hdl *hdl)
sio_sun_autostart(struct sio_sun_hdl *hdl)
{
struct audio_info aui;
struct pollfd pfd;
@ -783,7 +783,7 @@ sun_autostart(struct sun_hdl *hdl)
while (poll(&pfd, 1, 0) < 0) {
if (errno == EINTR)
continue;
DPERROR("sun_autostart: poll");
DPERROR("sio_sun_autostart: poll");
hdl->sio.eof = 1;
return 0;
}
@ -795,7 +795,7 @@ sun_autostart(struct sun_hdl *hdl)
if (hdl->sio.mode & SIO_REC)
aui.record.pause = 0;
if (ioctl(hdl->fd, AUDIO_SETINFO, &aui) < 0) {
DPERROR("sun_autostart: setinfo");
DPERROR("sio_sun_autostart: setinfo");
hdl->sio.eof = 1;
return 0;
}
@ -808,7 +808,7 @@ sun_autostart(struct sun_hdl *hdl)
* insert silence to play to compensate xruns
*/
static int
sun_wsil(struct sun_hdl *hdl)
sio_sun_wsil(struct sio_sun_hdl *hdl)
{
#define ZERO_NMAX 0x1000
static char zero[ZERO_NMAX];
@ -822,49 +822,49 @@ sun_wsil(struct sun_hdl *hdl)
if (errno == EINTR)
continue;
if (errno != EAGAIN) {
DPERROR("sun_wsil: write");
DPERROR("sio_sun_wsil: write");
hdl->sio.eof = 1;
return 0;
}
return 0;
}
hdl->offset += (int)n / (int)hdl->obpf;
DPRINTF("sun_wsil: inserted %ld/%ld bytes\n", n, todo);
DPRINTF("sio_sun_wsil: inserted %ld/%ld bytes\n", n, todo);
}
return 1;
}
static size_t
sun_write(struct sio_hdl *sh, const void *buf, size_t len)
sio_sun_write(struct sio_hdl *sh, const void *buf, size_t len)
{
struct sun_hdl *hdl = (struct sun_hdl *)sh;
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
const unsigned char *data = buf;
ssize_t n, todo;
if (!sun_wsil(hdl))
if (!sio_sun_wsil(hdl))
return 0;
todo = len;
while ((n = write(hdl->fd, data, todo)) < 0) {
if (errno == EINTR)
continue;
if (errno != EAGAIN) {
DPERROR("sun_write: write");
DPERROR("sio_sun_write: write");
hdl->sio.eof = 1;
}
return 0;
}
if (hdl->filling) {
if (!sun_autostart(hdl))
if (!sio_sun_autostart(hdl))
return 0;
}
return n;
}
static int
sun_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
sio_sun_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
{
struct sun_hdl *hdl = (struct sun_hdl *)sh;
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
pfd->fd = hdl->fd;
pfd->events = events;
@ -872,9 +872,9 @@ sun_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events)
}
int
sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
sio_sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
{
struct sun_hdl *hdl = (struct sun_hdl *)sh;
struct sio_sun_hdl *hdl = (struct sio_sun_hdl *)sh;
struct audio_offset ao;
int xrun, dmove, dierr = 0, doerr = 0, delta;
int revents = pfd->revents;
@ -883,7 +883,7 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
return pfd->revents;
if (hdl->sio.mode & SIO_PLAY) {
if (ioctl(hdl->fd, AUDIO_PERROR, &xrun) < 0) {
DPERROR("sun_revents: PERROR");
DPERROR("sio_sun_revents: PERROR");
hdl->sio.eof = 1;
return POLLHUP;
}
@ -894,7 +894,7 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
}
if (hdl->sio.mode & SIO_REC) {
if (ioctl(hdl->fd, AUDIO_RERROR, &xrun) < 0) {
DPERROR("sun_revents: RERROR");
DPERROR("sio_sun_revents: RERROR");
hdl->sio.eof = 1;
return POLLHUP;
}
@ -910,7 +910,7 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
if ((revents & POLLOUT) && (hdl->sio.mode & SIO_PLAY)) {
if (ioctl(hdl->fd, AUDIO_GETOOFFS, &ao) < 0) {
DPERROR("sun_revents: GETOOFFS");
DPERROR("sio_sun_revents: GETOOFFS");
hdl->sio.eof = 1;
return POLLHUP;
}
@ -922,7 +922,7 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
}
if ((revents & POLLIN) && (hdl->sio.mode & SIO_REC)) {
if (ioctl(hdl->fd, AUDIO_GETIOFFS, &ao) < 0) {
DPERROR("sun_revents: GETIOFFS");
DPERROR("sio_sun_revents: GETIOFFS");
hdl->sio.eof = 1;
return POLLHUP;
}
@ -946,9 +946,9 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
*/
if (hdl->filling)
revents |= POLLOUT;
if ((hdl->sio.mode & SIO_PLAY) && !sun_wsil(hdl))
if ((hdl->sio.mode & SIO_PLAY) && !sio_sun_wsil(hdl))
revents &= ~POLLOUT;
if ((hdl->sio.mode & SIO_REC) && !sun_rdrop(hdl))
if ((hdl->sio.mode & SIO_REC) && !sio_sun_rdrop(hdl))
revents &= ~POLLIN;
return revents;
}