Bug 268164 - emulators/wine: Problem with base sound system (OSS) since the update to 7
Summary: emulators/wine: Problem with base sound system (OSS) since the update to 7
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2022-12-05 07:25 UTC by Alexander Vereeken
Modified: 2023-09-23 13:39 UTC (History)
6 users (show)

See Also:
bugzilla: maintainer-feedback? (damjan.jov)


Attachments
Patch to set ALSA for default audio and point libasound lib to the 32-Bit lib (2.95 KB, patch)
2023-08-20 19:21 UTC, Alexander Vereeken
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Vereeken freebsd_triage 2022-12-05 07:25:42 UTC
Hello,

i cant tell when this issue came up but since i do use wine with FreeBSD i have discovered that games like 


- Life is Strange (2015)

- HELLDIVERS

- The Incredible Adventures of Van Helsing

- Ember

- Terraria

- Lego Worlds 

- BioShockInfinite
BH6.exe

- WormsReloaded

- Rage

- PAYDAY 2

have crackling or disorted audio and the wokraround for that is to set the win version for the game binaries to winxp. But this is not an endless solution for me.

This is issue can be repodurced with aswell with xaudio other games too when an xaudio dll have been applied. 

For instance Elder Scrolls V Skyrim requieres xaudio2_6 set to native, buildin which results in more working audio like character voices and stuff but then the issue with the crackling or disorted audio comes up.

I do also have some modern xaudio games that are not starting up with the inbuild faudio in wine and if i apply the faudio verb via winetricks then these starts up but then there is also crackling or disorted audio.
Comment 1 Alexander Vereeken freebsd_triage 2022-12-06 21:15:32 UTC
For testing here a very small game which can reproduce this issue.

If you just launch it with wine then you can hear directly the bad audio, but if you set the prefix or the game binary to winxp then it will disappear.

64-Bit: https://cdn.discordapp.com/attachments/727023752348434436/1045438818037280768/Key_to_Success_x64.zip

32-Bit: https://cdn.discordapp.com/attachments/727023752348434436/1045437296230535178/Key_to_Success_x86.zip
Comment 2 Alexander Vereeken freebsd_triage 2023-01-11 11:13:00 UTC
Lets track the main issue first.

Mostly, Unreal Engine games that making usage of xaudio2 failing to start or continue without sound.

The issue have been now reported also on https://bugs.winehq.org/show_bug.cgi?id=54285.

2 Logs where the problem is more obvious to see have been attached in that external bug report.

These 2 games having issue with xaudio2_7 DLL.

When applying faudio via winetricks then these games are working again, maybe there is an problem with the inbuild faudio version in wine?

Thanks in advance!
Comment 3 Alastair Hogge 2023-01-11 13:59:40 UTC
Wow, thank you for the impressive diagnosis. I have followed your solution, and Mechwarrior 5 Mercenaries now loads successfully, and appears playable, however, the audio is a constant hiss interspersed with some recognisable samples. I am using wine-7.0.1,1 on 14-CURRENT with the following options:
ALSA           : off
CUPS           : off
DOCS           : on
DOSBOX         : off
GECKO          : on
GNUTLS         : on
LDAP           : off
MONO           : on
OPENAL         : on
OSS            : on
V4L            : off
WINEMAKER      : off
X11            : on

I will try building with ALSA later and see if that makes a difference.

Thank you so much for your efforts.

PS: Terraria worked fine, including audio prior to the winetricks solution.
Comment 4 Alexander Vereeken freebsd_triage 2023-01-11 14:39:11 UTC
Hello Alastair,

thank you for confirming!
Comment 5 Alastair Hogge 2023-01-12 05:44:00 UTC
Building emulators/wine with ALSA and without OSS does not improve the audio.
Comment 6 Alexander Vereeken freebsd_triage 2023-01-12 06:35:00 UTC
Yeah thats the 2nd issue that happends when xaudio gets used with DLL overrides.

Seems to be only an FreeBSD and Mac OS only issue as far i have seen.

However since the 1st issue appeard since update to 7, i think we need to git bisect this to get more attention.
Comment 7 Alexander Vereeken freebsd_triage 2023-02-11 14:41:50 UTC
Some other interesting notes:

I have noticed also that if the prefix or the game executable set to Windows 10 that it will call xaudio_2_9 and then the problem that gets created by the faudio winetricks workaround gets worse, its not that some samples are distorted the whole audio is then completely broken and volume is out of control.( When testing with this setting, it is best to mute the audio device )

While here CC'ing Gerald aswell since Gerald is the maintainer of the stable Wine.(Should this have been unnecessary then I apologize)
Comment 8 Alexander Vereeken freebsd_triage 2023-02-24 21:19:18 UTC
Hello again,

i can tell that the distorted noise caused by the faudio workaround is away when i do run an 14-CURRENT.
Comment 9 Alexander Vereeken freebsd_triage 2023-07-26 07:43:33 UTC
Hello,

i want to confirm that using alsa for audio fixes all problems.

I tried this now out because that the packinging got fixed for alsa and thats maybe why it didnt changed for Alastair.

So no workaround like 3rd party DLLs are needed and everything works now as intended.

That means that something between Wine and our base sound sytem is not working correctly anymore for now its ok but it could be great if someone could look into it.

This also fixed issues with FMOD audio and games in general that do use AFMT_FLOAT.


Putting alsa as a default audio would be then recommended for now as it fixes a big nummber of games and applications.
Comment 10 Alastair Hogge 2023-07-26 07:57:14 UTC
(In reply to Alexander Vereeken from comment #9)

Hey Alexander,

That is an interesting and exciting update, unfortunate about Open Sound System tho. I will try again with ALSA, thanks.
Comment 11 Gerald Pfeifer freebsd_committer freebsd_triage 2023-08-15 23:30:35 UTC
Should we remove the option to use OSS or at least change the default
from OSS to ALSA?
Comment 12 Alastair Hogge 2023-08-18 04:16:07 UTC
(In reply to Gerald Pfeifer from comment #11)

I was able to test with wine-7.0.2_3,1 and confirm Alexander's findings, audio with OSS is broken. I tested Mechwarrior 5 with ALSA and there is no longer any audio clipping or noise at all. I agree on making ALSA the default until OSS is restored or removed from Wine.
Comment 13 Alexander Vereeken freebsd_triage 2023-08-18 05:21:36 UTC
(In reply to Alastair Hogge from comment #12)

Thank you for confirming!

Before we decide to make alsa default we also have to test it on the 32-bit side in WoW64 mode.
Comment 14 Alexander Vereeken freebsd_triage 2023-08-20 19:21:45 UTC
Created attachment 244237 [details]
Patch to set ALSA for default audio and point libasound lib to the 32-Bit lib

I was able to confirm that it works on the 32-Bit side too.

It was only necessary to align the lib accordingly.

So this patch can be applied to wine7.
--

Before we touch emulators/wine with the default audio change, i want to test it in wine 8 if the audio bugs still occors there.

And because wow64 is not functional right now since wine 7.22 then the lib fix dont have to be applied to that port either because it gets obsolete with that update anyway right?
Comment 15 commit-hook freebsd_committer freebsd_triage 2023-08-27 21:22:57 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=06e0feb25f3fd07bfd324314d408a553a7770066

commit 06e0feb25f3fd07bfd324314d408a553a7770066
Author:     Gerald Pfeifer <gerald@FreeBSD.org>
AuthorDate: 2023-08-27 21:06:45 +0000
Commit:     Gerald Pfeifer <gerald@FreeBSD.org>
CommitDate: 2023-08-27 21:16:32 +0000

    emulators/wine: Switch the default from OSS to ALSA

    ALSA has been the default on Linux for ages and is what the
    majority of upstream Wine developers use. More importantly,
    though, it appears newer versions of Wine aren't actually
    quite working with OSS. So, switch the default over to ALSA.

    Bump PORTREVISION.

    PR:             268164

 emulators/wine/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 16 commit-hook freebsd_committer freebsd_triage 2023-08-27 21:22:59 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=215305d603efdcd77bcfd8715799cae69f708e7a

commit 215305d603efdcd77bcfd8715799cae69f708e7a
Author:     Alexander Vereeken <Alexander88207@protonmail.com>
AuthorDate: 2023-08-27 21:19:15 +0000
Commit:     Gerald Pfeifer <gerald@FreeBSD.org>
CommitDate: 2023-08-27 21:19:15 +0000

    emulators/wine: Cover alsa-lib in LD_32_LIBMAP

    Ensure the ALSA run-time portions are found under WoW64.

    PR:             268164

 emulators/wine/files/wine-wow64.sh | 1 +
 1 file changed, 1 insertion(+)
Comment 17 commit-hook freebsd_committer freebsd_triage 2023-09-01 23:05:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4f4374e51e069a7509b7f21bd12e23c198c25ac9

commit 4f4374e51e069a7509b7f21bd12e23c198c25ac9
Author:     Alexander Vereeken <Alexander88207@protonmail.com>
AuthorDate: 2023-09-01 23:04:21 +0000
Commit:     Gerald Pfeifer <gerald@FreeBSD.org>
CommitDate: 2023-09-01 23:04:21 +0000

    emulators/wine7: Cover alsa-lib in LD_32_LIBMAP

    Ensure the ALSA run-time portions are found under WoW64.

    (This backports 215305d603 from emulators/wine.)

    PR:             268164

 emulators/wine7/files/wine-wow64.sh | 1 +
 1 file changed, 1 insertion(+)
Comment 18 commit-hook freebsd_committer freebsd_triage 2023-09-01 23:05:53 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2de261ab70ec8e744d122f0bc2cd273fcec6c29f

commit 2de261ab70ec8e744d122f0bc2cd273fcec6c29f
Author:     Gerald Pfeifer <gerald@FreeBSD.org>
AuthorDate: 2023-09-01 22:59:03 +0000
Commit:     Gerald Pfeifer <gerald@FreeBSD.org>
CommitDate: 2023-09-01 22:59:03 +0000

    emulators/wine7: Switch the default from OSS to ALSA

    ALSA has been the default on Linux for ages and is what the
    majority of upstream Wine developers use. More importantly,
    though, it appears newer versions of Wine aren't actually
    quite working with OSS. So, switch the default over to ALSA.

    (This backports 06e0feb25f from emulators/wine.)

    Bump PORTREVISION.

    PR:             268164

 emulators/wine7/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 19 Sean Farley freebsd_committer freebsd_triage 2023-09-03 01:53:53 UTC
I just want to mention that OSS works for the games I play using Wine 8.11:
- AOE II: Conquerors
- Rocket League

However, that may be luck on my part.  On a slightly related note, I had to patch the OSS plugin in alsa-plugins to reduce the underruns I was experiencing in Veloren.

audio/alsa-plugins/files/patch-oss_pcm__oss.c
-+#define ALSA_OSS_BUFSZ_MAX    131072
++#define ALSA_OSS_BUFSZ_MAX    16384
Comment 20 commit-hook freebsd_committer freebsd_triage 2023-09-03 07:50:40 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e7ba5f6bf187b4d01feabb86ced156041faf081b

commit e7ba5f6bf187b4d01feabb86ced156041faf081b
Author:     Gerald Pfeifer <gerald@FreeBSD.org>
AuthorDate: 2023-09-03 07:50:01 +0000
Commit:     Gerald Pfeifer <gerald@FreeBSD.org>
CommitDate: 2023-09-03 07:50:01 +0000

    emulators/wine-devel: Switch the default from OSS to ALSA

    ALSA has been the default on Linux for ages and is what the majority
    of upstream Wine developers use. More importantly, though, it appears
    newer versions of Wine aren't actually quite working with OSS for many.
    So, switch the default over to ALSA.

    (This forward ports 06e0feb25f from emulators/wine.)

    Bump PORTREVISION.

    PR:             268164
    Approved by:    maintainer timeout

 emulators/wine-devel/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 21 Gerald Pfeifer freebsd_committer freebsd_triage 2023-09-03 09:06:09 UTC
(In reply to Sean Farley from comment #19)
> I just want to mention that OSS works for the games I play using Wine 8.11:

Thank you for these data points, Sean!

Interesting timing: I had prepared the switch of defaults for the 
wine-devel port yesterday, and went ahead and committed it now.


If you are interested in newer versions, 
 - bug #272710 has an update of emulators/wine to 8.0.2 which I plan
   to commit in the next days and
 - bug #273538 has an update of emulators/wine-devel to 8.14.


> However, that may be luck on my part.  On a slightly related note, I 
> had to patch the OSS plugin in alsa-plugins to reduce the underruns I
> was experiencing in Veloren.

Are you going to get this into the alsa-plugins port? It currently 
lists ports@ as maintainer, so it should be easy.
Comment 22 commit-hook freebsd_committer freebsd_triage 2023-09-09 13:12:26 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=39f0209b6fa86c621d4253fd3ecd0ebe286f379e

commit 39f0209b6fa86c621d4253fd3ecd0ebe286f379e
Author:     Gerald Pfeifer <gerald@FreeBSD.org>
AuthorDate: 2023-09-09 13:11:24 +0000
Commit:     Gerald Pfeifer <gerald@FreeBSD.org>
CommitDate: 2023-09-09 13:11:24 +0000

    emulators/wine-devel: Cover alsa-lib in LD_32_LIBMAP

    Forward port commit 215305d603 from emulators/wine:

      Author: Alexander Vereeken <Alexander88207@protonmail.com>
      Date:   Sun Aug 27 21:19:15 2023 +0000

      Ensure the ALSA run-time portions are found under WoW64.

    i386 and hence (the old way of) WoW64 is currently BROKEN, so this
    is not actually exercised right now. Still good to have this for
    when/if it may become relevant again.

    PR:             268164

 emulators/wine-devel/files/wine-wow64.sh | 1 +
 1 file changed, 1 insertion(+)
Comment 23 Sean Farley freebsd_committer freebsd_triage 2023-09-23 13:39:46 UTC
(In reply to Gerald Pfeifer from comment #21)

You are welcome for the information.  I understand the reason for switching the default to ALSA.

I will open a PR about the underruns but am not sure what is best.  Perhaps, Veloren is doing the wrong thing which causes the underruns.  However, a PR will be nice to document it.