From bdec7a9ad3f5b3911dbb3b425d76ca3a53295a98 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 26 Feb 2004 10:52:40 +0000 Subject: [PATCH] Cleanup - the libaoss.so shouldn't depend on libasound.so --- alsa/alsa-local.h | 20 ++++++++++++++++++++ alsa/alsa-oss-emul.h | 19 ------------------- alsa/alsa-oss.c | 38 ++++++++++++++++++++++++++++++-------- alsa/mixer.c | 2 +- alsa/pcm.c | 2 +- 5 files changed, 52 insertions(+), 29 deletions(-) create mode 100644 alsa/alsa-local.h diff --git a/alsa/alsa-local.h b/alsa/alsa-local.h new file mode 100644 index 0000000..e5c89aa --- /dev/null +++ b/alsa/alsa-local.h @@ -0,0 +1,20 @@ +#include "alsa-oss-emul.h" + +#if 1 +#define DEBUG_POLL +#define DEBUG_SELECT +#ifdef NEW_MACRO_VARARGS +#define DEBUG(...) do { if (alsa_oss_debug) fprintf(stderr, __VA_ARGS__); } while (0) +#else /* !NEW_MACRO_VARARGS */ +#define DEBUG(args...) do { if (alsa_oss_debug) fprintf(stderr, ##args); } while (0) +#endif +#else +#ifdef NEW_MACRO_VARARGS +#define DEBUG(...) +#else /* !NEW_MACRO_VARARGS */ +#define DEBUG(args...) +#endif +#endif + +extern int alsa_oss_debug; +extern snd_output_t *alsa_oss_debug_out; diff --git a/alsa/alsa-oss-emul.h b/alsa/alsa-oss-emul.h index 5fbd906..756f50b 100644 --- a/alsa/alsa-oss-emul.h +++ b/alsa/alsa-oss-emul.h @@ -24,22 +24,6 @@ #define NEW_MACRO_VARARGS #endif -#if 1 -#define DEBUG_POLL -#define DEBUG_SELECT -#ifdef NEW_MACRO_VARARGS -#define DEBUG(...) do { if (alsa_oss_debug) fprintf(stderr, __VA_ARGS__); } while (0) -#else /* !NEW_MACRO_VARARGS */ -#define DEBUG(args...) do { if (alsa_oss_debug) fprintf(stderr, ##args); } while (0) -#endif -#else -#ifdef NEW_MACRO_VARARGS -#define DEBUG(...) -#else /* !NEW_MACRO_VARARGS */ -#define DEBUG(args...) -#endif -#endif - #define OSS_MAJOR 14 #define OSS_DEVICE_MIXER 0 #define OSS_DEVICE_SEQUENCER 1 @@ -78,7 +62,4 @@ extern int lib_oss_mixer_open(const char *pathname, int flags, ...); extern int lib_oss_mixer_close(int fd); extern int lib_oss_mixer_ioctl(int fd, unsigned long int request, ...); -extern int alsa_oss_debug; -extern snd_output_t *alsa_oss_debug_out; - #endif /* __ALSA_OSS_EMUL_H */ diff --git a/alsa/alsa-oss.c b/alsa/alsa-oss.c index 1005f19..497e7e4 100644 --- a/alsa/alsa-oss.c +++ b/alsa/alsa-oss.c @@ -30,17 +30,38 @@ #include #include #include +#include #include #include -#include +#include +#include #include #include #include -#include -#include #include "alsa-oss-emul.h" +#ifndef ATTRIBUTE_UNUSED +/** do not print warning (gcc) when function parameter is not used */ +#define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif + +#if 1 +#define DEBUG_POLL +#define DEBUG_SELECT +#ifdef NEW_MACRO_VARARGS +#define DEBUG(...) do { if (oss_wrapper_debug) fprintf(stderr, __VA_ARGS__); } while (0) +#else /* !NEW_MACRO_VARARGS */ +#define DEBUG(args...) do { if (oss_wrapper_debug) fprintf(stderr, ##args); } while (0) +#endif +#else +#ifdef NEW_MACRO_VARARGS +#define DEBUG(...) +#else /* !NEW_MACRO_VARARGS */ +#define DEBUG(args...) +#endif +#endif + int (*_select)(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); int (*_poll)(struct pollfd *ufds, unsigned int nfds, int timeout); int (*_open)(const char *file, int oflag, ...); @@ -76,6 +97,7 @@ typedef struct { void *mmap_area; } fd_t; +static int oss_wrapper_debug = 0; static int open_max; static int poll_fds_add = 0; static fd_t **fds; @@ -407,7 +429,7 @@ int poll(struct pollfd *pfds, unsigned long nfds, int timeout) if (direct) return _poll(pfds, nfds, timeout); #ifdef DEBUG_POLL - if (alsa_oss_debug) { + if (oss_wrapper_debug) { fprintf(stderr, "Orig enter "); dump_poll(pfds, nfds, timeout); fprintf(stderr, "Changed enter "); @@ -450,7 +472,7 @@ int poll(struct pollfd *pfds, unsigned long nfds, int timeout) count1++; } #ifdef DEBUG_POLL - if (alsa_oss_debug) { + if (oss_wrapper_debug) { fprintf(stderr, "Changed exit "); dump_poll(pfds1, nfds1, timeout); fprintf(stderr, "Orig exit "); @@ -529,7 +551,7 @@ int select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, if (direct) return _select(nfds, rfds, wfds, efds, timeout); #ifdef DEBUG_SELECT - if (alsa_oss_debug) { + if (oss_wrapper_debug) { fprintf(stderr, "Orig enter "); dump_select(nfds, rfds, wfds, efds, timeout); fprintf(stderr, "Changed enter "); @@ -598,7 +620,7 @@ int select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, count1++; } #ifdef DEBUG_SELECT - if (alsa_oss_debug) { + if (oss_wrapper_debug) { fprintf(stderr, "Changed exit "); dump_select(nfds1, rfds1, wfds1, efds1, timeout); fprintf(stderr, "Orig exit "); @@ -676,7 +698,7 @@ static void initialize() return; s = getenv("ALSA_OSS_DEBUG"); if (s) - alsa_oss_debug = 1; + oss_wrapper_debug = 1; open_max = sysconf(_SC_OPEN_MAX); if (open_max < 0) exit(1); diff --git a/alsa/mixer.c b/alsa/mixer.c index c0e86cc..f018362 100644 --- a/alsa/mixer.c +++ b/alsa/mixer.c @@ -38,7 +38,7 @@ #include #include -#include "alsa-oss-emul.h" +#include "alsa-local.h" typedef struct _oss_mixer { int fileno; diff --git a/alsa/pcm.c b/alsa/pcm.c index 8f7faf2..5d1a324 100644 --- a/alsa/pcm.c +++ b/alsa/pcm.c @@ -38,7 +38,7 @@ #include #include -#include "alsa-oss-emul.h" +#include "alsa-local.h" int alsa_oss_debug = 0; snd_output_t *alsa_oss_debug_out = NULL; -- 2.47.1