Skip to content

Supporting optional logging to user-provided callback. #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/FAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ typedef struct FAudioDebugConfiguration
int32_t LogFileline;
int32_t LogFunctionName;
int32_t LogTiming;
void (*LogCallback)(const char* msg, void* userData);
void* LogUserData;
} FAudioDebugConfiguration;

#pragma pack(pop)
Expand Down
9 changes: 8 additions & 1 deletion src/FAudio_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ void FAudio_INTERNAL_debug(
va_end(va);

/* Print, finally. */
FAudio_Log(output);
if (audio->debug.LogCallback)
{
audio->debug.LogCallback(output, audio->debug.LogUserData);
}
else
{
FAudio_Log(output);
}
}

static const char *get_wformattag_string(const FAudioWaveFormatEx *fmt)
Expand Down