mirror of https://github.com/ericonr/sndio.git
Merge branch 'master' into mixer
This commit is contained in:
commit
0445c6a464
|
@ -534,7 +534,7 @@ afile_aiff_readhdr(struct afile *f)
|
|||
unsigned int csize, rsize, nfr = 0, pos = 0, offs;
|
||||
int comm_done = 0, comp;
|
||||
|
||||
if (!afile_readhdr(f, &form, sizeof(struct wav_riff)))
|
||||
if (!afile_readhdr(f, &form, sizeof(struct aiff_form)))
|
||||
return 0;
|
||||
if (memcmp(&form.id, &aiff_id_form, 4) != 0) {
|
||||
log_puts(f->path);
|
||||
|
@ -656,7 +656,7 @@ afile_au_readhdr(struct afile *f)
|
|||
struct au_hdr hdr;
|
||||
unsigned int fmt;
|
||||
|
||||
if (!afile_readhdr(f, &hdr, sizeof(struct wav_riff)))
|
||||
if (!afile_readhdr(f, &hdr, sizeof(struct au_hdr)))
|
||||
return 0;
|
||||
if (memcmp(&hdr.id, &au_id, 4) != 0) {
|
||||
log_puts(f->path);
|
||||
|
|
|
@ -21,4 +21,20 @@ size_t strlcpy(char *, const char *, size_t);
|
|||
long long strtonum(const char *, long long, long long, const char **);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SOCK_CLOEXEC
|
||||
#define strtonum _sndio_strtonum
|
||||
long long strtonum(const char *, long long, long long, const char **);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CLOCK_GETTIME
|
||||
#define CLOCK_MONOTONIC 0
|
||||
#define clock_gettime _sndio_clock_gettime
|
||||
struct timespec;
|
||||
int clock_gettime(int, struct timespec *);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SOCK_CLOEXEC
|
||||
#define SOCK_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
#endif /* !defined(BSD_COMPAT_H) */
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Alexandre Ratchov <alex@coua.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.
|
||||
*/
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include "bsd-compat.h"
|
||||
|
||||
#ifndef HAVE_CLOCK_GETTIME
|
||||
|
||||
int
|
||||
_sndio_clock_gettime(int timer, struct timespec *ts)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (timer != CLOCK_MONOTONIC) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (gettimeofday(&tv, NULL) < 0)
|
||||
return -1;
|
||||
|
||||
ts->tv_sec = tv.tv_sec;
|
||||
ts->tv_nsec = tv.tv_usec * 1000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -60,33 +60,40 @@ case `uname` in
|
|||
alsa=yes
|
||||
ldadd="-lrt"
|
||||
user=sndiod
|
||||
so="$so libsndio.so"
|
||||
defs='-D_GNU_SOURCE -DDEV_RANDOM=\\"/dev/urandom\\"'
|
||||
so_link="libsndio.so"
|
||||
defs='-D_GNU_SOURCE -DDEV_RANDOM=\\"/dev/urandom\\" \\\
|
||||
-DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME'
|
||||
;;
|
||||
NetBSD)
|
||||
sun=no
|
||||
rmidi=yes
|
||||
user=_sndio
|
||||
so="$so libsndio.so"
|
||||
so_link="libsndio.so"
|
||||
defs='-DHAVE_ARC4RANDOM -DHAVE_ISSETUGID \\\
|
||||
-DHAVE_STRLCAT -DHAVE_STRLCPY'
|
||||
-DHAVE_STRLCAT -DHAVE_STRLCPY \\\
|
||||
-DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME'
|
||||
;;
|
||||
OpenBSD)
|
||||
sun=yes
|
||||
rmidi=yes
|
||||
user=_sndio
|
||||
defs='-DHAVE_ARC4RANDOM -DHAVE_ISSETUGID \\\
|
||||
-DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRTONUM'
|
||||
-DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRTONUM \\\
|
||||
-DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME'
|
||||
;;
|
||||
DragonFly|FreeBSD)
|
||||
umidi=yes
|
||||
user=_sndio
|
||||
so="$so libsndio.so"
|
||||
so_link="libsndio.so"
|
||||
defs='-DHAVE_ARC4RANDOM -DHAVE_ISSETUGID \\\
|
||||
-DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRTONUM'
|
||||
oss=yes
|
||||
mandir=${prefix}/man
|
||||
-DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRTONUM \\\
|
||||
-DHAVE_SOCK_CLOEXEC -DHAVE_CLOCK_GETTIME'
|
||||
;;
|
||||
Darwin)
|
||||
rmidi=no
|
||||
so="libsndio.\${MAJ}.\${MIN}.dylib"
|
||||
defs='-DHAVE_ARC4RANDOM -DHAVE_ISSETUGID \\\
|
||||
-DHAVE_STRLCAT -DHAVE_STRLCPY'
|
||||
esac
|
||||
|
||||
# shell word separator (none)
|
||||
|
@ -255,6 +262,7 @@ do
|
|||
-e "s:@defs@:$defs:" \
|
||||
-e "s:@ldadd@:$ldadd:" \
|
||||
-e "s:@so@:$so:" \
|
||||
-e "s:@so_link@:$so_link:" \
|
||||
-e "s:@vars@:${vars}:" \
|
||||
-e "s:@precision@:$precision:" \
|
||||
-e "s:@user@:$user:" \
|
||||
|
|
|
@ -14,7 +14,7 @@ LDADD = @ldadd@
|
|||
SO_CFLAGS = -fPIC
|
||||
|
||||
# extra compiler flags to produce a shared library with the given name
|
||||
SO_LDFLAGS = -shared -Wl,-soname=libsndio.so.${MAJ}.${MIN}
|
||||
SO_LDFLAGS = -shared #-Wl,-soname=libsndio.so.${MAJ}.${MIN}
|
||||
|
||||
# variables defined on configure script command line (if any)
|
||||
@vars@
|
||||
|
@ -48,6 +48,7 @@ MAN7 = sndio.7
|
|||
MAJ = 6
|
||||
MIN = 1
|
||||
SO = @so@
|
||||
SO_LINK = @so_link@
|
||||
|
||||
all: ${SO}
|
||||
|
||||
|
@ -57,7 +58,7 @@ install:
|
|||
mkdir -p ${DESTDIR}${MAN3_DIR}
|
||||
mkdir -p ${DESTDIR}${MAN7_DIR}
|
||||
cp sndio.h ${DESTDIR}${INCLUDE_DIR}
|
||||
cp -R ${SO} ${DESTDIR}${LIB_DIR}
|
||||
cp -R ${SO} ${SO_LINK} ${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
|
||||
|
@ -96,7 +97,7 @@ install:
|
|||
|
||||
uninstall:
|
||||
rm -f ${DESTDIR}${INCLUDE_DIR}/sndio.h
|
||||
cd ${DESTDIR}${LIB_DIR} && rm -f ${SO}
|
||||
cd ${DESTDIR}${LIB_DIR} && rm -f ${SO} ${SO_LINK}
|
||||
cd ${DESTDIR}${MAN3_DIR} && rm -f ${MAN3}
|
||||
cd ${DESTDIR}${MAN7_DIR} && rm -f ${MAN7}
|
||||
|
||||
|
@ -113,16 +114,16 @@ OBJS = debug.o aucat.o \
|
|||
mio.o mio_rmidi.o mio_alsa.o mio_aucat.o \
|
||||
sio.o sio_alsa.o sio_aucat.o sio_oss.o sio_sun.o \
|
||||
siomix.o siomix_aucat.o siomix_sun.o \
|
||||
issetugid.o strlcat.o strlcpy.o strtonum.o
|
||||
issetugid.o strlcat.o strlcpy.o strtonum.o clock_gettime.o
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} ${SO_CFLAGS} -I. ${INCLUDE} ${DEFS} -o $@ -c $<
|
||||
|
||||
libsndio.so.${MAJ}.${MIN}: ${OBJS}
|
||||
${CC} ${LDFLAGS} ${SO_CFLAGS} ${SO_LDFLAGS} -o libsndio.so.${MAJ}.${MIN} ${OBJS} ${LDADD}
|
||||
${SO}: ${OBJS}
|
||||
${CC} ${LDFLAGS} ${SO_CFLAGS} ${SO_LDFLAGS} -o ${SO} ${OBJS} ${LDADD}
|
||||
|
||||
libsndio.so:
|
||||
ln -sf libsndio.so.${MAJ}.${MIN} libsndio.so
|
||||
${SO_LINK}:
|
||||
ln -sf ${SO} ${SO_LINK}
|
||||
|
||||
issetugid.o: ../bsd-compat/issetugid.c
|
||||
${CC} ${CFLAGS} ${SO_CFLAGS} ${INCLUDE} ${DEFS} -c -o issetugid.o ../bsd-compat/issetugid.c
|
||||
|
@ -136,6 +137,9 @@ 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
|
||||
|
||||
clock_gettime.o: ../bsd-compat/clock_gettime.c
|
||||
${CC} ${CFLAGS} ${SO_CFLAGS} ${INCLUDE} ${DEFS} -c -o clock_gettime.o ../bsd-compat/clock_gettime.c
|
||||
|
||||
aucat.o: aucat.c aucat.h amsg.h debug.h \
|
||||
../bsd-compat/bsd-compat.h
|
||||
debug.o: debug.c debug.h ../bsd-compat/bsd-compat.h
|
||||
|
|
|
@ -366,6 +366,14 @@ aucat_connect_tcp(struct aucat *hdl, char *host, unsigned int unit)
|
|||
DPERROR("socket");
|
||||
continue;
|
||||
}
|
||||
#ifndef HAVE_SOCK_CLOEXEC
|
||||
if (fcntl(s, F_SETFL, FD_CLOEXEC) < 0) {
|
||||
DPERROR("FD_CLOEXEC");
|
||||
close(s);
|
||||
s = - 1;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
restart:
|
||||
if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0) {
|
||||
if (errno == EINTR)
|
||||
|
@ -405,6 +413,13 @@ aucat_connect_un(struct aucat *hdl, unsigned int unit)
|
|||
s = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||
if (s < 0)
|
||||
return 0;
|
||||
#ifndef HAVE_SOCK_CLOEXEC
|
||||
if (fcntl(s, F_SETFL, FD_CLOEXEC) < 0) {
|
||||
DPERROR("FD_CLOEXEC");
|
||||
close(s);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
while (connect(s, (struct sockaddr *)&ca, len) < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
|
|
@ -478,14 +478,11 @@ may be set if an error occurs, even if
|
|||
it is not selected with
|
||||
.Fn sio_pollfd .
|
||||
.Pp
|
||||
The
|
||||
The size of the
|
||||
.Ar pfd
|
||||
array, which the caller must pre-allocate, is provided by the
|
||||
.Fn sio_nfds
|
||||
function returns the number of
|
||||
.Vt pollfd
|
||||
structures the caller must preallocate in order to be sure
|
||||
that
|
||||
.Fn sio_pollfd
|
||||
will never overrun.
|
||||
function.
|
||||
.Ss Synchronizing non-audio events to the audio stream in real-time
|
||||
In order to perform actions at precise positions of the audio stream,
|
||||
such as displaying video in sync with the audio stream,
|
||||
|
@ -668,32 +665,49 @@ argument, except
|
|||
and
|
||||
.Fn sio_eof ,
|
||||
stop working (i.e. always return 0).
|
||||
.Pp
|
||||
The
|
||||
.Fn sio_eof
|
||||
function can be used at any stage;
|
||||
it returns 0 if there's no pending error, and a non-zero
|
||||
value if there's an error.
|
||||
function can be used at any stage.
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn sio_open
|
||||
function returns the newly created handle on success or NULL
|
||||
on failure.
|
||||
.Pp
|
||||
The
|
||||
.Fn sio_setpar ,
|
||||
.Fn sio_getpar ,
|
||||
.Fn sio_getcap ,
|
||||
.Fn sio_start ,
|
||||
.Fn sio_stop ,
|
||||
.Fn sio_pollfd ,
|
||||
and
|
||||
.Fn sio_setvol
|
||||
functions return 1 on success and 0 on failure.
|
||||
.Pp
|
||||
The
|
||||
.Fn sio_pollfd
|
||||
function returns the number of
|
||||
.Va pollfd
|
||||
structures filled.
|
||||
The
|
||||
.Fn sio_nfds
|
||||
function returns the number of
|
||||
.Va pollfd
|
||||
structures the caller must preallocate in order to be sure
|
||||
that
|
||||
.Fn sio_pollfd
|
||||
will never overrun.
|
||||
.Pp
|
||||
The
|
||||
.Fn sio_read
|
||||
and
|
||||
.Fn sio_write
|
||||
functions return the number of bytes transferred.
|
||||
.Pp
|
||||
The
|
||||
.Fn sio_eof
|
||||
function returns 0 if there's no pending error, and a non-zero
|
||||
value if there's an error.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width "SNDIO_DEBUGXXX" -compact
|
||||
.It Ev AUDIODEVICE
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "bsd-compat.h"
|
||||
|
||||
#include "file.h"
|
||||
#include "utils.h"
|
||||
|
|
Loading…
Reference in New Issue