diff --git a/CMakeLists.txt b/CMakeLists.txt index 6394e3f..15d3a42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ option(BUILD_EXAMPLES "Build the example applications" ON) option(BUILD_TESTER "Build the tester application" ON) option(BUILD_SIMD "Build with SIMD as minimum requirement" ON) option(BUILD_DOCS "Build the doxygen documentation files" ON) +option(BUILD_DEBUG_LOG "Build with debug logging output" OFF) set(BUILD_SIMD_VERSION "SSE" CACHE STRING "Which SIMD version to require") ## Generate version @@ -150,6 +151,9 @@ target_include_directories(mixed PRIVATE "src/" "libsamplerate/" "spiralfft/") set_property(TARGET mixed PROPERTY C_STANDARD 99) set_property(TARGET mixed PROPERTY POSITION_INDEPENDENT_CODE ON) target_compile_definitions(mixed PRIVATE MIXED_BUILD=1 MIXED_VERSION="${MIXED_VERSION_STRING}") +if(BUILD_DEBUG_LOG) + target_compile_definitions(mixed PRIVATE MIXED_DEBUG=1) +endif() target_compile_options(mixed PRIVATE ${COMPILATION_FLAGS} -W -Wall -Wextra -Wpedantic -Wno-ignored-attributes -Wno-enum-conversion) find_library(DL_LIB dl) diff --git a/src/bip.h b/src/bip.h index c89c72c..e756dfe 100644 --- a/src/bip.h +++ b/src/bip.h @@ -27,6 +27,7 @@ static inline int bip_request_write(uint32_t *off, uint32_t *size, struct bip *b }else{ // Read has not done anything yet, no space! *size = 0; *off = 0; + debug_log("%p Overrun", buffer); return 0; } }else if(write < read){ @@ -38,6 +39,7 @@ static inline int bip_request_write(uint32_t *off, uint32_t *size, struct bip *b }else{ *size = 0; *off = 0; + debug_log("%p Overrun", buffer); return 0; } return 1; @@ -77,6 +79,7 @@ static inline int bip_request_read(uint32_t *off, uint32_t *size, struct bip *bu }else{ // Write has not done anything yet, no space! *size = 0; *off = 0; + debug_log("%p Underrun", buffer); return 0; } }else if(read < write){ @@ -85,6 +88,7 @@ static inline int bip_request_read(uint32_t *off, uint32_t *size, struct bip *bu }else{ *size = 0; *off = 0; + debug_log("%p Underrun", buffer); return 0; } return 1; diff --git a/src/internal.h b/src/internal.h index fec9678..b173497 100644 --- a/src/internal.h +++ b/src/internal.h @@ -32,6 +32,12 @@ #define IGNORE(...) __ignore(0, __VA_ARGS__) static inline void __ignore(char _, ...){(void)_;} +#ifdef MIXED_DEBUG +#define debug_log(...) {fprintf(stderr, "[libmixed] "); fprintf(stderr, __VA_ARGS__);} +#else +#define debug_log(...) +#endif + #if defined(__GNUC__) && !defined(__WIN32__) #if defined(__x86_64__) #define VECTORIZE __attribute__((target_clones("avx2","avx","sse4.1","default")))