jpayne@69: /** jpayne@69: * \file include/error.h jpayne@69: * \brief Application interface library for the ALSA driver jpayne@69: * \author Jaroslav Kysela jpayne@69: * \author Abramo Bagnara jpayne@69: * \author Takashi Iwai jpayne@69: * \date 1998-2001 jpayne@69: * jpayne@69: * Application interface library for the ALSA driver jpayne@69: */ jpayne@69: /* jpayne@69: * This library is free software; you can redistribute it and/or modify jpayne@69: * it under the terms of the GNU Lesser General Public License as jpayne@69: * published by the Free Software Foundation; either version 2.1 of jpayne@69: * the License, or (at your option) any later version. jpayne@69: * jpayne@69: * This program is distributed in the hope that it will be useful, jpayne@69: * but WITHOUT ANY WARRANTY; without even the implied warranty of jpayne@69: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jpayne@69: * GNU Lesser General Public License for more details. jpayne@69: * jpayne@69: * You should have received a copy of the GNU Lesser General Public jpayne@69: * License along with this library; if not, write to the Free Software jpayne@69: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA jpayne@69: * jpayne@69: */ jpayne@69: jpayne@69: #ifndef __ALSA_ERROR_H jpayne@69: #define __ALSA_ERROR_H jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \defgroup Error Error handling jpayne@69: * Error handling macros and functions. jpayne@69: * \{ jpayne@69: */ jpayne@69: jpayne@69: #define SND_ERROR_BEGIN 500000 /**< Lower boundary of sound error codes. */ jpayne@69: #define SND_ERROR_INCOMPATIBLE_VERSION (SND_ERROR_BEGIN+0) /**< Kernel/library protocols are not compatible. */ jpayne@69: #define SND_ERROR_ALISP_NIL (SND_ERROR_BEGIN+1) /**< Lisp encountered an error during acall. */ jpayne@69: jpayne@69: const char *snd_strerror(int errnum); jpayne@69: jpayne@69: /** jpayne@69: * \brief Error handler callback. jpayne@69: * \param file Source file name. jpayne@69: * \param line Line number. jpayne@69: * \param function Function name. jpayne@69: * \param err Value of \c errno, or 0 if not relevant. jpayne@69: * \param fmt \c printf(3) format. jpayne@69: * \param ... \c printf(3) arguments. jpayne@69: * jpayne@69: * A function of this type is called by the ALSA library when an error occurs. jpayne@69: * This function usually shows the message on the screen, and/or logs it. jpayne@69: */ jpayne@69: 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: extern snd_lib_error_handler_t snd_lib_error; jpayne@69: extern int snd_lib_error_set_handler(snd_lib_error_handler_t handler); jpayne@69: jpayne@69: #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95) jpayne@69: #define SNDERR(...) snd_lib_error(__FILE__, __LINE__, __func__, 0, __VA_ARGS__) /**< Shows a sound error message. */ jpayne@69: #define SYSERR(...) snd_lib_error(__FILE__, __LINE__, __func__, errno, __VA_ARGS__) /**< Shows a system error message (related to \c errno). */ jpayne@69: #else jpayne@69: #define SNDERR(args...) snd_lib_error(__FILE__, __LINE__, __func__, 0, ##args) /**< Shows a sound error message. */ jpayne@69: #define SYSERR(args...) snd_lib_error(__FILE__, __LINE__, __func__, errno, ##args) /**< Shows a system error message (related to \c errno). */ jpayne@69: #endif jpayne@69: jpayne@69: /** \} */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: /** Local error handler function type */ jpayne@69: typedef void (*snd_local_error_handler_t)(const char *file, int line, jpayne@69: const char *func, int err, jpayne@69: const char *fmt, va_list arg); jpayne@69: jpayne@69: snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func); jpayne@69: jpayne@69: #endif /* __ALSA_ERROR_H */ jpayne@69: