mirror of https://github.com/ericonr/sndio.git
use common DPRINTF's for audio and midi code
This commit is contained in:
parent
77a2cf5acb
commit
313ba302a8
|
@ -97,8 +97,9 @@ clean:
|
|||
# object files, sorted following dependencies to allow the
|
||||
# loader to determine dependencies in a single pass
|
||||
#
|
||||
OBJS = mio.o mio_rmidi.o mio_aucat.o sio.o sio_alsa.o sio_aucat.o sio_sun.o \
|
||||
aucat.o getpeereid.o issetugid.o strlcpy.o strtonum.o
|
||||
OBJS = debug.o aucat.o \
|
||||
mio.o mio_rmidi.o mio_aucat.o sio.o sio_alsa.o sio_aucat.o sio_sun.o \
|
||||
getpeereid.o issetugid.o strlcpy.o strtonum.o
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} ${SO_CFLAGS} ${INCLUDE} ${DEFS} -o $@ -c $<
|
||||
|
@ -124,14 +125,17 @@ 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
|
||||
|
||||
aucat.o: aucat.c aucat.h ../aucat/amsg.h ../aucat/conf.h \
|
||||
aucat.o: aucat.c aucat.h ../aucat/amsg.h ../aucat/conf.h debug.h \
|
||||
../bsd-compat/bsd-compat.h
|
||||
debug.o: debug.c debug.h ../bsd-compat/bsd-compat.h
|
||||
mio.o: mio.c debug.h mio_priv.h sndio.h \
|
||||
../bsd-compat/bsd-compat.h
|
||||
mio.o: mio.c mio_priv.h sndio.h ../bsd-compat/bsd-compat.h
|
||||
mio_aucat.o: mio_aucat.c aucat.h ../aucat/amsg.h ../aucat/conf.h \
|
||||
mio_priv.h sndio.h ../bsd-compat/bsd-compat.h
|
||||
mio_rmidi.o: mio_rmidi.c mio_priv.h sndio.h
|
||||
sio.o: sio.c sio_priv.h sndio.h ../bsd-compat/bsd-compat.h
|
||||
sio_alsa.o: sio_alsa.c sio_priv.h sndio.h
|
||||
debug.h mio_priv.h sndio.h ../bsd-compat/bsd-compat.h
|
||||
mio_rmidi.o: mio_rmidi.c debug.h mio_priv.h sndio.h
|
||||
sio.o: sio.c debug.h sio_priv.h sndio.h \
|
||||
../bsd-compat/bsd-compat.h
|
||||
sio_alsa.o: sio_alsa.c debug.h sio_priv.h sndio.h
|
||||
sio_aucat.o: sio_aucat.c aucat.h ../aucat/amsg.h ../aucat/conf.h \
|
||||
sio_priv.h sndio.h ../bsd-compat/bsd-compat.h
|
||||
sio_sun.o: sio_sun.c sio_priv.h sndio.h
|
||||
debug.h sio_priv.h sndio.h ../bsd-compat/bsd-compat.h
|
||||
sio_sun.o: sio_sun.c debug.h sio_priv.h sndio.h
|
||||
|
|
|
@ -28,28 +28,11 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "aucat.h"
|
||||
#include "debug.h"
|
||||
#ifdef COMPAT_STRLCPY
|
||||
#include "bsd-compat.h"
|
||||
#endif
|
||||
|
||||
int aucat_debug = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DPRINTF(...) \
|
||||
do { \
|
||||
if (aucat_debug > 0) \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
} while(0)
|
||||
#define DPERROR(s) \
|
||||
do { \
|
||||
if (aucat_debug > 0) \
|
||||
perror(s); \
|
||||
} while(0)
|
||||
#else
|
||||
#define DPRINTF(...) do {} while(0)
|
||||
#define DPERROR(s) do {} while(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* read a message, return 0 if not completed
|
||||
*/
|
||||
|
@ -216,15 +199,11 @@ aucat_open(struct aucat *hdl, const char *str, char *sock, unsigned mode, int nb
|
|||
{
|
||||
extern char *__progname;
|
||||
int s, eof;
|
||||
char unit[4], *sep, *opt, *debug;
|
||||
char unit[4], *sep, *opt;
|
||||
struct sockaddr_un ca;
|
||||
socklen_t len = sizeof(struct sockaddr_un);
|
||||
uid_t uid;
|
||||
|
||||
debug = getenv("AUCAT_DEBUG");
|
||||
if (debug)
|
||||
sscanf(debug, "%u", &aucat_debug);
|
||||
|
||||
sep = strchr(str, '.');
|
||||
if (sep == NULL) {
|
||||
opt = "default";
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/* $OpenBSD$ */
|
||||
/*
|
||||
* Copyright (c) 2011 Alexandre Ratchov <alex@caoua.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "debug.h"
|
||||
#ifdef COMPAT_ISSETUGID
|
||||
#include "bsd-compat.h"
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* debug level, -1 means uninitialized
|
||||
*/
|
||||
int sndio_debug = -1;
|
||||
|
||||
void
|
||||
sndio_debug_init(void)
|
||||
{
|
||||
char *dbg;
|
||||
|
||||
if (sndio_debug < 0) {
|
||||
dbg = issetugid() ? NULL : getenv("SNDIO_DEBUG");
|
||||
if (!dbg || sscanf(dbg, "%u", &sndio_debug) != 1)
|
||||
sndio_debug = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,42 @@
|
|||
/* $OpenBSD$ */
|
||||
/*
|
||||
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
|
||||
#define DPRINTF(...) \
|
||||
do { \
|
||||
if (sndio_debug > 0) \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
#define DPERROR(s) \
|
||||
do { \
|
||||
if (sndio_debug > 0) \
|
||||
perror(s); \
|
||||
} while(0)
|
||||
|
||||
void sndio_debug_init(void);
|
||||
extern int sndio_debug;
|
||||
#else
|
||||
#define DPRINTF(...) do {} while(0)
|
||||
#define DPERROR(s) do {} while(0)
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -28,18 +28,12 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "mio_priv.h"
|
||||
#ifdef COMPAT_ISSETUGID
|
||||
#include "bsd-compat.h"
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* debug level, -1 means uninitialized
|
||||
*/
|
||||
int mio_debug = -1;
|
||||
#endif
|
||||
|
||||
struct mio_hdl *
|
||||
mio_open(const char *str, unsigned mode, int nbio)
|
||||
{
|
||||
|
@ -50,14 +44,9 @@ mio_open(const char *str, unsigned mode, int nbio)
|
|||
struct stat sb;
|
||||
char *sep, buf[4];
|
||||
int len;
|
||||
#ifdef DEBUG
|
||||
char *dbg;
|
||||
|
||||
if (mio_debug < 0) {
|
||||
dbg = issetugid() ? NULL : getenv("MIO_DEBUG");
|
||||
if (!dbg || sscanf(dbg, "%u", &mio_debug) != 1)
|
||||
mio_debug = 0;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
sndio_debug_init();
|
||||
#endif
|
||||
if ((mode & (MIO_OUT | MIO_IN)) == 0)
|
||||
return NULL;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "aucat.h"
|
||||
#include "debug.h"
|
||||
#include "mio_priv.h"
|
||||
#ifdef COMPAT_STRLCPY
|
||||
#include "bsd-compat.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $OpenBSD: mio_open.3,v 1.3 2009/07/26 12:42:48 ratchov Exp $
|
||||
.\" $OpenBSD$
|
||||
.\"
|
||||
.\" Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
|
||||
.\"
|
||||
|
@ -14,7 +14,7 @@
|
|||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.Dd $Mdocdate: July 26 2009 $
|
||||
.Dd $Mdocdate$
|
||||
.Dt MIO_OPEN 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -233,7 +233,7 @@ and
|
|||
functions return the number of bytes transferred.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width "MIO_DEBUGXXX" -compact
|
||||
.It Ev MIO_DEBUG
|
||||
.It Ev SNDIO_DEBUG
|
||||
The debug level:
|
||||
may be a value between 0 and 2.
|
||||
.El
|
||||
|
|
|
@ -20,22 +20,6 @@
|
|||
#include <sys/param.h>
|
||||
#include "sndio.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DPRINTF(...) \
|
||||
do { \
|
||||
if (mio_debug > 0) \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
} while(0)
|
||||
#define DPERROR(s) \
|
||||
do { \
|
||||
if (mio_debug > 0) \
|
||||
perror(s); \
|
||||
} while(0)
|
||||
#else
|
||||
#define DPRINTF(...) do {} while(0)
|
||||
#define DPERROR(s) do {} while(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* private ``handle'' structure
|
||||
*/
|
||||
|
@ -63,8 +47,4 @@ struct mio_hdl *mio_aucat_open(const char *, unsigned, int);
|
|||
void mio_create(struct mio_hdl *, struct mio_ops *, unsigned, int);
|
||||
void mio_destroy(struct mio_hdl *);
|
||||
|
||||
#ifdef DEBUG
|
||||
extern int mio_debug;
|
||||
#endif
|
||||
|
||||
#endif /* !defined(MIO_PRIV_H) */
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "mio_priv.h"
|
||||
|
||||
struct mio_rmidi_hdl {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "sio_priv.h"
|
||||
#ifdef COMPAT_ISSETUGID
|
||||
#include "bsd-compat.h"
|
||||
|
@ -35,13 +36,6 @@
|
|||
|
||||
#define SIO_PAR_MAGIC 0x83b905a4
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* debug level, -1 means uninitialized
|
||||
*/
|
||||
int sio_debug = -1;
|
||||
#endif
|
||||
|
||||
void
|
||||
sio_initpar(struct sio_par *par)
|
||||
{
|
||||
|
@ -61,14 +55,9 @@ sio_open(const char *str, unsigned mode, int nbio)
|
|||
struct stat sb;
|
||||
char *sep, buf[NAME_MAX];
|
||||
int len;
|
||||
#ifdef DEBUG
|
||||
char *dbg;
|
||||
|
||||
if (sio_debug < 0) {
|
||||
dbg = issetugid() ? NULL : getenv("SIO_DEBUG");
|
||||
if (!dbg || sscanf(dbg, "%u", &sio_debug) != 1)
|
||||
sio_debug = 0;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
sndio_debug_init();
|
||||
#endif
|
||||
if ((mode & (SIO_PLAY | SIO_REC)) == 0)
|
||||
return NULL;
|
||||
|
@ -328,7 +317,7 @@ sio_write(struct sio_hdl *hdl, const void *buf, size_t len)
|
|||
struct timeval tv0, tv1, dtv;
|
||||
unsigned us;
|
||||
|
||||
if (sio_debug >= 2)
|
||||
if (sndio_debug >= 2)
|
||||
gettimeofday(&tv0, NULL);
|
||||
#endif
|
||||
|
||||
|
@ -361,7 +350,7 @@ sio_write(struct sio_hdl *hdl, const void *buf, size_t len)
|
|||
#endif
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (sio_debug >= 2) {
|
||||
if (sndio_debug >= 2) {
|
||||
gettimeofday(&tv1, NULL);
|
||||
timersub(&tv0, &hdl->tv, &dtv);
|
||||
DPRINTF("%ld.%06ld: ", dtv.tv_sec, dtv.tv_usec);
|
||||
|
@ -400,7 +389,7 @@ sio_revents(struct sio_hdl *hdl, struct pollfd *pfd)
|
|||
struct timeval tv0, tv1, dtv;
|
||||
unsigned us;
|
||||
|
||||
if (sio_debug >= 2)
|
||||
if (sndio_debug >= 2)
|
||||
gettimeofday(&tv0, NULL);
|
||||
#endif
|
||||
if (hdl->eof)
|
||||
|
@ -412,7 +401,7 @@ sio_revents(struct sio_hdl *hdl, struct pollfd *pfd)
|
|||
if (!hdl->started)
|
||||
return revents & POLLHUP;
|
||||
#ifdef DEBUG
|
||||
if (sio_debug >= 2) {
|
||||
if (sndio_debug >= 2) {
|
||||
gettimeofday(&tv1, NULL);
|
||||
timersub(&tv0, &hdl->tv, &dtv);
|
||||
DPRINTF("%ld.%06ld: ", dtv.tv_sec, dtv.tv_usec);
|
||||
|
@ -451,7 +440,7 @@ sio_onmove_cb(struct sio_hdl *hdl, int delta)
|
|||
struct timeval tv0, dtv;
|
||||
long long playpos;
|
||||
|
||||
if (sio_debug >= 3 && (hdl->mode & SIO_PLAY)) {
|
||||
if (sndio_debug >= 3 && (hdl->mode & SIO_PLAY)) {
|
||||
gettimeofday(&tv0, NULL);
|
||||
timersub(&tv0, &hdl->tv, &dtv);
|
||||
DPRINTF("%ld.%06ld: ", dtv.tv_sec, dtv.tv_usec);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <unistd.h>
|
||||
#include <values.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "sio_priv.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "aucat.h"
|
||||
#include "debug.h"
|
||||
#include "sio_priv.h"
|
||||
#ifdef COMPAT_STRLCPY
|
||||
#include "bsd-compat.h"
|
||||
|
|
|
@ -729,7 +729,7 @@ Device to use if
|
|||
is called with a NULL
|
||||
.Va name
|
||||
argument.
|
||||
.It Ev SIO_DEBUG
|
||||
.It Ev SNDIO_DEBUG
|
||||
The debug level:
|
||||
may be a value between 0 and 2.
|
||||
.El
|
||||
|
|
|
@ -20,22 +20,6 @@
|
|||
#include <sys/param.h>
|
||||
#include "sndio.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DPRINTF(...) \
|
||||
do { \
|
||||
if (sio_debug > 0) \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
} while(0)
|
||||
#define DPERROR(s) \
|
||||
do { \
|
||||
if (sio_debug > 0) \
|
||||
perror(s); \
|
||||
} while(0)
|
||||
#else
|
||||
#define DPRINTF(...) do {} while(0)
|
||||
#define DPERROR(s) do {} while(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* private ``handle'' structure
|
||||
*/
|
||||
|
@ -90,8 +74,4 @@ void sio_destroy(struct sio_hdl *);
|
|||
void sio_onmove_cb(struct sio_hdl *, int);
|
||||
void sio_onvol_cb(struct sio_hdl *, unsigned);
|
||||
|
||||
#ifdef DEBUG
|
||||
extern int sio_debug;
|
||||
#endif
|
||||
|
||||
#endif /* !defined(SNDIO_PRIV_H) */
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "sio_priv.h"
|
||||
|
||||
struct sio_sun_hdl {
|
||||
|
|
Loading…
Reference in New Issue