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
flibitijibibo opened this Issue Aug 21, 2018 · 53 comments

Comments

Projects
None yet
@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

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Aug 22, 2018

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Aug 23, 2018

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Aug 24, 2018

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Aug 24, 2018

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

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Sep 8, 2018

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 added a commit to mat8913/wine that referenced this issue Sep 9, 2018

mat8913 added a commit to mat8913/wine that referenced this issue Sep 9, 2018

@flibitijibibo

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Oct 1, 2018

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

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Oct 3, 2018

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

This comment has been minimized.

Copy link

benoit-pierre commented Oct 3, 2018

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

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Oct 3, 2018

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

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.

@flibitijibibo flibitijibibo referenced this issue Oct 9, 2018

Open

Implement CALCULATE_DELAY flag #42

3 of 4 tasks complete
@juppso

This comment has been minimized.

Copy link

juppso commented Dec 12, 2018

First up, this is great news and great work, I was just wondering - are there any plans/potential methods to work around the licensing issues of FFmpeg? Or is this just something we have to live with?

@flibitijibibo

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Dec 12, 2018

I found out today that the Steam runtime has FFmpeg, so I’m going to see if we can’t just link to that and make it so WMA support is as simple as dropping your own WMA-enabled FFmpeg into the runtime, instead of having to do a whole rebuild. But yeah, the legal issue is something we’re stuck with.

@juppso

This comment has been minimized.

Copy link

juppso commented Dec 12, 2018

From that I assume the steam runtime FFmpeg doesn't have wma support, is that due to the same licensing issues? How do distro repo's get around that?

@flibitijibibo

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Dec 12, 2018

You’d have to ask each distribution about it. I know Fedora doesn’t provide FFmpeg at all due to issues like this (though you can get it from third parties), and other distributions with strict software policies are probably like this too.

@BeerZ0rg

This comment has been minimized.

Copy link

BeerZ0rg commented Dec 12, 2018

yup, Fedora doesn't provide FFmpeg due to legal issues, although negativo17 multimedia repo provides one with every codec enabled i believe. It sucks that WMA can't be enabled, i really hoped for Skyrim: SE (which now crashes) to be working out of the box.

@mozo78

This comment has been minimized.

Copy link

mozo78 commented Dec 12, 2018

It’s enabled by default, but WMA support is disabled.

Thank you :)

@arendtio

This comment has been minimized.

Copy link

arendtio commented Dec 12, 2018

I just tested it (for about 3 minutes) and it seems to work 👍 (Skyrim SE + FAudio + FFMPEG with WMA support). The one thing that took me a few minutes to figure out, is that the documented copy command isn't foolproof ;-)

I had to add \ Beta:

cp libFAudio.so ~/.local/share/Steam/steamapps/common/Proton\ 3.16\ Beta/dist/lib64/

Not very surprising given the fact that 3.16-5 is still in Beta ;-)

@dragonfly-lover

This comment has been minimized.

Copy link

dragonfly-lover commented Dec 12, 2018

Strider uses xaudio2, and sadly audio doesn't work yet.

@ghost

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

BeerZ0rg commented Dec 13, 2018

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

BeerZ0rg commented Dec 13, 2018

@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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

atm-florian commented Dec 15, 2018

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

flibitijibibo commented Mar 1, 2019

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:

flibitijibibo#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.