mirror of https://github.com/ericonr/sndio.git
add initial alsa support from jakemsr
This commit is contained in:
parent
f268454989
commit
a17607cf7a
|
@ -0,0 +1,19 @@
|
||||||
|
all:
|
||||||
|
cd libsndio && ${MAKE}
|
||||||
|
cd aucat && ${MAKE}
|
||||||
|
|
||||||
|
install:
|
||||||
|
cd libsndio && ${MAKE} install
|
||||||
|
cd aucat && ${MAKE} install
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
cd libsndio && ${MAKE} uninstall
|
||||||
|
cd aucat && ${MAKE} uninstall
|
||||||
|
|
||||||
|
clean:
|
||||||
|
cd libsndio && ${MAKE} clean
|
||||||
|
cd aucat && ${MAKE} clean
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm -f Makefile libsndio/Makefile aucat/Makefile
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
# extra includes paths (-I options)
|
||||||
|
INCLUDE = -I../libsndio -I../bsd-compat
|
||||||
|
|
||||||
|
# extra libraries paths (-L options)
|
||||||
|
LIB = -L../libsndio
|
||||||
|
|
||||||
|
# extra defines (-D options)
|
||||||
|
DEFS = -DDEBUG @defs@
|
||||||
|
|
||||||
|
# extra libraries (-l options)
|
||||||
|
LDADD = -lsndio @ldadd@
|
||||||
|
|
||||||
|
# variables defined on configure script command line (if any)
|
||||||
|
@vars@
|
||||||
|
|
||||||
|
#
|
||||||
|
# binaries, documentation, man pages and examples will be installed in
|
||||||
|
# ${BIN_DIR}, ${MAN1_DIR}
|
||||||
|
#
|
||||||
|
BIN_DIR = @bindir@
|
||||||
|
MAN1_DIR = @mandir@/man1
|
||||||
|
|
||||||
|
#
|
||||||
|
# programs to build
|
||||||
|
#
|
||||||
|
PROG = aucat midicat
|
||||||
|
MAN1 = aucat.1 midicat.1
|
||||||
|
|
||||||
|
all: ${PROG}
|
||||||
|
|
||||||
|
install:
|
||||||
|
mkdir -p ${DESTDIR}${BIN_DIR} ${DESTDIR}${MAN1_DIR}
|
||||||
|
cp aucat ${DESTDIR}${BIN_DIR}
|
||||||
|
cd ${DESTDIR}${BIN_DIR} && ln -f aucat midicat
|
||||||
|
cp ${MAN1} ${DESTDIR}${MAN1_DIR}
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
cd ${DESTDIR}${BIN_DIR} && rm -f ${PROG}
|
||||||
|
cd ${DESTDIR}${MAN1_DIR} && rm -f ${MAN1}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f -- ${PROG} *.o *~ *.bak *.tmp *.core core
|
||||||
|
|
||||||
|
# ---------------------------------------------------------- dependencies ---
|
||||||
|
|
||||||
|
OBJS = \
|
||||||
|
abuf.o aparams.o aproc.o aucat.o dbg.o dev.o file.o headers.o \
|
||||||
|
listen.o midi.o miofile.o opt.o pipe.o siofile.o sock.o \
|
||||||
|
wav.o
|
||||||
|
|
||||||
|
aucat: ${OBJS}
|
||||||
|
${CC} ${LDFLAGS} ${LIB} -o aucat ${OBJS} ${LDADD}
|
||||||
|
|
||||||
|
midicat: aucat
|
||||||
|
ln -f aucat midicat
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
${CC} ${CFLAGS} ${INCLUDE} ${DEFS} -c $<
|
||||||
|
|
||||||
|
abuf.o: abuf.c abuf.h aparams.h aproc.h file.h conf.h dbg.h
|
||||||
|
aparams.o: aparams.c aparams.h dbg.h
|
||||||
|
aproc.o: aproc.c abuf.h aparams.h aproc.h file.h conf.h midi.h \
|
||||||
|
dbg.h
|
||||||
|
aucat.o: aucat.c abuf.h aparams.h aproc.h file.h conf.h dev.h \
|
||||||
|
listen.h midi.h opt.h wav.h pipe.h dbg.h \
|
||||||
|
../bsd-compat/bsd-compat.h
|
||||||
|
dbg.o: dbg.c dbg.h
|
||||||
|
dev.o: dev.c abuf.h aproc.h aparams.h file.h conf.h dev.h \
|
||||||
|
pipe.h miofile.h siofile.h midi.h opt.h dbg.h
|
||||||
|
file.o: file.c abuf.h aproc.h aparams.h file.h conf.h dbg.h
|
||||||
|
headers.o: headers.c aparams.h conf.h wav.h pipe.h file.h \
|
||||||
|
../bsd-compat/bsd-compat.h
|
||||||
|
legacy.o: legacy.c wav.h aparams.h pipe.h file.h \
|
||||||
|
../bsd-compat/bsd-compat.h
|
||||||
|
listen.o: listen.c conf.h listen.h aparams.h file.h sock.h amsg.h \
|
||||||
|
pipe.h ../bsd-compat/bsd-compat.h
|
||||||
|
midi.o: midi.c abuf.h aproc.h aparams.h file.h conf.h dev.h \
|
||||||
|
midi.h dbg.h ../bsd-compat/bsd-compat.h
|
||||||
|
miofile.o: miofile.c conf.h file.h miofile.h dbg.h
|
||||||
|
opt.o: opt.c conf.h opt.h aparams.h dbg.h
|
||||||
|
pipe.o: pipe.c conf.h pipe.h file.h dbg.h
|
||||||
|
siofile.o: siofile.c aparams.h aproc.h file.h abuf.h conf.h dev.h \
|
||||||
|
siofile.h dbg.h
|
||||||
|
sock.o: sock.c abuf.h aproc.h aparams.h file.h conf.h dev.h \
|
||||||
|
midi.h opt.h sock.h amsg.h pipe.h dbg.h \
|
||||||
|
../bsd-compat/bsd-compat.h
|
||||||
|
wav.o: wav.c abuf.h aproc.h aparams.h file.h conf.h dev.h \
|
||||||
|
midi.h wav.h pipe.h opt.h dbg.h
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: aucat.c,v 1.103 2010/08/19 06:31:06 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -30,7 +30,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <varargs.h>
|
|
||||||
|
|
||||||
#include "abuf.h"
|
#include "abuf.h"
|
||||||
#include "aparams.h"
|
#include "aparams.h"
|
||||||
|
@ -44,6 +43,9 @@
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef COMPAT_STRTONUM
|
||||||
|
#include "bsd-compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* unprivileged user name
|
* unprivileged user name
|
||||||
|
@ -181,7 +183,7 @@ opt_mode(void)
|
||||||
char *p = optarg;
|
char *p = optarg;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
for (p = optarg; *p != NULL; p++) {
|
for (p = optarg; *p != '\0'; p++) {
|
||||||
len = strcspn(p, ",");
|
len = strcspn(p, ",");
|
||||||
if (strncmp("play", p, len) == 0) {
|
if (strncmp("play", p, len) == 0) {
|
||||||
mode |= MODE_PLAY;
|
mode |= MODE_PLAY;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: file.c,v 1.21 2010/07/10 12:32:45 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -46,6 +46,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
@ -55,6 +56,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "abuf.h"
|
#include "abuf.h"
|
||||||
#include "aproc.h"
|
#include "aproc.h"
|
||||||
|
@ -357,7 +359,7 @@ file_poll(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f = LIST_FIRST(&file_list);
|
f = LIST_FIRST(&file_list);
|
||||||
while (f != LIST_END(&file_list)) {
|
while (f != NULL) {
|
||||||
if (f->pfd == NULL) {
|
if (f->pfd == NULL) {
|
||||||
f = LIST_NEXT(f, entry);
|
f = LIST_NEXT(f, entry);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: headers.c,v 1.18 2010/06/05 16:54:19 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -27,6 +27,9 @@
|
||||||
#include "aparams.h"
|
#include "aparams.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "wav.h"
|
#include "wav.h"
|
||||||
|
#if defined(COMPAT_LETOH) || defined(COMPAT_PACKED)
|
||||||
|
#include "bsd-compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Encoding IDs used in .wav headers.
|
* Encoding IDs used in .wav headers.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: listen.c,v 1.11 2009/09/27 11:51:20 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -31,6 +31,9 @@
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "listen.h"
|
#include "listen.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
|
#ifdef COMPAT_STRLCPY
|
||||||
|
#include "bsd-compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
struct fileops listen_ops = {
|
struct fileops listen_ops = {
|
||||||
"listen",
|
"listen",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: midi.c,v 1.28 2010/07/06 01:12:45 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -35,6 +35,9 @@
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef COMPAT_STRLCPY
|
||||||
|
#include "bsd-compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* input data rate is XFER / TIMO (in bytes per microsecond),
|
* input data rate is XFER / TIMO (in bytes per microsecond),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: sock.c,v 1.50 2010/06/05 16:00:52 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -32,6 +32,9 @@
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef COMPAT_GETPEEREID
|
||||||
|
#include "bsd-compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void sock_attach(struct sock *, int);
|
void sock_attach(struct sock *, int);
|
||||||
int sock_read(struct sock *);
|
int sock_read(struct sock *);
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifdef COMPAT_PACKED
|
||||||
|
#define __packed __attribute__((packed))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef COMPAT_LETOH
|
||||||
|
#include <byteswap.h>
|
||||||
|
#include <endian.h>
|
||||||
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
#define letoh16(x) (x)
|
||||||
|
#define letoh32(x) (x)
|
||||||
|
#define htole16(x) (x)
|
||||||
|
#define htole32(x) (x)
|
||||||
|
#define ntohl(x) bswap_32(x)
|
||||||
|
#else
|
||||||
|
#define letoh16(x) bswap_16(x)
|
||||||
|
#define letoh32(x) bswap_32(x)
|
||||||
|
#define htole16(x) bswap_16(x)
|
||||||
|
#define htole32(x) bswap_32(x)
|
||||||
|
#define ntohl(x) (x)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* prototypes of these don't hurt
|
||||||
|
*/
|
||||||
|
long long strtonum(const char *, long long, long long, const char **);
|
||||||
|
size_t strlcpy(char *, const char *, size_t);
|
||||||
|
int issetugid(void);
|
||||||
|
int getpeereid(int, uid_t *, gid_t *);
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifdef COMPAT_GETPEEREID
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
getpeereid(int s, uid_t *ruid, gid_t *rgid)
|
||||||
|
{
|
||||||
|
struct ucred cr;
|
||||||
|
socklen_t len = sizeof(cr);
|
||||||
|
|
||||||
|
if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &cr, &len) < 0)
|
||||||
|
return -1;
|
||||||
|
*ruid = cr.uid;
|
||||||
|
*rgid = cr.gid;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010 Jacob Meuser <jakemsr@sdf.lonestar.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.
|
||||||
|
*/
|
||||||
|
#ifdef COMPAT_ISSETUGID
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
issetugid(void)
|
||||||
|
{
|
||||||
|
if (getuid() != geteuid())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (getgid() != getegid())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,51 @@
|
||||||
|
/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifdef COMPAT_STRLCPY
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy src to string dst of size siz. At most siz-1 characters
|
||||||
|
* will be copied. Always NUL terminates (unless siz == 0).
|
||||||
|
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
strlcpy(char *dst, const char *src, size_t siz)
|
||||||
|
{
|
||||||
|
char *d = dst;
|
||||||
|
const char *s = src;
|
||||||
|
size_t n = siz;
|
||||||
|
|
||||||
|
/* Copy as many bytes as will fit */
|
||||||
|
if (n != 0) {
|
||||||
|
while (--n != 0) {
|
||||||
|
if ((*d++ = *s++) == '\0')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||||
|
if (n == 0) {
|
||||||
|
if (siz != 0)
|
||||||
|
*d = '\0'; /* NUL-terminate dst */
|
||||||
|
while (*s++)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(s - src - 1); /* count does not include NUL */
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,72 @@
|
||||||
|
/* $OpenBSD: strtonum.c,v 1.6 2004/08/03 19:38:01 millert Exp $ */
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004 Ted Unangst and Todd Miller
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifdef COMPAT_STRTONUM
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef LLONG_MIN
|
||||||
|
#define LLONG_MIN (-LLONG_MAX-1)
|
||||||
|
#endif
|
||||||
|
#ifndef LLONG_MAX
|
||||||
|
#define LLONG_MAX __LONG_LONG_MAX__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define INVALID 1
|
||||||
|
#define TOOSMALL 2
|
||||||
|
#define TOOLARGE 3
|
||||||
|
|
||||||
|
long long
|
||||||
|
strtonum(const char *numstr, long long minval, long long maxval,
|
||||||
|
const char **errstrp)
|
||||||
|
{
|
||||||
|
long long ll = 0;
|
||||||
|
char *ep;
|
||||||
|
int error = 0;
|
||||||
|
struct errval {
|
||||||
|
const char *errstr;
|
||||||
|
int err;
|
||||||
|
} ev[4] = {
|
||||||
|
{ NULL, 0 },
|
||||||
|
{ "invalid", EINVAL },
|
||||||
|
{ "too small", ERANGE },
|
||||||
|
{ "too large", ERANGE },
|
||||||
|
};
|
||||||
|
|
||||||
|
ev[0].err = errno;
|
||||||
|
errno = 0;
|
||||||
|
if (minval > maxval)
|
||||||
|
error = INVALID;
|
||||||
|
else {
|
||||||
|
ll = strtoll(numstr, &ep, 10);
|
||||||
|
if (numstr == ep || *ep != '\0')
|
||||||
|
error = INVALID;
|
||||||
|
else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)
|
||||||
|
error = TOOSMALL;
|
||||||
|
else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval)
|
||||||
|
error = TOOLARGE;
|
||||||
|
}
|
||||||
|
if (errstrp != NULL)
|
||||||
|
*errstrp = ev[error].errstr;
|
||||||
|
errno = ev[error].err;
|
||||||
|
if (error)
|
||||||
|
ll = 0;
|
||||||
|
|
||||||
|
return (ll);
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,149 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# display help screeen
|
||||||
|
#
|
||||||
|
help() {
|
||||||
|
cat << END
|
||||||
|
Usage: configure [options]
|
||||||
|
--prefix=DIR set install prefix to DIR [$prefix]
|
||||||
|
--bindir=DIR install executables in DIR [\$prefix/bin]
|
||||||
|
--datadir=DIR install read-only data in DIR [\$prefix/share]
|
||||||
|
--includedir=DIR install header files in DIR [\$prefix/include]
|
||||||
|
--libdir=DIR install libraries in DIR [\$prefix/lib]
|
||||||
|
--mandir=DIR install man pages in DIR [\$prefix/man]
|
||||||
|
--enable-alsa enable alsa backend [$alsa]
|
||||||
|
--disable-alsa disable alsa backend
|
||||||
|
--enable-sun enable sun backend [$sun]
|
||||||
|
--disable-sun disable sun backend
|
||||||
|
END
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# defaults
|
||||||
|
#
|
||||||
|
prefix=/usr/local # where to install sndio
|
||||||
|
so="libsndio.so.\${MAJ}.\${MIN}" # shared libs to build
|
||||||
|
alsa=no # do we want alsa support ?
|
||||||
|
sun=no # do we want sun support ?
|
||||||
|
unset vars # variables passed as arguments
|
||||||
|
unset bindir # path where to install binaries
|
||||||
|
unset datadir # path where to install doc
|
||||||
|
unset mandir # path where to install man pages
|
||||||
|
unset includedir # path where to install header file
|
||||||
|
unset libdir # path where to install library
|
||||||
|
unset defs # no extra #defines
|
||||||
|
unset ldadd # no extra libraries (-l options)
|
||||||
|
|
||||||
|
if [ `uname` = Linux ]; then
|
||||||
|
alsa=yes
|
||||||
|
so="$so libsndio.so.\${MAJ}"
|
||||||
|
so="$so libsndio.so"
|
||||||
|
defs='-DCOMPAT_GETPEEREID -DCOMPAT_ISSETUGID \\\
|
||||||
|
-DCOMPAT_STRLCPY -DCOMPAT_STRTONUM \\\
|
||||||
|
-DCOMPAT_LETOH -DCOMPAT_PACKED'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ `uname` = OpenBSD ]; then
|
||||||
|
sun=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
# shell word separator (none)
|
||||||
|
IFS=''
|
||||||
|
|
||||||
|
# sed-quoted new-line
|
||||||
|
nl='\
|
||||||
|
'
|
||||||
|
|
||||||
|
for i; do
|
||||||
|
case "$i" in
|
||||||
|
--prefix=*)
|
||||||
|
prefix="${i#--prefix=}"
|
||||||
|
shift;;
|
||||||
|
--bindir=*)
|
||||||
|
bindir="${i#--bindir=}"
|
||||||
|
shift;;
|
||||||
|
--datadir=*)
|
||||||
|
datadir="${i#--datadir=}"
|
||||||
|
shift;;
|
||||||
|
--includedir=*)
|
||||||
|
includedir="${i#--includedir=}"
|
||||||
|
shift;;
|
||||||
|
--libdir=*)
|
||||||
|
libdir="${i#--libdir=}"
|
||||||
|
shift;;
|
||||||
|
--mandir=*)
|
||||||
|
mandir="${i#--mandir=}"
|
||||||
|
shift;;
|
||||||
|
--enable-alsa)
|
||||||
|
alsa=yes
|
||||||
|
shift;;
|
||||||
|
--disable-alsa)
|
||||||
|
alsa=no
|
||||||
|
shift;;
|
||||||
|
--enable-sun)
|
||||||
|
sun=yes
|
||||||
|
shift;;
|
||||||
|
--disable-sun)
|
||||||
|
sun=no
|
||||||
|
shift;;
|
||||||
|
CC=*|CFLAGS=*|LDFLAGS=*)
|
||||||
|
vars="$vars$i$nl"
|
||||||
|
shift;;
|
||||||
|
*)
|
||||||
|
help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
#
|
||||||
|
# if $xxxdir is not specified, define it to $prefix/xxx
|
||||||
|
#
|
||||||
|
bindir="${bindir:-$prefix/bin}"
|
||||||
|
datadir="${datadir:-$prefix/share}"
|
||||||
|
includedir="${includedir:-$prefix/include}"
|
||||||
|
libdir="${libdir:-$prefix/lib}"
|
||||||
|
mandir="${mandir:-$prefix/man}"
|
||||||
|
|
||||||
|
#
|
||||||
|
# if using ALSA, add corresponding parameters
|
||||||
|
#
|
||||||
|
if [ $alsa = yes ]; then
|
||||||
|
defs="$defs -DUSE_ALSA"
|
||||||
|
ldadd="$ldadd -lasound"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# if using Sun API, add corresponding parameters
|
||||||
|
#
|
||||||
|
if [ $sun = yes ]; then
|
||||||
|
defs="$defs -DUSE_SUN"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for makefile in Makefile aucat/Makefile libsndio/Makefile
|
||||||
|
do
|
||||||
|
sed \
|
||||||
|
-e "s:@bindir@:$bindir:" \
|
||||||
|
-e "s:@datadir@:$datadir:" \
|
||||||
|
-e "s:@includedir@:$includedir:" \
|
||||||
|
-e "s:@libdir@:$libdir:" \
|
||||||
|
-e "s:@mandir@:$mandir:" \
|
||||||
|
-e "s:@defs@:$defs:" \
|
||||||
|
-e "s:@ldadd@:$ldadd:" \
|
||||||
|
-e "s:@so@:$so:" \
|
||||||
|
-e "s:@vars@:${vars}:" \
|
||||||
|
< $makefile.in > $makefile
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "bindir................... $bindir"
|
||||||
|
echo "datadir.................. $datadir"
|
||||||
|
echo "includedir............... $includedir"
|
||||||
|
echo "libdir................... $libdir"
|
||||||
|
echo "mandir................... $mandir"
|
||||||
|
echo "alsa..................... $alsa"
|
||||||
|
echo "sun...................... $sun"
|
||||||
|
echo
|
||||||
|
echo "Do \"make && make install\" to compile and install sndio"
|
||||||
|
echo
|
|
@ -0,0 +1,131 @@
|
||||||
|
# extra includes paths (-I options)
|
||||||
|
INCLUDE = -I../aucat -I../bsd-compat
|
||||||
|
|
||||||
|
# extra libraries paths (-L options)
|
||||||
|
LIB =
|
||||||
|
|
||||||
|
# extra defines (-D options)
|
||||||
|
DEFS = -DDEBUG @defs@
|
||||||
|
|
||||||
|
# extra libraries (-l options)
|
||||||
|
LDADD = @ldadd@
|
||||||
|
|
||||||
|
# extra compiler flags to produce objects for shared library
|
||||||
|
SO_CFLAGS = -fPIC
|
||||||
|
|
||||||
|
# extra compiler flags to produce a shared library with the given name
|
||||||
|
SO_LDFLAGS = -shared -Wl,-soname=libsndio.so.${MAJ}.${MIN}
|
||||||
|
|
||||||
|
# variables defined on configure script command line (if any)
|
||||||
|
@vars@
|
||||||
|
|
||||||
|
#
|
||||||
|
# headers, libraries and man pages installation paths
|
||||||
|
#
|
||||||
|
INCLUDE_DIR = @includedir@
|
||||||
|
LIB_DIR = @libdir@
|
||||||
|
MAN3_DIR = @mandir@/man3
|
||||||
|
MAN7_DIR = @mandir@/man7
|
||||||
|
|
||||||
|
# man3 and man7 pages
|
||||||
|
MAN3 = \
|
||||||
|
sio_open.3 \
|
||||||
|
sio_close.3 sio_setpar.3 sio_getpar.3 sio_getcap.3 \
|
||||||
|
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 \
|
||||||
|
mio_open.3 \
|
||||||
|
mio_close.3 mio_read.3 mio_write.3 mio_nfds.3 mio_pollfd.3 \
|
||||||
|
mio_revents.3 mio_eof.3
|
||||||
|
MAN7 = sndio.7
|
||||||
|
|
||||||
|
#
|
||||||
|
# libraries to build and install
|
||||||
|
#
|
||||||
|
MAJ = 3
|
||||||
|
MIN = 3
|
||||||
|
SO = @so@
|
||||||
|
|
||||||
|
all: ${SO}
|
||||||
|
|
||||||
|
install:
|
||||||
|
mkdir -p ${DESTDIR}${INCLUDE_DIR}
|
||||||
|
mkdir -p ${DESTDIR}${LIB_DIR}
|
||||||
|
mkdir -p ${DESTDIR}${MAN3_DIR}
|
||||||
|
mkdir -p ${DESTDIR}${MAN7_DIR}
|
||||||
|
cp sndio.h ${DESTDIR}${INCLUDE_DIR}
|
||||||
|
cp -R ${SO} ${DESTDIR}${LIB_DIR}
|
||||||
|
cp sio_open.3 ${DESTDIR}${MAN3_DIR}
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_close.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_setpar.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_getpar.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_getcap.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_start.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_stop.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_read.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_write.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_onmove.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_nfds.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_pollfd.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_revents.3
|
||||||
|
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_eof.3
|
||||||
|
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 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
|
||||||
|
ln -sf mio_open.3 ${DESTDIR}${MAN3_DIR}/mio_write.3
|
||||||
|
ln -sf mio_open.3 ${DESTDIR}${MAN3_DIR}/mio_nfds.3
|
||||||
|
ln -sf mio_open.3 ${DESTDIR}${MAN3_DIR}/mio_pollfd.3
|
||||||
|
ln -sf mio_open.3 ${DESTDIR}${MAN3_DIR}/mio_revents.3
|
||||||
|
ln -sf mio_open.3 ${DESTDIR}${MAN3_DIR}/mio_eof.3
|
||||||
|
cp sndio.7 ${DESTDIR}${MAN7_DIR}
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f ${DESTDIR}${INCLUDE_DIR}/sndio.h
|
||||||
|
cd ${DESTDIR}${LIB_DIR} && rm -f ${SO}
|
||||||
|
cd ${DESTDIR}${MAN3_DIR} && rm -f ${MAN3}
|
||||||
|
cd ${DESTDIR}${MAN7_DIR} && rm -f ${MAN7}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f -- ${SO} *.o *~ *.bak *.core core
|
||||||
|
|
||||||
|
# ---------------------------------------------------------- dependencies ---
|
||||||
|
|
||||||
|
OBJS = alsa.o aucat.o sndio.o mio_rmidi.o mio_thru.o mio.o sun.o \
|
||||||
|
getpeereid.o issetugid.o strlcpy.o strtonum.o
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
${CC} ${CFLAGS} ${SO_CFLAGS} ${INCLUDE} ${DEFS} -o $@ -c $<
|
||||||
|
|
||||||
|
libsndio.so.${MAJ}.${MIN}: ${OBJS}
|
||||||
|
${CC} ${LDFLAGS} ${SO_CFLAGS} ${SO_LDFLAGS} -o libsndio.so.${MAJ}.${MIN} ${OBJS}
|
||||||
|
|
||||||
|
libsndio.so.${MAJ}:
|
||||||
|
ln -sf libsndio.so.${MAJ}.${MIN} libsndio.so.${MAJ}
|
||||||
|
|
||||||
|
libsndio.so:
|
||||||
|
ln -sf libsndio.so.${MAJ} libsndio.so
|
||||||
|
|
||||||
|
getpeereid.o: ../bsd-compat/getpeereid.c
|
||||||
|
${CC} ${CFLAGS} ${SO_CFLAGS} ${INCLUDE} ${DEFS} -c -o getpeereid.o ../bsd-compat/getpeereid.c
|
||||||
|
|
||||||
|
issetugid.o: ../bsd-compat/issetugid.c
|
||||||
|
${CC} ${CFLAGS} ${SO_CFLAGS} ${INCLUDE} ${DEFS} -c -o issetugid.o ../bsd-compat/issetugid.c
|
||||||
|
|
||||||
|
strlcpy.o: ../bsd-compat/strlcpy.c
|
||||||
|
${CC} ${CFLAGS} ${SO_CFLAGS} ${INCLUDE} ${DEFS} -c -o 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 sndio_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 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
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: aucat.c,v 1.41 2010/06/05 16:00:52 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -29,6 +29,9 @@
|
||||||
|
|
||||||
#include "amsg.h"
|
#include "amsg.h"
|
||||||
#include "sndio_priv.h"
|
#include "sndio_priv.h"
|
||||||
|
#ifdef COMPAT_STRLCPY
|
||||||
|
#include "bsd-compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
struct aucat_hdl {
|
struct aucat_hdl {
|
||||||
struct sio_hdl sio;
|
struct sio_hdl sio;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: mio.c,v 1.8 2010/04/24 06:15:54 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -29,6 +29,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "mio_priv.h"
|
#include "mio_priv.h"
|
||||||
|
#ifdef COMPAT_ISSETUGID
|
||||||
|
#include "bsd-compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: mio_thru.c,v 1.10 2010/07/21 23:00:16 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -29,6 +29,9 @@
|
||||||
|
|
||||||
#include "amsg.h"
|
#include "amsg.h"
|
||||||
#include "mio_priv.h"
|
#include "mio_priv.h"
|
||||||
|
#ifdef COMPAT_STRLCPY
|
||||||
|
#include "bsd-compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define THRU_SOCKET "midithru"
|
#define THRU_SOCKET "midithru"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: sndio.c,v 1.25 2010/04/24 06:15:54 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -29,6 +29,9 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "sndio_priv.h"
|
#include "sndio_priv.h"
|
||||||
|
#ifdef COMPAT_ISSETUGID
|
||||||
|
#include "bsd-compat.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SIO_PAR_MAGIC 0x83b905a4
|
#define SIO_PAR_MAGIC 0x83b905a4
|
||||||
|
|
||||||
|
@ -171,6 +174,9 @@ sio_open(const char *str, unsigned mode, int nbio)
|
||||||
{
|
{
|
||||||
static char prefix_aucat[] = "aucat";
|
static char prefix_aucat[] = "aucat";
|
||||||
static char prefix_sun[] = "sun";
|
static char prefix_sun[] = "sun";
|
||||||
|
#ifdef USE_ALSA
|
||||||
|
static char prefix_alsa[] = "hw";
|
||||||
|
#endif
|
||||||
struct sio_hdl *hdl;
|
struct sio_hdl *hdl;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
char *sep, buf[NAME_MAX];
|
char *sep, buf[NAME_MAX];
|
||||||
|
@ -192,15 +198,26 @@ sio_open(const char *str, unsigned mode, int nbio)
|
||||||
hdl = sio_open_aucat("0", mode, nbio);
|
hdl = sio_open_aucat("0", mode, nbio);
|
||||||
if (hdl != NULL)
|
if (hdl != NULL)
|
||||||
return hdl;
|
return hdl;
|
||||||
|
#ifdef USE_SUN
|
||||||
if (stat("/dev/audio", &sb) == 0 && S_ISCHR(sb.st_mode)) {
|
if (stat("/dev/audio", &sb) == 0 && S_ISCHR(sb.st_mode)) {
|
||||||
snprintf(buf, sizeof(buf), "%u",
|
snprintf(buf, sizeof(buf), "%u",
|
||||||
minor(sb.st_rdev) & 0xf);
|
minor(sb.st_rdev) & 0xf);
|
||||||
} else
|
} else
|
||||||
strlcpy(buf, "0", sizeof(buf));
|
strlcpy(buf, "0", sizeof(buf));
|
||||||
return sio_open_sun(buf, mode, nbio);
|
hdl = sio_open_sun(buf, mode, nbio);
|
||||||
|
if (hdl != NULL)
|
||||||
|
return hdl;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_ALSA
|
||||||
|
hdl = sio_open_alsa("default", mode, nbio);
|
||||||
|
if (hdl != NULL)
|
||||||
|
return hdl;
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
sep = strchr(str, ':');
|
sep = strchr(str, ':');
|
||||||
if (sep == NULL) {
|
if (sep == NULL) {
|
||||||
|
#ifdef USE_SUN
|
||||||
/*
|
/*
|
||||||
* try legacy "/dev/audioxxx" or ``socket'' device name
|
* try legacy "/dev/audioxxx" or ``socket'' device name
|
||||||
*/
|
*/
|
||||||
|
@ -210,14 +227,24 @@ sio_open(const char *str, unsigned mode, int nbio)
|
||||||
}
|
}
|
||||||
snprintf(buf, sizeof(buf), "%u", minor(sb.st_rdev) & 0xf);
|
snprintf(buf, sizeof(buf), "%u", minor(sb.st_rdev) & 0xf);
|
||||||
return sio_open_sun(buf, mode, nbio);
|
return sio_open_sun(buf, mode, nbio);
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
len = sep - str;
|
len = sep - str;
|
||||||
if (len == (sizeof(prefix_aucat) - 1) &&
|
if (len == (sizeof(prefix_aucat) - 1) &&
|
||||||
memcmp(str, prefix_aucat, len) == 0)
|
memcmp(str, prefix_aucat, len) == 0)
|
||||||
return sio_open_aucat(sep + 1, mode, nbio);
|
return sio_open_aucat(sep + 1, mode, nbio);
|
||||||
|
#ifdef USE_SUN
|
||||||
if (len == (sizeof(prefix_sun) - 1) &&
|
if (len == (sizeof(prefix_sun) - 1) &&
|
||||||
memcmp(str, prefix_sun, len) == 0)
|
memcmp(str, prefix_sun, len) == 0)
|
||||||
return sio_open_sun(sep + 1, mode, nbio);
|
return sio_open_sun(sep + 1, mode, nbio);
|
||||||
|
#endif
|
||||||
|
#ifdef USE_ALSA
|
||||||
|
if (len == (sizeof(prefix_alsa) - 1) &&
|
||||||
|
memcmp(str, prefix_alsa, len) == 0)
|
||||||
|
return sio_open_alsa(sep + 1, mode, nbio);
|
||||||
|
#endif
|
||||||
DPRINTF("sio_open: %s: unknown device type\n", str);
|
DPRINTF("sio_open: %s: unknown device type\n", str);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: sndio_priv.h,v 1.8 2009/07/25 11:15:56 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -78,7 +78,12 @@ struct sio_ops {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sio_hdl *sio_open_aucat(const char *, unsigned, int);
|
struct sio_hdl *sio_open_aucat(const char *, unsigned, int);
|
||||||
|
#ifdef USE_SUN
|
||||||
struct sio_hdl *sio_open_sun(const char *, unsigned, int);
|
struct sio_hdl *sio_open_sun(const char *, unsigned, int);
|
||||||
|
#endif
|
||||||
|
#ifdef USE_ALSA
|
||||||
|
struct sio_hdl *sio_open_alsa(const char *, unsigned, int);
|
||||||
|
#endif
|
||||||
void sio_create(struct sio_hdl *, struct sio_ops *, unsigned, int);
|
void sio_create(struct sio_hdl *, struct sio_ops *, unsigned, int);
|
||||||
void sio_destroy(struct sio_hdl *);
|
void sio_destroy(struct sio_hdl *);
|
||||||
void sio_onmove_cb(struct sio_hdl *, int);
|
void sio_onmove_cb(struct sio_hdl *, int);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: sun.c,v 1.40 2010/08/06 06:52:17 ratchov Exp $ */
|
/* $OpenBSD$ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||||
*
|
*
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
* implement generic blocking sio_read() and sio_write() with poll(2)
|
* implement generic blocking sio_read() and sio_write() with poll(2)
|
||||||
* and use non-blocking sio_ops only
|
* and use non-blocking sio_ops only
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_SUN
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/audioio.h>
|
#include <sys/audioio.h>
|
||||||
|
@ -891,7 +891,7 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
||||||
{
|
{
|
||||||
struct sun_hdl *hdl = (struct sun_hdl *)sh;
|
struct sun_hdl *hdl = (struct sun_hdl *)sh;
|
||||||
struct audio_offset ao;
|
struct audio_offset ao;
|
||||||
int xrun, dmove, dierr = 0, doerr = 0, delta;
|
int xrun, dmove, dierr = 0, doerr = 0, doffset = 0;
|
||||||
int revents = pfd->revents;
|
int revents = pfd->revents;
|
||||||
|
|
||||||
if (hdl->sio.mode & SIO_PLAY) {
|
if (hdl->sio.mode & SIO_PLAY) {
|
||||||
|
@ -902,8 +902,8 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
||||||
}
|
}
|
||||||
doerr = xrun - hdl->oerr;
|
doerr = xrun - hdl->oerr;
|
||||||
hdl->oerr = xrun;
|
hdl->oerr = xrun;
|
||||||
if (!(hdl->sio.mode & SIO_REC))
|
if (hdl->sio.mode & SIO_REC)
|
||||||
dierr = doerr;
|
doffset += doerr;
|
||||||
}
|
}
|
||||||
if (hdl->sio.mode & SIO_REC) {
|
if (hdl->sio.mode & SIO_REC) {
|
||||||
if (ioctl(hdl->fd, AUDIO_RERROR, &xrun) < 0) {
|
if (ioctl(hdl->fd, AUDIO_RERROR, &xrun) < 0) {
|
||||||
|
@ -913,10 +913,10 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
||||||
}
|
}
|
||||||
dierr = xrun - hdl->ierr;
|
dierr = xrun - hdl->ierr;
|
||||||
hdl->ierr = xrun;
|
hdl->ierr = xrun;
|
||||||
if (!(hdl->sio.mode & SIO_PLAY))
|
if (hdl->sio.mode & SIO_PLAY)
|
||||||
doerr = dierr;
|
doffset -= dierr;
|
||||||
}
|
}
|
||||||
hdl->offset += doerr - dierr;
|
hdl->offset += doffset;
|
||||||
dmove = dierr > doerr ? dierr : doerr;
|
dmove = dierr > doerr ? dierr : doerr;
|
||||||
hdl->idelta -= dmove;
|
hdl->idelta -= dmove;
|
||||||
hdl->odelta -= dmove;
|
hdl->odelta -= dmove;
|
||||||
|
@ -927,29 +927,25 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
||||||
hdl->sio.eof = 1;
|
hdl->sio.eof = 1;
|
||||||
return POLLHUP;
|
return POLLHUP;
|
||||||
}
|
}
|
||||||
delta = (ao.samples - hdl->obytes) / hdl->obpf;
|
hdl->odelta += (ao.samples - hdl->obytes) / hdl->obpf;
|
||||||
hdl->obytes = ao.samples;
|
hdl->obytes = ao.samples;
|
||||||
hdl->odelta += delta;
|
if (hdl->odelta > 0) {
|
||||||
if (!(hdl->sio.mode & SIO_REC))
|
sio_onmove_cb(&hdl->sio, hdl->odelta);
|
||||||
hdl->idelta += delta;
|
hdl->odelta = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((revents & POLLIN) && (hdl->sio.mode & SIO_REC)) {
|
if ((revents & POLLIN) && !(hdl->sio.mode & SIO_PLAY)) {
|
||||||
if (ioctl(hdl->fd, AUDIO_GETIOFFS, &ao) < 0) {
|
if (ioctl(hdl->fd, AUDIO_GETIOFFS, &ao) < 0) {
|
||||||
DPERROR("sun_revents: GETIOFFS");
|
DPERROR("sun_revents: GETIOFFS");
|
||||||
hdl->sio.eof = 1;
|
hdl->sio.eof = 1;
|
||||||
return POLLHUP;
|
return POLLHUP;
|
||||||
}
|
}
|
||||||
delta = (ao.samples - hdl->ibytes) / hdl->ibpf;
|
hdl->idelta += (ao.samples - hdl->ibytes) / hdl->ibpf;
|
||||||
hdl->ibytes = ao.samples;
|
hdl->ibytes = ao.samples;
|
||||||
hdl->idelta += delta;
|
if (hdl->idelta > 0) {
|
||||||
if (!(hdl->sio.mode & SIO_PLAY))
|
sio_onmove_cb(&hdl->sio, hdl->idelta);
|
||||||
hdl->odelta += delta;
|
hdl->idelta = 0;
|
||||||
}
|
}
|
||||||
delta = (hdl->idelta > hdl->odelta) ? hdl->idelta : hdl->odelta;
|
|
||||||
if (delta > 0) {
|
|
||||||
sio_onmove_cb(&hdl->sio, delta);
|
|
||||||
hdl->idelta -= delta;
|
|
||||||
hdl->odelta -= delta;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -967,3 +963,4 @@ sun_revents(struct sio_hdl *sh, struct pollfd *pfd)
|
||||||
}
|
}
|
||||||
return revents;
|
return revents;
|
||||||
}
|
}
|
||||||
|
#endif /* defined USE_SUN */
|
||||||
|
|
Loading…
Reference in New Issue