mirror of https://github.com/ericonr/sndio.git
Merge branch 'master' into mixer
This commit is contained in:
commit
d3be2d30ca
|
@ -63,11 +63,11 @@ sio_open(const char *str, unsigned int mode, int nbio)
|
||||||
if (hdl != NULL)
|
if (hdl != NULL)
|
||||||
return hdl;
|
return hdl;
|
||||||
#if defined(USE_SUN)
|
#if defined(USE_SUN)
|
||||||
return _sio_sun_open("rsnd/0", mode, nbio);
|
return _sio_sun_open("rsnd/default", mode, nbio);
|
||||||
#elif defined(USE_OSS)
|
#elif defined(USE_OSS)
|
||||||
return _sio_oss_open("rsnd/0", mode, nbio);
|
return _sio_oss_open("rsnd/default", mode, nbio);
|
||||||
#elif defined(USE_ALSA)
|
#elif defined(USE_ALSA)
|
||||||
return _sio_alsa_open("rsnd/0", mode, nbio);
|
return _sio_alsa_open("rsnd/default", mode, nbio);
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -304,6 +304,8 @@ _sio_alsa_open(const char *str, unsigned mode, int nbio)
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
DALSA("couldn't attach to stderr", err);
|
DALSA("couldn't attach to stderr", err);
|
||||||
#endif
|
#endif
|
||||||
|
if (strcmp(p, "default") == 0)
|
||||||
|
p = "0";
|
||||||
len = strlen(p);
|
len = strlen(p);
|
||||||
hdl->devname = malloc(len + sizeof(DEVNAME_PREFIX));
|
hdl->devname = malloc(len + sizeof(DEVNAME_PREFIX));
|
||||||
if (hdl->devname == NULL)
|
if (hdl->devname == NULL)
|
||||||
|
|
|
@ -108,6 +108,8 @@ static int sio_oss_xrun(struct sio_oss_hdl *);
|
||||||
static size_t sio_oss_read(struct sio_hdl *, void *, size_t);
|
static size_t sio_oss_read(struct sio_hdl *, void *, size_t);
|
||||||
static size_t sio_oss_write(struct sio_hdl *, const void *, size_t);
|
static size_t sio_oss_write(struct sio_hdl *, const void *, size_t);
|
||||||
static void sio_oss_close(struct sio_hdl *);
|
static void sio_oss_close(struct sio_hdl *);
|
||||||
|
static int sio_oss_setvol(struct sio_hdl *, unsigned int);
|
||||||
|
static void sio_oss_getvol(struct sio_hdl *);
|
||||||
|
|
||||||
static struct sio_ops sio_oss_ops = {
|
static struct sio_ops sio_oss_ops = {
|
||||||
sio_oss_close,
|
sio_oss_close,
|
||||||
|
@ -121,8 +123,8 @@ static struct sio_ops sio_oss_ops = {
|
||||||
sio_oss_nfds,
|
sio_oss_nfds,
|
||||||
sio_oss_pollfd,
|
sio_oss_pollfd,
|
||||||
sio_oss_revents,
|
sio_oss_revents,
|
||||||
NULL, /* setvol */
|
sio_oss_setvol,
|
||||||
NULL, /* getvol */
|
sio_oss_getvol,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -234,6 +236,7 @@ sio_oss_getfd(const char *str, unsigned int mode, int nbio)
|
||||||
char path[DEVPATH_MAX];
|
char path[DEVPATH_MAX];
|
||||||
unsigned int devnum;
|
unsigned int devnum;
|
||||||
int fd, flags, val;
|
int fd, flags, val;
|
||||||
|
audio_buf_info bi;
|
||||||
|
|
||||||
p = _sndio_parsetype(str, "rsnd");
|
p = _sndio_parsetype(str, "rsnd");
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
|
@ -248,12 +251,16 @@ sio_oss_getfd(const char *str, unsigned int mode, int nbio)
|
||||||
DPRINTF("sio_oss_getfd: %s: '/' expected\n", str);
|
DPRINTF("sio_oss_getfd: %s: '/' expected\n", str);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p = _sndio_parsenum(p, &devnum, 255);
|
if (strcmp(p, "default") == 0) {
|
||||||
if (p == NULL || *p != '\0') {
|
strlcpy(path, DEVPATH_PREFIX, sizeof(path));
|
||||||
DPRINTF("sio_oss_getfd: %s: number expected after '/'\n", str);
|
} else {
|
||||||
return -1;
|
p = _sndio_parsenum(p, &devnum, 255);
|
||||||
|
if (p == NULL || *p != '\0') {
|
||||||
|
DPRINTF("sio_sun_getfd: %s: number expected after '/'\n", str);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
snprintf(path, sizeof(path), DEVPATH_PREFIX "%u", devnum);
|
||||||
}
|
}
|
||||||
snprintf(path, sizeof(path), DEVPATH_PREFIX "%u", devnum);
|
|
||||||
if (mode == (SIO_PLAY | SIO_REC))
|
if (mode == (SIO_PLAY | SIO_REC))
|
||||||
flags = O_RDWR;
|
flags = O_RDWR;
|
||||||
else
|
else
|
||||||
|
@ -763,4 +770,40 @@ sio_oss_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
||||||
return revents;
|
return revents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
sio_oss_setvol(struct sio_hdl *sh, unsigned int vol)
|
||||||
|
{
|
||||||
|
struct sio_oss_hdl *hdl = (struct sio_oss_hdl *)sh;
|
||||||
|
int newvol;
|
||||||
|
|
||||||
|
/* Scale to 0..100 */
|
||||||
|
newvol = (100 * vol + SIO_MAXVOL / 2) / SIO_MAXVOL;
|
||||||
|
newvol = newvol | (newvol << 8);
|
||||||
|
|
||||||
|
if (ioctl(hdl->fd, SNDCTL_DSP_SETPLAYVOL, &newvol) < 0) {
|
||||||
|
DPERROR("sio_oss_setvol");
|
||||||
|
hdl->sio.eof = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sio_oss_getvol(struct sio_hdl *sh)
|
||||||
|
{
|
||||||
|
struct sio_oss_hdl *hdl = (struct sio_oss_hdl *)sh;
|
||||||
|
int vol;
|
||||||
|
|
||||||
|
if (ioctl(hdl->fd, SNDCTL_DSP_GETPLAYVOL, &vol) < 0) {
|
||||||
|
DPERROR("sio_oss_getvol");
|
||||||
|
hdl->sio.eof = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use left channel volume and scale to SIO_MAXVOL */
|
||||||
|
vol = (SIO_MAXVOL * (vol & 0x7f) + 50) / 100;
|
||||||
|
_sio_onvol_cb(&hdl->sio, vol);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* defined USE_OSS */
|
#endif /* defined USE_OSS */
|
||||||
|
|
|
@ -291,10 +291,14 @@ sio_sun_getfd(const char *str, unsigned int mode, int nbio)
|
||||||
DPRINTF("sio_sun_getfd: %s: '/' expected\n", str);
|
DPRINTF("sio_sun_getfd: %s: '/' expected\n", str);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
p = _sndio_parsenum(p, &devnum, 255);
|
if (strcmp(p, "default") == 0) {
|
||||||
if (p == NULL || *p != '\0') {
|
devnum = 0;
|
||||||
DPRINTF("sio_sun_getfd: %s: number expected after '/'\n", str);
|
} else {
|
||||||
return -1;
|
p = _sndio_parsenum(p, &devnum, 255);
|
||||||
|
if (p == NULL || *p != '\0') {
|
||||||
|
DPRINTF("sio_sun_getfd: %s: number expected after '/'\n", str);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
snprintf(path, sizeof(path), DEVPATH_PREFIX "%u", devnum);
|
snprintf(path, sizeof(path), DEVPATH_PREFIX "%u", devnum);
|
||||||
if (mode == (SIO_PLAY | SIO_REC))
|
if (mode == (SIO_PLAY | SIO_REC))
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
* default device in server mode
|
* default device in server mode
|
||||||
*/
|
*/
|
||||||
#ifndef DEFAULT_DEV
|
#ifndef DEFAULT_DEV
|
||||||
#define DEFAULT_DEV "rsnd/0"
|
#define DEFAULT_DEV "rsnd/default"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void sigint(int);
|
void sigint(int);
|
||||||
|
|
Loading…
Reference in New Issue