Implement FAudioDebugConfiguration #59

Open
opened 2018-11-11 14:28:30 -06:00 by flibitijibibo · 10 comments
flibitijibibo commented 2018-11-11 14:28:30 -06:00 (Migrated from github.com)

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:

  • TraceMask XAUDIO2_LOG_*
    • ERRORS
    • WARNINGS
    • INFO
    • DETAIL
    • API_CALLS
    • FUNC_CALLS
    • TIMING
    • LOCKS
    • MEMORY
    • STREAMING
  • BreakMask XAUDIO2_LOG_*
    • ERRORS
    • WARNINGS
  • LogThreadID
  • LogFileline
  • LogFunctionName
  • LogTiming
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: - [ ] TraceMask XAUDIO2_LOG_* - [x] ERRORS - [x] WARNINGS - [x] INFO - [x] DETAIL - [x] API_CALLS - [x] FUNC_CALLS - [ ] TIMING - [x] LOCKS - [ ] MEMORY - [ ] STREAMING - [ ] BreakMask XAUDIO2_LOG_* - [ ] ERRORS - [ ] WARNINGS - [x] LogThreadID - [x] LogFileline - [x] LogFunctionName - [x] LogTiming
aeikum commented 2018-11-13 10:39:02 -06:00 (Migrated from github.com)

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?

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 2018-11-13 10:44:51 -06:00 (Migrated from github.com)

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).

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 2018-11-13 10:45:54 -06:00 (Migrated from github.com)

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

The walking itself is annoying, but I was thinking of the internal resampler functions, for example.
flibitijibibo commented 2018-11-13 10:48:14 -06:00 (Migrated from github.com)

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...)

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 2018-11-13 14:05:52 -06:00 (Migrated from github.com)

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

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

SetDebugConfiguration now has an implementation, it just needs to be used now: https://github.com/FNA-XNA/FAudio/pull/64
flibitijibibo commented 2018-11-30 14:37:38 -06:00 (Migrated from github.com)

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!

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 2018-12-04 13:34:39 -06:00 (Migrated from github.com)
[Logs](https://github.com/FNA-XNA/FAudio/commit/0862c087471c8d2f8750f8a671e87054b1c3c31c), [logs](https://github.com/FNA-XNA/FAudio/commit/2941302a7e5a330fa847eba9dff38561afa5b841) [everywhere](https://github.com/FNA-XNA/FAudio/commit/1cca075cd753ad0e4c2b5f4b472ea4e76ce2d062)
flibitijibibo commented 2018-12-07 13:11:19 -06:00 (Migrated from github.com)

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

LOG_ASSERTIONS
FORCE_ENABLE_DEBUGCONFIGURATION

A couple things that may be of interest to Proton builds: [LOG_ASSERTIONS](https://github.com/FNA-XNA/FAudio/commit/b63a501370b469449b826fc71cead18faf4d7839) [FORCE_ENABLE_DEBUGCONFIGURATION](https://github.com/FNA-XNA/FAudio/commit/608083fa0f356b5fffa29747c2b797c752dbf741)
NeroBurner commented 2019-03-31 08:51:02 -05:00 (Migrated from github.com)

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

How can I let the log messages be written to a file instead of pop up windows?
flibitijibibo commented 2019-03-31 08:53:15 -05:00 (Migrated from github.com)

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

You can either build with the LOG_ASSERTIONS CMake option or set the SDL_ASSERT environment variable to “always_ignore”.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-FNA-XNA/FAudio#59
No description provided.