jpayne@69
|
1 /**
|
jpayne@69
|
2 * \file include/error.h
|
jpayne@69
|
3 * \brief Application interface library for the ALSA driver
|
jpayne@69
|
4 * \author Jaroslav Kysela <perex@perex.cz>
|
jpayne@69
|
5 * \author Abramo Bagnara <abramo@alsa-project.org>
|
jpayne@69
|
6 * \author Takashi Iwai <tiwai@suse.de>
|
jpayne@69
|
7 * \date 1998-2001
|
jpayne@69
|
8 *
|
jpayne@69
|
9 * Application interface library for the ALSA driver
|
jpayne@69
|
10 */
|
jpayne@69
|
11 /*
|
jpayne@69
|
12 * This library is free software; you can redistribute it and/or modify
|
jpayne@69
|
13 * it under the terms of the GNU Lesser General Public License as
|
jpayne@69
|
14 * published by the Free Software Foundation; either version 2.1 of
|
jpayne@69
|
15 * the License, or (at your option) any later version.
|
jpayne@69
|
16 *
|
jpayne@69
|
17 * This program is distributed in the hope that it will be useful,
|
jpayne@69
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jpayne@69
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jpayne@69
|
20 * GNU Lesser General Public License for more details.
|
jpayne@69
|
21 *
|
jpayne@69
|
22 * You should have received a copy of the GNU Lesser General Public
|
jpayne@69
|
23 * License along with this library; if not, write to the Free Software
|
jpayne@69
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
jpayne@69
|
25 *
|
jpayne@69
|
26 */
|
jpayne@69
|
27
|
jpayne@69
|
28 #ifndef __ALSA_ERROR_H
|
jpayne@69
|
29 #define __ALSA_ERROR_H
|
jpayne@69
|
30
|
jpayne@69
|
31 #ifdef __cplusplus
|
jpayne@69
|
32 extern "C" {
|
jpayne@69
|
33 #endif
|
jpayne@69
|
34
|
jpayne@69
|
35 /**
|
jpayne@69
|
36 * \defgroup Error Error handling
|
jpayne@69
|
37 * Error handling macros and functions.
|
jpayne@69
|
38 * \{
|
jpayne@69
|
39 */
|
jpayne@69
|
40
|
jpayne@69
|
41 #define SND_ERROR_BEGIN 500000 /**< Lower boundary of sound error codes. */
|
jpayne@69
|
42 #define SND_ERROR_INCOMPATIBLE_VERSION (SND_ERROR_BEGIN+0) /**< Kernel/library protocols are not compatible. */
|
jpayne@69
|
43 #define SND_ERROR_ALISP_NIL (SND_ERROR_BEGIN+1) /**< Lisp encountered an error during acall. */
|
jpayne@69
|
44
|
jpayne@69
|
45 const char *snd_strerror(int errnum);
|
jpayne@69
|
46
|
jpayne@69
|
47 /**
|
jpayne@69
|
48 * \brief Error handler callback.
|
jpayne@69
|
49 * \param file Source file name.
|
jpayne@69
|
50 * \param line Line number.
|
jpayne@69
|
51 * \param function Function name.
|
jpayne@69
|
52 * \param err Value of \c errno, or 0 if not relevant.
|
jpayne@69
|
53 * \param fmt \c printf(3) format.
|
jpayne@69
|
54 * \param ... \c printf(3) arguments.
|
jpayne@69
|
55 *
|
jpayne@69
|
56 * A function of this type is called by the ALSA library when an error occurs.
|
jpayne@69
|
57 * This function usually shows the message on the screen, and/or logs it.
|
jpayne@69
|
58 */
|
jpayne@69
|
59 typedef void (*snd_lib_error_handler_t)(const char *file, int line, const char *function, int err, const char *fmt, ...) /* __attribute__ ((format (printf, 5, 6))) */;
|
jpayne@69
|
60 extern snd_lib_error_handler_t snd_lib_error;
|
jpayne@69
|
61 extern int snd_lib_error_set_handler(snd_lib_error_handler_t handler);
|
jpayne@69
|
62
|
jpayne@69
|
63 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
|
jpayne@69
|
64 #define SNDERR(...) snd_lib_error(__FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows a sound error message. */
|
jpayne@69
|
65 #define SYSERR(...) snd_lib_error(__FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows a system error message (related to \c errno). */
|
jpayne@69
|
66 #else
|
jpayne@69
|
67 #define SNDERR(args...) snd_lib_error(__FILE__, __LINE__, __func__, 0, ##args) /**< Shows a sound error message. */
|
jpayne@69
|
68 #define SYSERR(args...) snd_lib_error(__FILE__, __LINE__, __func__, errno, ##args) /**< Shows a system error message (related to \c errno). */
|
jpayne@69
|
69 #endif
|
jpayne@69
|
70
|
jpayne@69
|
71 /** \} */
|
jpayne@69
|
72
|
jpayne@69
|
73 #ifdef __cplusplus
|
jpayne@69
|
74 }
|
jpayne@69
|
75 #endif
|
jpayne@69
|
76
|
jpayne@69
|
77 /** Local error handler function type */
|
jpayne@69
|
78 typedef void (*snd_local_error_handler_t)(const char *file, int line,
|
jpayne@69
|
79 const char *func, int err,
|
jpayne@69
|
80 const char *fmt, va_list arg);
|
jpayne@69
|
81
|
jpayne@69
|
82 snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func);
|
jpayne@69
|
83
|
jpayne@69
|
84 #endif /* __ALSA_ERROR_H */
|
jpayne@69
|
85
|