From 49affda3a0c69596934641c2c380a591b2830b54 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sat, 25 Nov 2000 16:36:18 +0000 Subject: [PATCH] Added configurable error handlers. --- include/Makefile.am | 5 +++-- include/error.h | 4 ++++ include/global.h | 14 ++++++++++++++ include/header.h | 12 ------------ src/error.c | 9 ++++++++- 5 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 include/global.h diff --git a/include/Makefile.am b/include/Makefile.am index a930d93a..9b0b5907 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -3,8 +3,9 @@ sysinclude_HEADERS = asoundlib.h # This is the order they will be concatenated into asoundlib.h! # -header_files=header.h version.h error.h control.h mixer.h pcm.h rawmidi.h \ - timer.h hwdep.h seq.h seqmid.h conv.h instr.h conf.h footer.h +header_files=header.h version.h global.h error.h control.h mixer.h pcm.h \ + rawmidi.h timer.h hwdep.h seq.h seqmid.h conv.h instr.h conf.h \ + footer.h noinst_HEADERS=$(header_files) search.h list.h aserver.h diff --git a/include/error.h b/include/error.h index eb666add..d13046d4 100644 --- a/include/error.h +++ b/include/error.h @@ -11,6 +11,10 @@ extern "C" { const char *snd_strerror(int errnum); +typedef void (snd_lib_error_handler_t)(const char *file, int line, const char *function, int err, const char *fmt, ...) /* __attribute__ ((weak, format (printf, 5, 6))) */; +extern snd_lib_error_handler_t *snd_lib_error; +extern int snd_lib_error_set_handler(snd_lib_error_handler_t *handler); + #ifdef __cplusplus } #endif diff --git a/include/global.h b/include/global.h new file mode 100644 index 00000000..c3ab7b9d --- /dev/null +++ b/include/global.h @@ -0,0 +1,14 @@ +/* + * Global defines + */ + +#define SND_DEV_TYPE_PCM 0 +#define SND_DEV_TYPE_CONTROL 1 +#define SND_DEV_TYPE_RAWMIDI 2 +#define SND_DEV_TYPE_TIMER 3 +#define SND_DEV_TYPE_HWDEP 4 +#define SND_DEV_TYPE_SEQ 5 + +#define SND_TRANSPORT_TYPE_SHM 0 +#define SND_TRANSPORT_TYPE_TCP 1 + diff --git a/include/header.h b/include/header.h index 8ce91f67..51648a95 100644 --- a/include/header.h +++ b/include/header.h @@ -36,15 +36,3 @@ #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) #endif -#define SND_DEV_TYPE_PCM 0 -#define SND_DEV_TYPE_CONTROL 1 -#define SND_DEV_TYPE_RAWMIDI 2 -#define SND_DEV_TYPE_TIMER 3 -#define SND_DEV_TYPE_HWDEP 4 -#define SND_DEV_TYPE_SEQ 5 - -#define SND_TRANSPORT_TYPE_SHM 0 -#define SND_TRANSPORT_TYPE_TCP 1 - -extern void snd_lib_error(const char *file, int line, const char *function, int err, const char *fmt, ...) __attribute__ ((weak, format (printf, 5, 6))); - diff --git a/src/error.c b/src/error.c index b5871f9a..fa799c05 100644 --- a/src/error.c +++ b/src/error.c @@ -44,7 +44,7 @@ const char *snd_strerror(int errnum) return snd_error_codes[errnum]; } -void snd_lib_error(const char *file, int line, const char *function, int err, const char *fmt, ...) +static void snd_lib_error_default(const char *file, int line, const char *function, int err, const char *fmt, ...) { va_list arg; va_start(arg, fmt); @@ -56,3 +56,10 @@ void snd_lib_error(const char *file, int line, const char *function, int err, co va_end(arg); } +snd_lib_error_handler_t *snd_lib_error = snd_lib_error_default; + +int snd_lib_error_set_handler(snd_lib_error_handler_t *handler) +{ + snd_lib_error = handler == NULL ? snd_lib_error_default : handler; + return 0; +} -- 2.47.1