FNA-XNA / FAudio

FAudio - Accuracy-focused XAudio reimplementation for open platforms
https://fna-xna.github.io/
Other
545 stars 73 forks source link

Implement FAudioDebugConfiguration #59

Open flibitijibibo opened 5 years ago

flibitijibibo commented 5 years ago

From MSDN: https://docs.microsoft.com/en-us/windows/desktop/api/xaudio2/ns-xaudio2-xaudio2_debug_configuration

In addition to filling in one more XAudio2 feature, this is a legitimately useful for general FAudio debugging without having to step through a whole lot. It can be extremely verbose, however, so this should only be enabled for non-release builds (i.e. !_DEBUG && !DEBUG && (GCC && !OPTIMIZED)). Additionally, I would like to add the ability to enable features with environment variables, not just SetDebugConfiguration. This is useful for projects like Wine that won't have access to these entry points without added hackery. Each flag/bool should get a variable in some way.

As for the implementation, this can be mapped to something like SDL_Log, though I don't know how complicated we'll need to get. I'm hoping we can make all these log types macros that are blanked in release builds, but that's totally speculation without having actually tried to write this at all.

It's a big ol checklist:

aeikum commented 5 years ago

Using SetDebugConfiguration requires having the FAudio pointer available any place we want to add logging. Would you be OK if we have a global FAudioDebugConfiguration struct which just affects all FAudio instances instead of just the one that SetDebugConfiguration is called on?

flibitijibibo commented 5 years ago

I'd be okay with that, but which functions don't have the FAudio instance? I think every function has access, though it requires a bunch of walking to get to it (i.e. voice->audio for most voice functions).

aeikum commented 5 years ago

The walking itself is annoying, but I was thinking of the internal resampler functions, for example.

flibitijibibo commented 5 years ago

Ah, right - we may have to fudge that a bit by dumping the parameters as well as the function pointer handle before calling, without actually printing within the function. (Or maybe we can print the function pointer when we assign it, not sure...)

flibitijibibo commented 5 years ago

SetDebugConfiguration now has an implementation, it just needs to be used now:

https://github.com/FNA-XNA/FAudio/pull/64

flibitijibibo commented 5 years ago

Wrote a HUGE pile of code that allows writing debug traces with quick lines like this:

void FAudioPretendVoice_DoStuff(FAudioVoice *voice)
{
    LOG_API_ENTER(voice->audio);
    /* Stuff */
    LOG_API_EXIT(voice->audio);
}

It should now be pretty easy to write up most of the essentials and all the DebugConfiguration stuff should Just Work with each config combination. It even supports environment variables for each TraceMask flag and LogX bools!

flibitijibibo commented 5 years ago

Logs, logs everywhere

flibitijibibo commented 5 years ago

A couple things that may be of interest to Proton builds:

LOG_ASSERTIONS FORCE_ENABLE_DEBUGCONFIGURATION

NeroBurner commented 5 years ago

How can I let the log messages be written to a file instead of pop up windows?

flibitijibibo commented 5 years ago

You can either build with the LOG_ASSERTIONS CMake option or set the SDL_ASSERT environment variable to “always_ignore”.