miniDSP
A small C library for audio DSP
Loading...
Searching...
No Matches
minidsp_error.c
Go to the documentation of this file.
1
6
7#include "minidsp.h"
8
9/* -----------------------------------------------------------------------
10 * Default handler: log to stderr, never abort.
11 * -----------------------------------------------------------------------*/
12
13static void default_error_handler(MD_ErrorCode code,
14 const char *func_name,
15 const char *message)
16{
17 fprintf(stderr, "miniDSP: error %d in %s(): %s\n",
18 (int)code, func_name, message);
19}
20
21/* -----------------------------------------------------------------------
22 * Handler state — set once before use, not thread-safe.
23 * -----------------------------------------------------------------------*/
24
25static MD_ErrorHandler current_handler = default_error_handler;
26
28{
29 current_handler = handler ? handler : default_error_handler;
30}
31
32/* -----------------------------------------------------------------------
33 * Internal reporting function (called by MD_CHECK macros).
34 * -----------------------------------------------------------------------*/
35
36void md_report_error(MD_ErrorCode code, const char *func_name,
37 const char *message)
38{
39 current_handler(code, func_name, message);
40}
A mini library of DSP (Digital Signal Processing) routines.
MD_ErrorCode
Error codes reported by miniDSP when a precondition is violated.
Definition minidsp.h:61
void(* MD_ErrorHandler)(MD_ErrorCode code, const char *func_name, const char *message)
Signature for a user-installed error handler.
Definition minidsp.h:78
void md_report_error(MD_ErrorCode code, const char *func_name, const char *message)
Report a precondition violation to the active error handler.
void MD_set_error_handler(MD_ErrorHandler handler)
Install a custom error handler.