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