mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-16 08:56:42 -05:00
Added configurable error handlers.
This commit is contained in:
parent
34c76ccf73
commit
49affda3a0
5 changed files with 29 additions and 15 deletions
|
|
@ -3,8 +3,9 @@ sysinclude_HEADERS = asoundlib.h
|
||||||
|
|
||||||
# This is the order they will be concatenated into 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 \
|
header_files=header.h version.h global.h error.h control.h mixer.h pcm.h \
|
||||||
timer.h hwdep.h seq.h seqmid.h conv.h instr.h conf.h footer.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
|
noinst_HEADERS=$(header_files) search.h list.h aserver.h
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ extern "C" {
|
||||||
|
|
||||||
const char *snd_strerror(int errnum);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
14
include/global.h
Normal file
14
include/global.h
Normal file
|
|
@ -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
|
||||||
|
|
||||||
|
|
@ -36,15 +36,3 @@
|
||||||
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||||
#endif
|
#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)));
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ const char *snd_strerror(int errnum)
|
||||||
return snd_error_codes[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_list arg;
|
||||||
va_start(arg, fmt);
|
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);
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue