11/* See ../rtmixer_build.py */
22
3- #include <assert.h> // for assert()
43#include <math.h> // for llround()
54#include <stdbool.h> // for bool, true, false
65
98
109#include "rtmixer.h"
1110
11+ #ifdef NDEBUG
12+ #define CALLBACK_ASSERT (expr ) ((void)(0))
13+ #else
14+ #define CALLBACK_ASSERT (expr ) \
15+ do { if (!(expr)) { \
16+ printf("Failed assertion in audio callback: \"" #expr "\" (" __FILE__ \
17+ ":%i)\n", __LINE__); \
18+ return paAbort; \
19+ }} while (false)
20+ #endif
21+
1222void remove_action (struct action * * addr , struct state * state )
1323{
14- assert (addr && * addr && state );
1524 struct action * action = * addr ;
1625 * addr = action -> next ; // Current action is removed from list
1726 action -> next = NULL ;
@@ -29,6 +38,7 @@ int callback(const void* input, void* output, frame_t frameCount
2938 , void * userData )
3039{
3140 struct state * state = userData ;
41+ CALLBACK_ASSERT (state );
3242
3343 memset (output , 0 , sizeof (float ) * state -> output_channels * frameCount );
3444
@@ -49,7 +59,7 @@ int callback(const void* input, void* output, frame_t frameCount
4959
5060 if (action -> type == CANCEL )
5161 {
52- assert (action -> action );
62+ CALLBACK_ASSERT (action -> action );
5363
5464 struct action * * actionaddr = & (state -> actions );
5565 while (* actionaddr )
@@ -148,7 +158,7 @@ int callback(const void* input, void* output, frame_t frameCount
148158 }
149159 if (frames + offset > frameCount )
150160 {
151- assert (frameCount > offset );
161+ CALLBACK_ASSERT (frameCount > offset );
152162 frames = frameCount - offset ;
153163 }
154164
0 commit comments