Skip to content
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

[XAudio2] FAudio support #2

Closed
2 of 6 tasks
flibitijibibo opened this issue Aug 21, 2018 · 53 comments
Closed
2 of 6 tasks

[XAudio2] FAudio support #2

flibitijibibo opened this issue Aug 21, 2018 · 53 comments

Comments

@flibitijibibo
Copy link
Contributor

flibitijibibo commented Aug 21, 2018

So now that this is out in the wild...

FAudio is a new, accuracy-focused reimplementation of XAudio2 and its relative libraries (such as X3DAudio, XACT, and XAPO). Part of this work includes a COM wrapper that mimics the Windows XAudio2 DLLs, allowing Windows games to use FAudio for audio support instead. This is known to work on both Windows and Wine for 32- and 64-bit, and both @JohanSmet and @aeikum have been putting in work to make it more compatible with the whole range of XAudio2 versions.

At the moment Wine is reimplementing XAudio2 with OpenAL Soft, and the other libraries (including X3DAudio) are currently stubbed. In addition to the feature gaps, there are also various accuracy issues that come from wrapping a low-level audio API around a high-level API (as we found ourselves while making FNA, hence the creation of FAudio).

The idea is that FAudio would both fill in large gaps left by the current Wine implementation as well as make the existing implementation much more accurate, and in a perfect world, remove the need for the DX redist for audio support.

Andrew has been leading the charge with Wine compatibility lately so I'll let him drive this thread, but the main things that Wine cares about:

@flibitijibibo
Copy link
Contributor Author

Spent some time on this today, the COM wrapper should work out of the box again (some recent 2.8+ compat and SIMD optimizations screwed it up) if anyone wants to play with this right now.

@mirh
Copy link

mirh commented Aug 23, 2018

At the moment Wine is reimplementing XAudio2 with OpenAL Soft, and the other libraries (including X3DAudio) are currently stubbed.

Uh? For real, no more MMDevAPI?
And.. are we sure this time the third or fourth rewrite of the audio stack will finally be the right one?

and in a perfect world, remove the need for the DX redist for audio support.

I mean, isn't that what windows itself requires?

@flibitijibibo
Copy link
Contributor Author

FAudio is a plain-as-peaches C implementation of XAudio2 and is already shipping in other work, so I'm pretty sure this won't end up like other scenarios where implementations were done with high-level wrappers or were unfinished and abandoned. Windows does require the DX redist but we don't have to be like that!

In other news, I just threw together the XACT COM wrapper source, but not the project files themselves... I think it'll work but the COM stuff isn't something I'm terribly familiar with myself:

FNA-XNA/FAudio#27

@aeikum
Copy link
Collaborator

aeikum commented Aug 23, 2018

Just so no one goes too far down this road, I already have the Wine integration work for xaudio2, xapofx, and x3daudio done in my tree. It's currently at the point where I'm testing games that worked in Wine's "old" xaudio2 and ensuring they work in the new FAudio-based xaudio2. I just got busy with other stuff ;)

@mirh
Copy link

mirh commented Aug 23, 2018

So.. How's the final picture going to look like?

Windows does require the DX redist but we don't have to be like that!

Mhh.. Newer windows maybe not either - but I'm not sure how much wine would be happy to differ otherwise.

@aeikum
Copy link
Collaborator

aeikum commented Aug 23, 2018

Same as it is now, we're just going to use FAudio to do the audio mixing instead of OpenAL, since it's a much better fit. All the audio still goes through the normal Wine audio paths.

@mirh
Copy link

mirh commented Aug 23, 2018

Oh, "reimplementing" was with respect to windows, not a previous wine architecture.

Are you also going to implement directsound on top of it then? Vista+ does at least.
How's FAudio going to play out with XP setting then? Are you going to add it a (faithful) directsound backend?

@flibitijibibo
Copy link
Contributor Author

flibitijibibo commented Aug 24, 2018

Just finished making the XACT DLLs! XACT 3.0 to 3.7 should work with FAudio now.

EDIT: Demo vid, because why not https://www.youtube.com/watch?v=_gFpDfN60S4

@tgurr
Copy link
Contributor

tgurr commented Aug 24, 2018

@flibitijibibo would it be possible to have the dlls in a precompiled form ready to download somewhere so the guys from winetricks could add a verb for it to ease testing?

@flibitijibibo
Copy link
Contributor Author

At the moment FAudio is moving really fast so precompiled wouldn't be of much use - I may do this for stable releases though (expected to be every month on the 1st, alongside FNA releases). This may be a good time to test out Johan's README:

https://github.com/FNA-XNA/FAudio/tree/master/cpp

@aeikum
Copy link
Collaborator

aeikum commented Aug 24, 2018

FWIW I put my WIP patches at https://github.com/aeikum/FAudio/commits/wip-totally-broken . It is in no way usable in its current state, but has some needs-more-research fixes to get more games to work.

@aeikum
Copy link
Collaborator

aeikum commented Aug 24, 2018

I also put the matching wine.git commit here, again, totally broken. https://github.com/aeikum/wine/commits/wip-faudio

@flibitijibibo
Copy link
Contributor Author

On the subject of broken things, the XACT wrapper is now at the point where Resident Evil 4 should run (though it's probably very fragile since it depends on a slightly unimplemented function). If you self-build, set this to 1:

FNA-XNA/FAudio@38471d2#diff-396a3a789a898fb29cce92cb6fc31014R2328

@flibitijibibo
Copy link
Contributor Author

By far the most requested feature since Proton has gone out is WMA support - here's the issue where we're now tracking this:

FNA-XNA/FAudio#32

There's some existing code but none of it is meant to work (it doesn't even compile yet), so if you're familiar with FFmpeg and want to fix this problem, that's the place to start.

mat8913 pushed a commit to mat8913/wine that referenced this issue Sep 9, 2018
mat8913 pushed a commit to mat8913/wine that referenced this issue Sep 9, 2018
@flibitijibibo
Copy link
Contributor Author

Work on this has been sparse since FAudio now works with FNA and I'm still in the process of seeing if I can work on this in a more official capacity, but in the meantime I've been given a couple games and I made some more samples.

Sonic Mania: https://www.youtube.com/watch?v=FV_GPY8O9ww

A Hat in Time (64-bit!): https://www.youtube.com/watch?v=I9NEkqfhWDw

@flibitijibibo
Copy link
Contributor Author

Had a bit of free time today, so I cleaned up the existing work for the COM wrapper and now it's MUCH easier to build and run yourself. All you need is MinGW-w64, MinGW-SDL2 (2.0.8 or greater), and Git, all of which are most likely in your repositories.

To build:

git clone git://github.com/FNA-XNA/FAudio.git
cd FAudio
source cpp/cross_compile_64 # Can be 32 if you want
make
cd cpp
make

Then you can use cpp/scripts/wine_setup_native to install these to a specific prefix. Be sure to read the documentation and the script first, however:

https://github.com/FNA-XNA/FAudio/blob/master/cpp/README.md

As of now my recommendation is to install the XAudio2 DLL, but NOT X3DAudio. So you would be removing these 5 lines, for example:

https://github.com/FNA-XNA/FAudio/blob/master/cpp/scripts/wine_setup_native#L62

XACTEngine may or may not work, but honestly so few games use this that I'd be surprised if you ran into it at all.

@benoit-pierre
Copy link

There's a typo in the cpp/README.md: scrips/cross_compile_32 -> scripts/cross_compile_32. It would also be better if those 2 scripts used return 1 instead of exit 1 when the mingw32 / SDL environment is incorrectly set, since they are supposed to be sourced.

@flibitijibibo
Copy link
Contributor Author

If you can, do a pass through the files and for anything you find that's off send a PR, I can merge it right away if it's all docs plus the return code.

@dhewg
Copy link
Contributor

dhewg commented Oct 4, 2018

Tested on Witcher 3, which fixes audio cracks followed by volume drops I got with wine internal xaudio2_7, nice!

@pc-bil
Copy link

pc-bil commented Oct 9, 2018

Tested Skyrim Special Edition but without success. The following errors were logged:
INFO: Invalid destination channels
WARN: \n\nAssertion failure at FAudio_PlatformInit (src/FAudio_platform_sdl2.c:188), triggered 1 time:\r\n '0 && "Failed to open audio device!
WARN: \n\nAssertion failure at FAudio_CreateSourceVoice (src/FAudio.c:260), triggered 1 time:\r\n '0 && "Unsupported format tag!
WARN: \n\nAssertion failure at FAudioSourceVoice_SubmitSourceBuffer (src/FAudio.c:1274), triggered 1 time:\r\n 'pBufferWMA == ((void *)0)

So, it's not looking too promising.

@ghost
Copy link

ghost commented Dec 12, 2018

Proton 3.16-5 ships with FAudio support! It should cover most cases but the one big case is WMA support. This is a licensing restriction that's out of our control right now, but thankfully it's still in yours:

Thanks!
you guys are doing gods work, latest release makes skyrim playable

kakra referenced this issue in kakra/wine-proton Dec 12, 2018
@mirh
Copy link

mirh commented Dec 12, 2018

Isn't this expired already?
And even if not, wouldn't it fall under the 60k patents microsoft opened 2 months ago for OIN?

@juppso
Copy link

juppso commented Dec 13, 2018

Assuming it is that patent which is in question for this case, it would appear that while not expired it should be covered under the OIN?

@BeerZ0rg
Copy link

I have FFmpeg 4.1.0 with all codecs enabled (including WMA), i've built FAudio and replaced it in Proton 3.16 Beta and now Skyrim: SE runs, but there is something wrong with sound. It is buzzing or cracking every few minutes. Also Skyrim crashes on exit (same way it did with xact native dll).

@kakra
Copy link
Contributor

kakra commented Dec 13, 2018

@BeerZ0rg I'm no longer having the crackling sound issue in my build. Could you try https://github.com/kakra/wine-proton, it is rebased to a newer wine version including several patches and experimental improvements. Maybe we can isolate the required patches... SkyrimSE works fine here. But currently you'd have to compile from source (should be easy) and extract the resulting dist.tar.xz to the proton beta folder.

@BeerZ0rg
Copy link

@kakra Thanks, i'll try this when im back home in couple of hours. The ammount of work done here is so impressive im feeling like Christmas already.

@kakra
Copy link
Contributor

kakra commented Dec 13, 2018

@BeerZ0rg Nah, there's a few days left until then. ;-)

I'm planing to push a refined branch this evening (CEST).

@foresto
Copy link

foresto commented Dec 13, 2018

Also Skyrim crashes on exit

Skyrim has a crash-on-exit bug caused by one of the DLC. (Dawnguard, I think, but I'm not sure of that.) You might want to try again with DLC disabled.

@kakra
Copy link
Contributor

kakra commented Dec 13, 2018

@foresto It can crash or freeze. Usually, with built-in xaudio2_7, it freezes. It may crash otherwise with native xaudio2_7, I'm not sure, but from Proton it looks like a clean exit so that's okay.

kakra referenced this issue in kakra/wine-proton Dec 14, 2018
@kakra
Copy link
Contributor

kakra commented Dec 14, 2018

@BeerZ0rg My branch is updated now.

kakra referenced this issue in kakra/wine-proton Dec 15, 2018
@atm-florian
Copy link

As explain in https://github.com/FNA-XNA/FAudio/wiki/FAudio-for-Proton SDL 2.0.9 is needed... Ubuntu 16.04 (or even 18.04) => SDL 2.0.4 (2.0.8)... Can't compile... Arfff, in one or two year Fallout 4 or Skyrim SE should be played out of the box with Proton. But for now stuck with Xaudio.

@kakra
Copy link
Contributor

kakra commented Dec 22, 2018

It compiles fine here on Gentoo with SDL 2.0.8, tho it's throwing a warning during compile to upgrade ASAP. In my Ubuntu (cosmic) container, it also compiles fine, cosmic seems to have SDL 2.0.9.

@mati865
Copy link

mati865 commented Dec 22, 2018

@kakra Debian sid and Ubuntu cosmic/disco still are at 2.0.8 version. Once Debian upgrades to 2.0.9 it'll to be pulled by next Ubuntu release before freeze (it's too late for anything <19.04 aka Disco).

@LinuxUser404
Copy link

LinuxUser404 commented Feb 5, 2019

This might impact The Darkness II. Using "winetricks xact xact_july2010"(though xact_july2010 is probably redundant) solves all audio issues in the game with the most recent version of wine (wine-4.0). It is also worth noting that the game runs with wine out of the box though fails to start with "Steam Play".

The game might make it to platinum rating if the audio problems were solved without winetrick and the following patch(that fixes and old "missing textures" bug) made it to wine:
https://bugs.winehq.org/attachment.cgi?id=54454&action=diff

@kisak-valve
Copy link
Member

kisak-valve commented Feb 5, 2019

Hello @LinuxUser404, please use the Proton issue tracker for game-specific discussion, in your case ValveSoftware/Proton#563 (and issues with upstream wine should be reported to the winehq issue tracker).

@flibitijibibo
Copy link
Contributor Author

Wine 4.3 includes the FAudio rewrite:

https://www.winehq.org/announce/4.3

Proton 3.16-5+ also includes the XACT DLLs, but some work will need to go into that before it goes into upstream:

https://github.com/flibitijibibo/wine/pull/2

The FAudio-specific stuff is tracked over here:

https://github.com/FNA-XNA/FAudio/issues

Developers can use the above issue tracker, and all other users are encouraged to use the Proton issue tracker for any issues found in specific titles:

https://github.com/ValveSoftware/proton/issues

AlexeyProkhin pushed a commit to AlexeyProkhin/wine that referenced this issue Aug 27, 2019
rbernon pushed a commit to rbernon/wine-proton that referenced this issue Oct 22, 2019
rbernon pushed a commit to rbernon/wine-proton that referenced this issue Dec 17, 2019
rbernon added a commit to rbernon/wine-proton that referenced this issue Aug 14, 2021
# This is the 1st commit message:

winebus.sys: Pass HID_XFER_PACKET and IO_STATUS_BLOCK to callbacks.

# The commit message ValveSoftware#2 will be skipped:

# fixup winebus.sys: Pass HID_XFER_PACKET and IO_STATUS_BLOCK to callbacks.
arilou added a commit to arilou/proton-wine that referenced this issue Nov 21, 2023
arilou added a commit to arilou/proton-wine that referenced this issue Nov 21, 2023
arilou added a commit to arilou/proton-wine that referenced this issue Nov 21, 2023
arilou added a commit to arilou/proton-wine that referenced this issue Nov 21, 2023
arilou added a commit to arilou/proton-wine that referenced this issue Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests