ALSA project - the C library reference

Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
11/*
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as
14 * published by the Free Software Foundation; either version 2.1 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 *
26 */
27
28#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
29/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
30#warning "use #include <alsa/asoundlib.h>, <alsa/error.h> should not be used directly"
31#include <alsa/asoundlib.h>
32#endif
33
34#ifndef __ALSA_ERROR_H
35#define __ALSA_ERROR_H
37#ifdef __cplusplus
38 extern "C" {
39#endif
40
47#define SND_ERROR_BEGIN 500000
48#define SND_ERROR_INCOMPATIBLE_VERSION (SND_ERROR_BEGIN+0)
50 const char *snd_strerror(int errnum);
51
52#define SND_LOG_ERROR 1
53#define SND_LOG_WARN 2
54#define SND_LOG_INFO 3
55#define SND_LOG_DEBUG 4
56#define SND_LOG_TRACE 5
57#define SND_LOG_LAST SND_LOG_TRACE
59#define SND_ILOG_CORE 1
60#define SND_ILOG_CONFIG 2
61#define SND_ILOG_CONTROL 3
62#define SND_ILOG_HWDEP 4
63#define SND_ILOG_TIMER 5
64#define SND_ILOG_RAWMIDI 6
65#define SND_ILOG_PCM 7
66#define SND_ILOG_MIXER 8
67#define SND_ILOG_SEQUENCER 9
68#define SND_ILOG_UCM 10
69#define SND_ILOG_TOPOLOGY 11
70#define SND_ILOG_ASERVER 12
71#define SND_ILOG_LAST SND_ILOG_ASERVER
87 typedef void (*snd_lib_log_handler_t)(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg);
88 extern snd_lib_log_handler_t snd_lib_vlog;
89 int snd_lib_log_filter(int prio, int interface, const char *configstr);
90 void snd_lib_log(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...) /* __attribute__ ((format (printf, 7, 8))) */;
91 void snd_lib_check(int interface, const char *file, int line, const char *function, int errcode, const char *fmt, ...);
92 snd_lib_log_handler_t snd_lib_log_set_handler(snd_lib_log_handler_t handler);
93 snd_lib_log_handler_t snd_lib_log_set_local(snd_lib_log_handler_t handler);
94 const char *snd_lib_log_priority(int prio);
95 const char *snd_lib_log_interface(int interface);
96
97#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
98#define snd_error(interface, ...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__)
99#define snd_errornum(interface, ...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, __VA_ARGS__)
100#define snd_warn(interface, ...) snd_lib_log(SND_LOG_WARN, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__)
101#define snd_info(interface, ...) snd_lib_log(SND_LOG_INFO, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__)
102#define snd_debug(interface, ...) snd_lib_log(SND_LOG_DEBUG, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__)
103#define snd_trace(interface, ...) snd_lib_log(SND_LOG_TRACE, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__)
104#define snd_check(interface, ...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, __VA_ARGS__)
105#define snd_checknum(interface, ...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, __VA_ARGS__)
106#else
107#define snd_error(interface, args...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args)
108#define snd_errornum(interface, args...) snd_lib_log(SND_LOG_ERROR, SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, ##args)
109#define snd_warn(interface, args...) snd_lib_log(SND_LOG_WARN, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args)
110#define snd_info(interface, args...) snd_lib_log(SND_LOG_INFO, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args)
111#define snd_debug(interface, args...) snd_lib_log(SND_LOG_DEBUG, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args)
112#define snd_trace(interface, args...) snd_lib_log(SND_LOG_TRACE, SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args)
113#define snd_check(interface, args...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, 0, ##args)
114#define snd_checknum(interface, args...) snd_lib_check(SND_ILOG_##interface, __FILE__, __LINE__, __func__, errno, ##args)
115#endif
116
130 typedef void (*snd_lib_error_handler_t)(const char *file, int line, const char *function, int errcode, const char *fmt, ...) /* __attribute__ ((format (printf, 5, 6))) */;
131 extern snd_lib_error_handler_t snd_lib_error;
132 int snd_lib_error_set_handler(snd_lib_error_handler_t handler);
133
134#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
135#define SNDERR(...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, 0, __VA_ARGS__)
136#define SYSERR(...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, errno, __VA_ARGS__)
137#else
138#define SNDERR(args...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, 0, ##args)
139#define SYSERR(args...) snd_lib_log(SND_LOG_ERROR, 0, __FILE__, __LINE__, __func__, errno, ##args)
140#endif
141
143 typedef void (*snd_local_error_handler_t)(const char *file, int line,
144 const char *func, int errcode,
145 const char *fmt, va_list arg);
146 snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func);
147
150#ifdef __cplusplus
151}
152#endif
153
154
155
156#endif /* __ALSA_ERROR_H */
snd_lib_log_filter
int snd_lib_log_filter(int prio, int interface, const char *configstr)
Check if a log message should be shown based on LIBASOUND_DEBUG.
Definition error.c:277
snd_lib_check
void snd_lib_check(int interface, const char *file, int line, const char *function, int errcode, const char *fmt,...)
The check point function.
Definition error.c:379
snd_lib_vlog
snd_lib_log_handler_t snd_lib_vlog
Definition error.c:403
snd_strerror
const char * snd_strerror(int errnum)
Returns the message for an error code.
Definition error.c:53
snd_lib_log_set_local
snd_lib_log_handler_t snd_lib_log_set_local(snd_lib_log_handler_t handler)
Install local log handler.
Definition error.c:81
snd_lib_error_set_handler
int snd_lib_error_set_handler(snd_lib_error_handler_t handler)
Sets the error handler.
Definition error.c:495
snd_lib_log_interface
const char * snd_lib_log_interface(int interface)
Function to convert interface code to text.
Definition error.c:136
snd_lib_log_handler_t
void(* snd_lib_log_handler_t)(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt, va_list arg)
Log handler callback.
Definition error.h:87
snd_lib_log_set_handler
snd_lib_log_handler_t snd_lib_log_set_handler(snd_lib_log_handler_t handler)
Sets the log handler.
Definition error.c:413
snd_lib_error_set_local
snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func)
Install local error handler.
Definition error.c:427
snd_lib_log
void snd_lib_log(int prio, int interface, const char *file, int line, const char *function, int errcode, const char *fmt,...)
Root log handler function.
Definition error.c:359
snd_local_error_handler_t
void(* snd_local_error_handler_t)(const char *file, int line, const char *func, int errcode, const char *fmt, va_list arg)
Definition error.h:143
snd_lib_error_handler_t
void(* snd_lib_error_handler_t)(const char *file, int line, const char *function, int errcode, const char *fmt,...)
Error handler callback.
Definition error.h:130
snd_lib_error
snd_lib_error_handler_t snd_lib_error
Definition error.c:482
snd_lib_log_priority
const char * snd_lib_log_priority(int prio)
Function to convert log priority level to text.
Definition error.c:124