AndreRH / hangover

Hangover runs simple Win32 applications on arm64 Linux
GNU Lesser General Public License v2.1
1.24k stars 91 forks source link

Sound is missing in hangover #117

Closed daemongloom closed 2 months ago

daemongloom commented 3 years ago

System Details

Lenovo Chromebook Duet, crostini vm, Debian 10.

I've tried with hangover built via docker on that machine myself and Devedse's prebuilt versions

Problems Description

I've tried to launch old Marble Drop game (https://archive.org/details/marble-drop). It worked fine, but there was no sound. The same happened with putty. Error in log is 00c8:err:ole:apartment_getclassobject DllGetClassObject returned error 0x80004005 for dll L"C:\\windows\\system32\\mmdevapi.dll" 00c8:err:ole:com_get_class_object no class object {bcde0395-e52f-467c-8e3d-c4579291692e} could be created for context 0x1

Can't check winecfg's Audio tab as it dies with error. 0024:fixme:qemu_module:import_dll No implementation for ucrtbase.dll.__stdio_common_vswprintf_s imported from L"C:\\windows\\system32\\oleaut32.dll", setting to 0x74b9bf9705

Audio from that vm works fine, I've checked it with vlc.

Am I missing something in my setup? Any ways/tests to do to fix audio?

stefand commented 3 years ago

See if sound works in arm64 winecfg (not run inside hangover).

It is quite possible that our mmdevapi wrapper is missing some interfaces added in later Wine versions. Although I am curious why such an old game would go through the mmdevapi wrapper. I'd expect it to use either dsound or winmm, both of which are wrapped right away and then the arm64 DLLs call arm64 mmdevapi.

daemongloom commented 3 years ago

Wine from Debian 10 works fine. Audio tab in winecfg is working and test button plays sound successfully. Screenshot 2021-04-20 20 54 43

stefand commented 3 years ago

Use the same wine that you use to run hangover, not the one from the package repos. It could be that the hangover build is missing winepulse.drv.so for example. Just don't run the x86 winecfg, run the arm one.

daemongloom commented 3 years ago

I've launched /usr/lib/aarch64-linux-gnu/wine/fakedlls/winecfg.exe with hangover's wine. Audio tab was working, but there are no audio devices listed. "Test sound" button produces following error: 002c:err:process:NtCreateUserProcess L"\\??\\C:\\windows\\syswow64\\rundll32.exe" not supported on this installation (x86 binary) wine: configuration in L"/home/daemongloom/.wine" has been updated. 0024:err:mmdevapi:DllGetClassObject Driver initialization failed 0024:err:ole:apartment_getclassobject DllGetClassObject returned error 0x80004005 for dll L"C:\\windows\\system32\\mmdevapi.dll" 0024:err:ole:com_get_class_object no class object {bcde0395-e52f-467c-8e3d-c4579291692e} could be created for context 0x1 00fc:err:mmdevapi:DllGetClassObject Driver initialization failed

There is definitely no winepulse.drv.so in hangover's wine.

stefand commented 3 years ago

Ah that suggests that Devedse's docker container build is missing audio backends. Presumably because they don't care about audio for their image processing programs.

You can try to build yourself (it's not trivial unfortunately) or try to run qemu.exe.so with Debian's Wine (there are some hacks in hangover's Wine for edge cases, but it might run your game with sound)

daemongloom commented 3 years ago

Ah that suggests that Devedse's docker container build is missing audio backends. Presumably because they don't care about audio for their image processing programs.

There is also no winepulse.drv.so in docker-based build of hangover from this repo. I've built it on 1st of March, so it is not very old one.

stefand commented 3 years ago

Check the output of Wine's configure (the one in build/wine-host). It will warn about missing libraries - presumably you need something along the name libpulse and libpulse-dev or so. I am not a Debian user, so I don't know the exact names.

wine-hosts configure invocation in the top level Makefile is pretty simple: It is just

../../wine/configure

On x86_64 the top level Makefile adds --enable-win64, but that's specific to this platform. Oh, and it also points to a separate wine-tools build directory, but that only matters for cross compiling.

daemongloom commented 3 years ago

That's the problem. I used docker for building hangover because installing all dependencies on debian 10 is a pain. As it has very old software versions in repos. I'll try to check it tomorrow when there is enough time to do a complete new build.

Package is called libpulse-dev in debian.

daemongloom commented 3 years ago

I've added libpulse-dev to docker file. Hangover's winecfg dies when switching to audio tab. ARM64 winecfg shows audio tab, there is pulseaudio device, "Test" button plays sound successfully. Putty plays .wav file from game successfully.

But game shows following error:

0024:err:pulse:pulse_test_connect Failed to create context
0024:err:mmdevapi:DllGetClassObject Driver initialization failed
0024:err:ole:apartment_getclassobject DllGetClassObject returned error 0x80004005 for dll 
L"C:\\windows\\system32\\mmdevapi.dll"
0024:err:ole:com_get_class_object no class object {bcde0395-e52f-467c-8e3d-c4579291692e} could be created for context 0x1
0024:err:dsound:get_mmdevenum CoCreateInstance failed: 80004005

Any additional packages that I have to add?

Output from configure part:

configure: OpenCL 64-bit development files not found, OpenCL won't be supported.
configure: pcap 64-bit development files not found, wpcap won't be supported.
configure: libinotify 64-bit development files not found (or too old), filesystem change notifications won't be supported.
configure: libdbus 64-bit development files not found, no dynamic device support.
configure: libsane 64-bit development files not found, scanners won't be supported.
configure: libusb-1.0 64-bit development files not found (or too old), USB devices won't be supported.
configure: libv4l2 64-bit development files not found.
configure: libgphoto2 64-bit development files not found, digital cameras won't be supported.
configure: libgphoto2_port 64-bit development files not found, digital cameras won't be auto-detected.
configure: liblcms2 64-bit development files not found, Color Management won't be supported.
configure: libpulse 64-bit development files not found or too old, Pulse won't be supported.
configure: gstreamer-1.0 base plugins 64-bit development files not found, GStreamer won't be supported.
configure: OSS sound system found but too old (OSSv4 needed), OSS won't be supported.
configure: libudev 64-bit development files not found, plug and play won't be supported.
configure: libSDL2 64-bit development files not found, SDL2 won't be supported.
configure: libFAudio 64-bit development files not found, XAudio2 won't be supported.
configure: libcapi20 64-bit development files not found, ISDN won't be supported.
configure: libcups 64-bit development files not found, CUPS won't be supported.
configure: fontconfig 64-bit development files not found, fontconfig won't be supported.
configure: libgsm 64-bit development files not found, gsm 06.10 codec won't be supported.
configure: libkrb5 64-bit development files not found (or too old), Kerberos won't be supported.
configure: jxrlib 64-bit development files not found, JPEG-XR won't be supported.
configure: libtiff 64-bit development files not found, TIFF won't be supported.
configure: libmpg123 64-bit development files not found (or too old), mp3 codec won't be supported.
configure: libopenal 64-bit development files not found (or too old), OpenAL won't be supported.
configure: libvulkan and libMoltenVK 64-bit development files not found, Vulkan won't be supported.
configure: vkd3d 64-bit development files not found (or too old), Direct3D 12 won't be supported.
configure: libldap (OpenLDAP) 64-bit development files not found, LDAP won't be supported.
configure: WARNING: libgnutls 64-bit development files not found, no schannel support.
configure: WARNING: libjpeg 64-bit development files not found, JPEG won't be supported.
configure: WARNING: libpng 64-bit development files not found, PNG won't be supported.
configure: WARNING: No sound system was found. Windows applications will be silent.
configure: Finished.  Do 'make' to compile Wine.

It says that there would be no sound but Putty and winecfg both produce sound fine.

stefand commented 3 years ago

0024:err:pulse:pulse_test_connect Failed to create context

This is where the problem is, and it is a nasty issue. hangover is rather inefficient re address space (qemu allocs, wrapper libs, the JIT translated code, etc) and pulseaudio thinks it is running in a 64 bit process so it can map a huge shared memory blob into the process to transfer data between the client process and pulseaudio server.

Most old Win32 applications have just 2 GB address space available. While there is certainly room for PA's shm allocation in there by size, by the time the application tries to play sound the 2 GB are fragmented enough that PA can't place its shm area anywhere. I think for 64 bit processes it defaults to 256 mb nowadays, because why not, address space is free...

https://manpages.debian.org/testing/pulseaudio/pulse-client.conf.5.en.html enable-shm, shm-size-bytes. You can also try to edit qemu/windows-user/main.c to set large_address_aware to always true to have qemu keep a full 4 gb address space available. But that might break your app.

devedse commented 3 years ago

My fork indeed shouldn't have changed anything to the actual docker builds, I only changed the pipeline so that it creates an automatic release with every check-in.

This allows me to easily do a wget -O /root/buildfolder_build_arm64.tar.gz --no-verbose https://github.com/devedse/hangover/releases/latest/download/buildfolder_build_arm64.tar.gz to get the latest hangover release.

(It doesn't seem to be possible to do a latest wget on the actual build output)

daemongloom commented 3 years ago

I've built hangover without docker - it behaves exactly the same way as docker-built one (with added libpulse-dev). Log is the same as in my post https://github.com/AndreRH/hangover/issues/117#issuecomment-823798834

I've tried to enable-shm =yes and shm-size-bytes = 4194304 {that's 4MB}. It gives a bit different log:

starting L"/home/daemongloom/.wine/drive_c/Marble/marble.exe" with Hangover

0024:err:secur32:SECUR32_initSchannelSP TLS library not found, SSL connections will fail
32 bit environment set up, Large Address Aware: NO.
0024:fixme:qemu_ntdll:qemu_RtlAddVectoredExceptionHandler Unverified!
0024:fixme:qemu_kernel32:qemu_GetPrivateProfileSectionW Unverified!
0024:fixme:qemu_kernel32:qemu_GetEnvironmentStringsA Unverified!
0024:fixme:ntdll:NtQuerySystemInformation info_class SYSTEM_PERFORMANCE_INFORMATION
0024:fixme:mciavi:MCIAVI_mciRealize (0002, 00000000, 000000000022CF50) : stub
0024:fixme:mciavi:MCIAVI_mciRealize (0002, 00000000, 000000000022CF50) : stub
mmap() failed: Cannot allocate memory
Failed to create permanent mapping for memfd region with ID = 2849542420
mmap() failed: Cannot allocate memory
Failed to create permanent mapping for memfd region with ID = 2279003944
Ignoring received block reference with non-registered memfd ID = 2279003944
00c4:err:mmdevapi:DllGetClassObject Driver initialization failed
00c4:err:ole:apartment_getclassobject DllGetClassObject returned error 0x80004005 for dll L"C:\\windows\\system32\\mmdevapi.dll"
00c4:err:ole:com_get_class_object no class object {bcde0395-e52f-467c-8e3d-c4579291692e} could be created for context 0x1
0024:fixme:bitmap:CreateBitmapIndirect planes = 0
mmap() failed: Cannot allocate memory
Failed to create permanent mapping for memfd region with ID = 2849542420
mmap() failed: Cannot allocate memory
Failed to create permanent mapping for memfd region with ID = 2108268435
Ignoring received block reference with non-registered memfd ID = 2108268435
0024:err:mmdevapi:DllGetClassObject Driver initialization failed
0024:err:ole:apartment_getclassobject DllGetClassObject returned error 0x80004005 for dll L"C:\\windows\\system32\\mmdevapi.dll"
0024:err:ole:com_get_class_object no class object {bcde0395-e52f-467c-8e3d-c4579291692e} could be created for context 0x1
0024:err:dsound:get_mmdevenum CoCreateInstance failed: 80004005
0024:fixme:qemu_gdi32:qemu_SetSystemPaletteUse Unverified!
0024:fixme:qemu_gdi32:qemu_SetSystemPaletteUse Unverified!
0024:fixme:qemu_gdi32:qemu_ResizePalette Unverified!

I'll try editing qemu now.

Added later Qemu fix changes nothing sadly.

AndreRH commented 2 months ago

Sound should not be an issue anymore, open new issues in case there's some trouble