Thanks for updating the default linux compat to -c7. I have some very hopeful results with a couple of games. However, I just cannot get sound working through alsa which a lot of the games (anything unity based) depend on. I know that sound through linux-compat works in general because things that use OpenAL like the unigine ports work. My Setup: # pkg info | grep alsa alsa-lib-1.1.2_2 ALSA compatibility library alsa-plugins-1.1.1_6 ALSA compatibility library plugins alsa-utils-1.1.2 ALSA compatibility utils linux-c7-alsa-lib-1.1.6 Advanced Linux Sound Architecture libraries (Linux CentOS 7.6.1810) linux-c7-alsa-plugins-oss-1.1.6 OSS plugin for ALSA (Linux CentOS 7.6.1810) linux-c7-alsa-utils-1.1.6 Advanced Linux Sound Architecture utilities (Linux CentOS 7.6.1810) % freebsd-version 12.0-STABLE % pkg info | grep nvidia gstreamer-plugins-vdpau-0.10.23_3,3 Gstreamer nvidia vdpau plugin nvidia-driver-390.87_3 NVidia graphics card binary drivers for hardware OpenGL rendering nvidia-settings-430.14 Display Control Panel for X NVidia driver Here's what I have tried: Native FreeBSD alsa speaker-test works: % speaker-test speaker-test 1.1.2 Wiedergabe-Gerät ist default Stream-Parameter sind 48000 Hz, S16_LE, 1 Kanäle Verwende 16 Oktaven rosa Rauschen Rate ist 48000 Hz (angefordert: 48000 Hz) Puffergröße von 16 bis 65536 Periodengröße von 8 bis 32768 Verwende maximale Puffergröße 65536 Perioden = 4 gesetzt: period_size = 16384 gesetzt: buffer_size = 65536 Linux speaker-test fails: % /compat/linux/usr/bin/speaker-test speaker-test 1.1.6 Wiedergabe-Gerät ist default Stream-Parameter sind 48000 Hz, S16_LE, 1 Kanäle Verwende 16 Oktaven rosa Rauschen ALSA lib conf.c:3639:(config_file_open) cannot access file /etc/alsa/conf.d/50-oss.conf ALSA lib conf.c:3559:(snd_config_hooks_call) function snd_config_hook_load returned error: Datei oder Verzeichnis nicht gefunden ALSA lib conf.c:4013:(snd_config_update_r) hooks failed, removing configuration Calling speaker test from inside a chroot on /compat/linux fails with a different problem: bash-4.2# speaker-test speaker-test 1.1.6 Wiedergabe-Gerät ist default Stream-Parameter sind 48000 Hz, S16_LE, 1 Kanäle Verwende 16 Oktaven rosa Rauschen ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4555:(_snd_config_evaluate) function snd_func_card_driver returned error: Datei oder Verzeichnis nicht gefunden ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4555:(_snd_config_evaluate) function snd_func_concat returned error: Datei oder Verzeichnis nicht gefunden ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4555:(_snd_config_evaluate) function snd_func_refer returned error: Datei oder Verzeichnis nicht gefunden ALSA lib conf.c:5034:(snd_config_expand) Evaluate error: Datei oder Verzeichnis nicht gefunden ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM default Fehler beim Öffnen des Gerätes: -2, Datei oder Verzeichnis nicht gefunden Here's what I did to make speaker-test work: * remove /compat/linux/etc/alsa/conf.d/50-oss.conf * copy /usr/local/etc/asound.conf to /compat/linux/etc/etc/asound.conf * mount -t devfs none /compat/linux/dev/ Now speaker-test works, both calling it from the host and from inside a chroot in the linux directory. BUT the games still don't have audio :( And now there is nothing in the logs, it just looks like it will work, but it won't. Any further things I can try?
Are you sure these are not PulseAudio games?
(In reply to Alex S from comment #1) They give diagnostics about using alsa. Alsa in emu seems to have an OSS backend and a pulse-backend. If I install the pulse-backend the games pick up alsa-pulse, but fail for different reasons (alsa-pulse seems to be missing shared objects like lz4 and a few other things that are not available in the ports). In any case I am pretty sure alsa is the interface and I assumed applications have no preference regarding the backend, but I might be mistaken.
I have a similar problem. Read https://forums.freebsd.org/threads/no-sound-in-flashplayer-with-linux_base-c7.71632/
This is my knowledge I just knew recently. But, my comment is not directly related to this bug 240043. /usr/bin/ldd cannot be used directly to * .so on /compat/linux. We must use /compat/linux/usr/bin/ldd. But /compat/linux/usr/bin/ldd is a bash script that tries to use bash installed in /usr/bin. So it must be used as follows: /compat/linux/usr/bin/bash /compat/linux/usr/bin/ldd /compat/linux/usr/lib/libfoo.so.0 If you don't have enough libraries, pick up the rpm from the centos site and install it. For example, devel/linux-c7-dbus-libs requires libsystemd.so.0. Since tar uses libarchive with a filter for rpm, it can extract rpm files as follows: tar -x -f systemd-libs-219-62.el7.x86_64.rpm -C /compat/linux/ -- ./usr/lib64/libsystemd.so.0 ./usr/lib64/libsystemd.so.0.6.0 If you need lz4, do the following: tar -x -f lz4-1.7.5-2.el7.x86_64.rpm -C /compat/linux/ -- ./usr/lib64/liblz4.so.1 ./usr/lib64/liblz4.so.1.7.5 I wrote it here because I thought it would be insufficient to just read the handbook :) (The handbook is written to require a PC with centos installed.)
What applications/games does sound not work in (after making the adjustments to make speaker-test work), and where are these games sourced from, and how are they installed? Also, exact stable/12 information might be handy (uname -a)
(In reply to Tatsuki Makino from comment #4) Yes, I could also try to make the pulse package work and I already prepared a port for the systemd-libs, but it's all something I would rather not do if we can make also work without pulse/systemd/... (In reply to Kubilay Kocak from comment #5) % uname -a FreeBSD fbsdmain.soldiner.lan 12.0-STABLE FreeBSD 12.0-STABLE 14d1b03944e(stable/12) GENERIC amd64 (not very up-to-date) Games with audio issues: Pillars Of Eternity from gog.com Hollow Knight from gog.com Signal from Tölva from gog.com [all make use of the Unity3d engine] Games without audio issues: games/linux-unigine-heaven games/linux-unigine-valley OilRush from HumbleBundle installer [all make use of the Unigine Engine and logs say they are using OpenAL] Everspace from gog.com [uses the Unreal Engine] Thanks for your help with this! It should be noted that alsa did work with the -c6 ports (for the few things that still worked with -c6).
(In reply to Hannes Hauswedell from comment #6) > if we can make also work without pulse/systemd/... There is https://github.com/i-rinat/apulse. Afaik, it's not packaged for CentOS, so you need to build it from source, see https://gist.github.com/shkhln/6af746f44030443b58db4c8186f0a7bc. Also requires alsa-lib-devel and glib2-devel packages. > Pillars Of Eternity from gog.com I'll check this one later.
A commit references this bug: Author: tijl Date: Sun Aug 25 12:20:18 UTC 2019 New revision: 509790 URL: https://svnweb.freebsd.org/changeset/ports/509790 Log: Add devel/linux-c7-systemd-libs and let linux-c7-dbus-libs depend on it. PR: 240043 Reported by: Tatsuki Makino <tatsuki_makino@hotmail.com> Changes: head/Mk/Uses/linux.mk head/devel/Makefile head/devel/linux-c7-dbus-libs/Makefile head/devel/linux-c7-systemd-libs/ head/devel/linux-c7-systemd-libs/Makefile head/devel/linux-c7-systemd-libs/distinfo head/devel/linux-c7-systemd-libs/pkg-descr head/devel/linux-c7-systemd-libs/pkg-plist.amd64 head/devel/linux-c7-systemd-libs/pkg-plist.i386
A commit references this bug: Author: tijl Date: Sun Aug 25 16:55:07 UTC 2019 New revision: 509805 URL: https://svnweb.freebsd.org/changeset/ports/509805 Log: Add dependency on systemd-libs, needed by libpulsecommon-10.0.so. PR: 240043 Changes: head/audio/linux-c7-pulseaudio-libs/Makefile
A commit references this bug: Author: tijl Date: Sun Aug 25 20:02:10 UTC 2019 New revision: 509853 URL: https://svnweb.freebsd.org/changeset/ports/509853 Log: Fix Linux ALSA OSS plugin by removing a configuration file. The configuration from FreeBSD /usr/local/etc/asound.conf should be used. PR: 240043 Reported by: Hannes Hauswedell <h2+fbsdports@fsfe.org> Changes: head/audio/linux-c7-alsa-plugins-oss/Makefile head/audio/linux-c7-alsa-plugins-oss/pkg-plist.amd64 head/audio/linux-c7-alsa-plugins-oss/pkg-plist.i386
I've committed some of the fixes suggested here, so please update your ports tree to at least r509853 and update your installed linux packages to see if that fixes anything.
Ok, so linux-c7-alsa-plugins-oss loads fine with Pillars. Apparently FMOD (audio middleware) just doesn't like it. The relevant part of the system call trace: linux_open("/dev/dsp",0x1,00) = 20 (0x14) linux_ioctl(0x14,0x8004500f,0x1d388a8) = 0 (0x0) linux_ioctl(0x14,0x8004500b,0x7fffffffc848) = 0 (0x0) linux_ioctl(0x14,0xc0045006,0x7fffffffc848) = 0 (0x0) linux_ioctl(0x14,0xc0045006,0x7fffffffc848) = 0 (0x0) linux_ioctl(0x14,0xc0045006,0x7fffffffc848) = 0 (0x0) linux_ioctl(0x14,0xc0045006,0x7fffffffc848) = 0 (0x0) linux_ioctl(0x14,0xc0045006,0x7fffffffc848) = 0 (0x0) linux_ioctl(0x14,0xc0045006,0x7fffffffc848) = 0 (0x0) linux_brk(0x0) = 30994432 (0x1d8f000) linux_brk(0x1db3000) = 31141888 (0x1db3000) linux_ioctl(0x14,0xc004500a,0x7fffffffc664) = 0 (0x0) linux_fcntl(0x14,0x3,0x7fffffffc664) = 1 (0x1) linux_ioctl(0x14,0x5000,0x1d393f0) = 0 (0x0) linux_ioctl(0x14,0xc0045006,0x7fffffffcb04) = 0 (0x0) linux_ioctl(0x14,0xc0045005,0x7fffffffcb04) = 0 (0x0) linux_ioctl(0x14,0xc0045002,0x7fffffffcb04) = 0 (0x0) linux_sched_get_priority_min(0x1) = 0 (0x0) linux_sched_get_priority_max(0x1) = 31 (0x1f) linux_ioctl(0x14,0x40045010,0x7fffffffcd74) = 0 (0x0) linux_clock_gettime(0x0,0x1d389c8) = 0 (0x0) close(20) = 0 (0x0) write(5,"FMOD failed to initialize ... An"...,117) = 117 (0x75) (fd = 5 corresponds to the log file located at ~/.config/unity3d/Obsidian\ Entertainment/Pillars\ of\ Eternity/Player.log. There nothing else worth mentioning there, however.)
(In reply to Alex S from comment #12) Is there any difference if you replace one or both of linux-c7-alsa-lib and linux-c7-alsa-plugins-oss with their c6 version? pkg del -f linux-c7-alsa-lib cd /usr/ports/audio/linux-c6-alsa-lib make RUN_DEPENDS= install pkg del -f linux-c7-alsa-plugins-oss cd /usr/ports/audio/linux-c6-alsa-plugins-oss make RUN_DEPENDS= install
(In reply to Tijl Coosemans from comment #13) > Is there any difference if you replace > one or both of linux-c7-alsa-lib and linux-c7-alsa-plugins-oss > with their c6 version? No difference. Just in case anyone has this question, apulse also doesn't work with this game: https://gist.github.com/shkhln/75d16272e5ea6f49600bd3337e976614. I did not try the real PulseAudio. There are enough complaints about FMOD + PulseAudio combo on Linux anyway.
(In reply to Tijl Coosemans from comment #13) This trick worked for me. Now I have a sound in the www/flashplayer (firefox). So the problem is in the linux-c7-alsa-lib and/or linux-c7-alsa-plugins-oss? #pkg info -q | grep linux-c linux-c6-alsa-lib-1.1.0_3 linux-c6-alsa-plugins-oss-1.1.0_3 linux-c7-atk-2.28.1 linux-c7-cairo-1.15.12 linux-c7-curl-7.29.0_6 linux-c7-cyrus-sasl-lib-2.1.26_4 linux-c7-dri-18.0.5 linux-c7-elfutils-libelf-0.172 linux-c7-expat-2.1.0_2 linux-c7-fontconfig-2.13.0 linux-c7-freetype-2.8 linux-c7-fribidi-1.0.2 linux-c7-gdk-pixbuf2-2.36.12 linux-c7-graphite2-1.3.10 linux-c7-gtk2-2.24.31 linux-c7-harfbuzz-1.7.5 linux-c7-jasper-libs-1.900.1_5 linux-c7-jbigkit-libs-2.0_2 linux-c7-jpeg-1.2.90_3 linux-c7-libglvnd-1.0.1 linux-c7-libpciaccess-0.14 linux-c7-libpng-1.5.13_2 linux-c7-libssh2-1.4.3_5 linux-c7-libthai-0.1.14_1 linux-c7-libtiff-4.0.3_3 linux-c7-nspr-4.19.0 linux-c7-nss-3.36.0 linux-c7-openldap-2.4.44_1 linux-c7-pango-1.42.4 linux-c7-pixman-0.34.0 linux-c7-sqlite-3.7.17_1 linux-c7-wayland-1.15.0 linux-c7-xorg-libs-7.7_6
(In reply to Tijl Coosemans from comment #13) I tried to get back from linux-c6-alsa-plugins-oss to linux-c7-alsa-plugins-oss. And sound in the www/flashplayer (firefox) works fine. So the problem is in the linux-c7-alsa-libs. Sound in the www/flashplayer (firefox) works only with linux-c6-alsa-lib.
(In reply to Alex S from comment #14) > apulse also doesn't work with this game Looks like apulse doesn't work at all with linux-c*-alsa-plugins-oss. It's actually possible to build the OSS output plugin for Linuxulator with /audio/alsa-plugins/files/alsa-plugins.patch (with obvious modifications to __FreeBSD__ ifdefs) to deal with apulse, however that's probably not entirely correct solution to this problem. Unfortunately the patched plugin still doesn't help FMOD, although working apulse would be useful for another popular application ;)
(In reply to Alex S from comment #17) Just a guess, but can you try FMOD with these symlinks: ln -s libasound.so.2.0.0 /compat/linux/usr/lib/libasound.so ln -s libasound.so.2.0.0 /compat/linux/usr/lib64/libasound.so
(In reply to Tijl Coosemans from comment #18) What is that supposed to do? As far as I am aware, the correct libraries are already loaded.
(In reply to Alex S from comment #19) Well, I read somewhere about a problem where Steam bundles libasound.so.2 but not libasound.so and that caused the system libasound to be loaded instead of the Steam one. In our case that could be the FreeBSD /usr/local/lib/libasound.so.
(In reply to Tijl Coosemans from comment #20) > In our case that could be the FreeBSD /usr/local/lib/libasound.so. No, nothing like that. This must be FMOD quirk.
(In reply to Serge Volkov from comment #15) > This trick worked for me. Now I have a sound in the www/flashplayer (firefox). So the problem is in the linux-c7-alsa-lib and/or linux-c7-alsa-plugins-oss? This does not work for me. I get the same FMOD problem report here: FMOD failed to initialize ... An error occured that wasn't supposed to. Contact support. I have also tried going through the pulse port. Note that it additionally requires gsm-1.0.13-11.el7.x86_64.rpm which is currently not packaged. It also requires not using asound.conf from the host system, because that enforces OSS. It will then try to connect to FreeBSD's pulse daemon, but fail (which is probably expected): setsockopt(SOL_SOCKET, SO_PASSCRED): Protocol not available setsockopt(SOL_SOCKET, SO_PASSCRED): Protocol not available setsockopt(SOL_SOCKET, SO_PASSCRED): Protocol not available Assertion 'pthread_mutex_unlock(&m->mutex) == 0' failed at pulsecore/mutex-posix.c:108, function pa_mutex_unlock(). Aborting. Stacktrace: It then also crashes. I really think pulse won't save us here and we need to get the alsa->oss thing working. I don't know anything about FMOD... Is there anything else I can do to help get this sorted out? It feels like we are so close with graphics actually working for most things and now sound of all things is breaking it :'(
For what it's worth, I did some more tracing (with shoddily written C wrapper) and none of ALSA functions that FMOD calls return any errors. FMOD also apparently parses ALSA config files itself, but I'm not sure what to make of it. Might be a culprit, probably not. (In reply to Hannes Hauswedell from comment #22) > now sound of all things is breaking it I'm not sure how this is surprising. Sound is precisely what you should never expect to work with Linux applications. One of the reasons I always recommend trying Wine first.
(In reply to Alex S from comment #23) Does fmod or alsalib try to access anything under /dev, /proc, or /sys?
I found a better target for experiments. Older (< 3) GZDoom versions used libfmodex.so, which is quite convenient for us since it is dynamically linked and, unlike www.fmod.com, there is no registration-to-download bullshit. You can grab a copy at https://zdoom.org/files/gzdoom/bin/gzdoom_2.4.0_amd64.deb. For running it use run.sh script from http://repo.steampowered.com/steamrt/steamrt-scout/snapshots/0.20190711.3/steam-runtime.tar.xz [SHA256 (steam-runtime.tar.xz) = ae5b94638a339911054e8b3ac0dea8da615be93bc6ba7c59c82e495e62ac79f8]. The game eventually crashes anyway, but not before it has tried to initialize FMOD. (In reply to Tijl Coosemans from comment #24) > Does fmod or alsalib try to access anything under /dev, /dev/snd/controlC* for libasound.so, /dev/dsp for OSS plugin. > /proc, or /sys? No.
Ok, so apparently FMOD calls pthread_attr_setschedparam, which fails with EIVAL and then FMOD bails out of initialization. This happens regardless of the selected output type. Hannes, can you please try the workaround at https://gist.github.com/shkhln/3f4756770182d406b0a9968509f6711e?
By the way, in case anyone wonders, FMOD on Linux probes backends (PulseAudio, ALSA, OSS) in this order: 1. Run "pulseaudio --check > /dev/null 2>&1", then look for "libpulse-simple.so.0"; 2. Look for libasound.so.2; 3. Open /dev/dsp.
(In reply to Alex S from comment #26) According to the Linux manpage pthread_attr_setschedparam returns EINVAL when the priority it's trying to set is invalid. This must be caused by the linux_sched_get_priority_min(0x1) and linux_sched_get_priority_max(0x1) syscalls in comment 12 which seem to be returning the FreeBSD priority range instead of what Linux would return. Maybe trasz or dchagin can comment on this.
(In reply to Alex S from comment #27) In bug 240326 sound got working again after removing linux-c7-alsa-lib. Maybe that also works for FMOD? We'd still need to make it work with alsa-lib installed, but that would be a nice workaround at least.
*** Bug 240326 has been marked as a duplicate of this bug. ***
(In reply to Tijl Coosemans from comment #29) > In bug 240326 sound got working again after removing linux-c7-alsa-lib. This does not work for www/linux-flashplayer. If I just remove the linux-c7-alsa-lib, then there is no sound. The sound in it works only if I replace the linux-c7-alsa-lib with linux-c6-alsa-lib. I'm on 12.0-RELEASE-p10 (amd64) with latest ports.
(In reply to Alex S from comment #26) Thanks for trying to get to the bottom of this, everyone! I don't have access to my main computer today, but will try the workaround tomorrow!
(In reply to Tijl Coosemans from comment #29) > In bug 240326 sound got working again after removing linux-c7-alsa-lib. Maybe that also works for FMOD? Yeah, sorry. There are just too many different combinations there, I always forget to test something. Sound definitely doesn't work for me with the current version of linux-c7-alsa-plugins-oss. I do remember being quite frustrated by stuttering in Grim Fandango Remastered half a year ago (?), so it used to work. Downgrading alsa-lib and plugins-oss helps, but so does rebuilding the OSS plugin from source with alsa-plugins.patch (see comment #17). The latter also fixes stuttering in Grim Fandango.
By the way, how does the FreeBSD Linux emulator do dlopen? In libasound.so.2.0.0, ALSA_PLUGIN_DIR defined in the preprocessor is hard-coded. libasound_module_*.so is called from path of ALSA_PLUGIN_DIR. Reference sources are alsa-lib-1.1.2/src/control/control.c, alsa-lib-1.1.2/src/pcm/pcm.c and alsa-lib-1.1.2/src/pcm/pcm_rate.c. libasound.so.2.0.0 installed by audio/alsa-lib has /usr/local/lib/alsa-lib. libasound.so.2.0.0 installed by audio/linux-c7-alsa-lib has /usr/lib64/alsa-lib. The command below may have some meaning. ln -s /compat/linux/usr/lib64/alsa-lib /usr/lib64/alsa-lib
(In reply to Tijl Coosemans from comment #28) > This must be caused by the linux_sched_get_priority_min(0x1) > and linux_sched_get_priority_max(0x1) syscalls in comment 12 > which seem to be returning the FreeBSD priority range > instead of what Linux would return. Indeed, FMOD requests priority 90 or 94 (there are multiple calls). (In reply to Tatsuki Makino from comment #34) > By the way, how does the FreeBSD Linux emulator do dlopen? Linuxulator looks for /compat/linux/<whatever> path, if there is nothing here, it looks for <whatever> path. If you need to check what is getting loaded into a process, use "procstat -v <pid>".
(In reply to Tijl Coosemans from comment #11) Updating the ports with removed configs works, but I still need the symlink /usr/local/etc/asound.conf -> /compat/linux/etc/asound.conf Note that linux-c7-pulseaudio-libs-10.0_2 may not be installed at all on the system or OpenAL will pick up pulseaudio which is broken. Maybe we should remove the pulseaudio ports altogether if they don't work anyway and just mess-up the auto-detection of backends? I would also recommend forcing OpenAL to always use its OSS backend and not even go through alsa (why add more layers of complexity? OSS interface always works on FreeBSD or not?). This can easily be done via a one-liner in /compat/linux/etc/openal/alsoft.conf. (In reply to Alex S from comment #26) In regard to the preload for PillarsOfEternity, it doesn't fix the sound. It also makes the game hang on exit. I get nothing in regard to FMOD in the log anymore though. Only thing related to audio seems to be "AudioManager: Using ALSA: default".
(In reply to Hannes Hauswedell from comment #36) > Only thing related to audio seems to be "AudioManager: Using ALSA: default". I thought we already established that alsa is a bit broken right now. If you force the game to use OSS, it should have sound: % mkdir noalsa % ln -s /dev/null noalsa/libasound.so.2 % LD_LIBRARY_PATH=noalsa (Obviously should be combined with FMOD workaround.)
(In reply to Alex S from comment #37) Wow, indeed, that fixes sound for me on PillarsOfEternity and HollowKnight! And there is no hang. I have removed all of the alsa ports now. Curiously that is not enough to not have the game pick up Alsa. I still need to preload the empty shared object. Also OpenAL also needs to be forced to OSS (for linux-unigine-*), it doesn't automatically take OSS although Alsa is no longer available. I didn't know that Unity3d/FMOD had fallback to OSS, but if that's the case I think we should just try to make everything use OSS and not care too much about Alsa or Pulse or a combination thereof. Seems unnecessary complexity (never understood the many abstraction layers on Linux). Thanks for working on this!
(In reply to Hannes Hauswedell from comment #38) > I didn't know that Unity3d/FMOD had fallback to OSS Searching for "/dev/dsp" string in the executable is enough to make an educated guess. Finding the least obnoxious way to enable OSS is another matter, however. > we should just try to make everything use OSS > and not care too much about Alsa or Pulse or > a combination thereof. Seems unnecessary complexity > (never understood the many abstraction layers on Linux). Unfortunately we occasionally need ALSA, because there is no OSS fallback or it is broken in the application itself. Same goes for PulseAudio and whatever replacement API freedesktop people devise in future once they decide the current one is too reliable.
A commit references this bug: Author: tijl Date: Sun Sep 8 20:47:58 UTC 2019 New revision: 511597 URL: https://svnweb.freebsd.org/changeset/ports/511597 Log: Rewrite the port so we build our own Linux package from the upstream .src.rpm with patches derived from the audio/alsa-plugins port. This should improve sound output from Linux programs. CFLAGS contains -nostdinc -isystem ... because gcc searches /usr/local/include before /usr/include otherwise and picks up headers from /usr/local/include/alsa instead of /compat/linux/usr/include/alsa. PR: 240043 Changes: head/audio/linux-c7-alsa-plugins-oss/Makefile head/audio/linux-c7-alsa-plugins-oss/distinfo head/audio/linux-c7-alsa-plugins-oss/files/ head/audio/linux-c7-alsa-plugins-oss/files/patch-oss-ctl_oss.c head/audio/linux-c7-alsa-plugins-oss/files/patch-oss-pcm_oss.c head/audio/linux-c7-alsa-plugins-oss/pkg-plist.amd64 head/audio/linux-c7-alsa-plugins-oss/pkg-plist.i386
Please try the latest linux-c7-alsa-plugins-oss. The port now rebuilds the plugin with patches from audio/alsa-plugins. Also try openal with alsa backend to make sure that it continues to work. Does surround sound work by the way? With both openal->alsa->oss and openal->oss?
(In reply to commit-hook from comment #40) > https://svnweb.freebsd.org/changeset/ports/511597 After this commit audio/linux-c7-alsa-plugins-oss fails to build on 12.0 i386: make[4]: Entering directory `/usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/alsa-plugins-1.1.6/oss' make[4]: Nothing to be done for `install-exec-am'. /bin/mkdir -p '/usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib' /bin/sh ../libtool --mode=install /usr/local/bin/ginstall -c -s libasound_module_ctl_oss.la '/usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib' libtool: install: /usr/local/bin/ginstall -c .libs/libasound_module_ctl_oss.so /usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib/libasound_module_ctl_oss.so ginstall: cannot create regular file '/usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib/libasound_module_ctl_oss.so': No such file or directory make[4]: *** [install-asound_module_ctl_ossLTLIBRARIES] Error 1 make[4]: Leaving directory `/usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/alsa-plugins-1.1.6/oss' make[3]: *** [install-am] Error 2 make[3]: Leaving directory `/usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/alsa-plugins-1.1.6/oss' make[2]: *** [install-recursive] Error 1 make[2]: Leaving directory `/usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/alsa-plugins-1.1.6' make[1]: *** [install-strip] Error 2 make[1]: Leaving directory `/usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/alsa-plugins-1.1.6' *** Error code 2 Workaround (after build failed): mkdir -p /usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib/ mkdir -p /usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/share/alsa/alsa.conf.d cp -a /usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/alsa-plugins-1.1.6/oss/.libs/libasound_module_ctl_oss.so /usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib/ portmaster -C audio/linux-c7-alsa-plugins-oss
(In reply to Tijl Coosemans from comment #41) This is weird, apulse and Grim Fandango fail for me, otherwise this seems to work. > The port now rebuilds the plugin with patches from audio/alsa-plugins. Out of curiosity, any particular reason for not using --sysroot=/compat/linux flag? In my case (git tree somewhere in $HOME, non-root user, no additional tools) building this requires: --- a/audio/linux-c7-alsa-plugins-oss/Makefile +++ b/audio/linux-c7-alsa-plugins-oss/Makefile @@ -92,11 +92,11 @@ do-build: do-install: .if !empty(COMPAT32_CFLAGS_${ARCH}) @(cd ${WRKSRC32} && ${LINUXBASE}/usr/bin/make install-strip \ - DESTDIR=${STAGEDIR}${LINUXBASE}) + DESTDIR=/compat/../${STAGEDIR}${LINUXBASE}) ${RM} -r ${STAGEDIR}${LINUXBASE}/usr/lib/alsa-lib/*.la .endif @(cd ${WRKSRC} && ${LINUXBASE}/usr/bin/make install-strip \ - DESTDIR=${STAGEDIR}${LINUXBASE}) + DESTDIR=/compat/../${STAGEDIR}${LINUXBASE}) ${RM} -r ${STAGEDIR}${LINUXBASE}${LIBDIR_${ARCH}}/alsa-lib/*.la ${RM} -r ${STAGEDIR}${LINUXBASE}/etc ${STAGEDIR}${LINUXBASE}/usr/share to work around a nasty Linuxulator habit of returning /compat/linux/<whatever> directory entries instead of, say, merging them with <whatever> directory entries, otherwise this fails with "/bin/mkdir: cannot create directory '/usr/home': Permission denied" message, as well as specifying ARCH=amd64, since I don't have this defined anywhere.
(In reply to Alex S from comment #43) > This is weird, apulse and Grim Fandango fail for me, > otherwise this seems to work. Looks like this is caused by -DFREEBSD_OSS_BUFSZ_P2. I didn't actually define FREEBSD_OSS_BUFSZ_P2 or FREEBSD_OSS_USE_IO_PTR when I was testing this myself, thus the difference in behavior.
A commit references this bug: Author: tijl Date: Mon Sep 9 20:36:11 UTC 2019 New revision: 511702 URL: https://svnweb.freebsd.org/changeset/ports/511702 Log: - Make the port safe to build as root. [1] Given an absolute /path Linux programs first try to access /compat/linux/path before trying /path. That means mkdir -p ${STAGEDIR} will always create /compat/linux${STAGEDIR} when run as root and echo > /dev/null will create /compat/linux/dev/null as a regular file. Fix this by running configure with FreeBSD /bin/sh and build/install using FreeBSD gmake. PATH is set to /compat/linux/usr/bin and MKDIR_P to /bin/mkdir -p so all commands except mkdir are still Linux programs. - Add USES=libtool:build because libtoolize is needed. [2] - Add USES=pkgconfig. - Remove -DFREEBSD_OSS_BUFSZ_P2 because it breaks some games. [3] - Replace -nostdinc -isystem ... with --sysroot=${LINUXBASE}. [3] - Include bsd.port.options.mk to get ARCH. [3] PR: 240043 Reported by: VVD <vvd@unislabs.com> [1] Reported by: Giacomo Olgeni <olgeni@olgeni.com> [2] Reported by: Alex S <iwtcex@gmail.com> [3] Changes: head/audio/linux-c7-alsa-plugins-oss/Makefile
(In reply to commit-hook from comment #45) On 12.0 amd64 build fine, but on 12.0 i386 error: ===> Installing for linux-c7-alsa-plugins-oss-1.1.6_3 ===> Checking if linux-c7-alsa-plugins-oss is already installed ===> Registering installation for linux-c7-alsa-plugins-oss-1.1.6_3 as automatic pkg-static: Unable to access file /usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib/libasound_module_ctl_oss.so:No such file or directory pkg-static: Unable to access file /usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib/libasound_module_pcm_oss.so:No such file or directory *** Error code 74 Workaround: cp -a /usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/alsa-plugins-1.1.6/oss/.libs/*.so /usr/obj/usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib/ portmaster -C audio/linux-c7-alsa-plugins-oss
(In reply to commit-hook from comment #45) Almost there: diff --git a/audio/linux-c7-alsa-plugins-oss/Makefile b/audio/linux-c7-alsa-plugins-oss/Makefile index e1afcccdf1eb..6970d0700711 100644 --- a/audio/linux-c7-alsa-plugins-oss/Makefile +++ b/audio/linux-c7-alsa-plugins-oss/Makefile @@ -19,6 +19,8 @@ COMMENT= OSS plugin for ALSA (Linux CentOS ${LINUX_DIST_VER}) LICENSE= LGPL21+ +BUILD_DEPENDS= gawk:lang/gawk + USES= autoreconf:build gmake libtool:build linux:c7 pkgconfig USE_LDCONFIG= yes USE_LINUX= alsalib:build,run alsa-lib-devel:build devtools:build @@ -72,7 +74,7 @@ do-patch: do-configure: .if !empty(COMPAT32_CFLAGS_${ARCH}) @(cd ${WRKSRC32} && ${AUTORECONF} -f -i && ${SETENV} \ - PATH=${LINUXBASE}/usr/bin ./configure CPPFLAGS="${CPPFLAGS}" \ + PATH=${LINUXBASE}/usr/bin ./configure AWK="${LOCALBASE}/bin/gawk" CPPFLAGS="${CPPFLAGS}" \ CFLAGS="${CFLAGS} ${COMPAT32_CFLAGS_${ARCH}}" \ LDFLAGS="${LDFLAGS}" MAKE="${LOCALBASE}/bin/gmake" \ MKDIR_P="${MKDIR}" PKG_CONFIG="${LOCALBASE}/bin/pkgconf" \ @@ -80,7 +82,7 @@ do-configure: ${CONFIG_ARGS}) .endif @(cd ${WRKSRC} && ${AUTORECONF} -f -i && ${SETENV} \ - PATH=${LINUXBASE}/usr/bin ./configure CPPFLAGS="${CPPFLAGS}" \ + PATH=${LINUXBASE}/usr/bin ./configure AWK="${LOCALBASE}/bin/gawk" CPPFLAGS="${CPPFLAGS}" \ CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \ MAKE="${LOCALBASE}/bin/gmake" MKDIR_P="${MKDIR}" \ PKG_CONFIG="${LOCALBASE}/bin/pkgconf" \
Make sure you have the latest linux_base-c7. It should have gawk.
(In reply to VVD from comment #46) Can you check if you have /compat/linux/usr/obj/... and then delete that? You may also need to delete /compat/linux/dev/null.
(In reply to Tijl Coosemans from comment #48) > Make sure you have the latest linux_base-c7. It should have gawk. Ah, that explains it.
(In reply to Tijl Coosemans from comment #49) Thanks! This fixed build.
Still unable to install. ===> Registering installation for linux-c7-alsa-plugins-oss-1.1.6_3 pkg-static: Unable to access file /usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib/libasound_module_ctl_oss.so:No such file or directory pkg-static: Unable to access file /usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib/alsa-lib/libasound_module_pcm_oss.so:No such file or directory pkg-static: Unable to access file /usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib64/alsa-lib/libasound_module_ctl_oss.so:No such file or directory pkg-static: Unable to access file /usr/ports/audio/linux-c7-alsa-plugins-oss/work/stage/compat/linux/usr/lib64/alsa-lib/libasound_module_pcm_oss.so:No such file or directory *** Error code 74 Deleted /compat/linux/dev/null. Did not have /compat/linux/usr/obj. Updated emulators/linux_base-c7 to the latest as of today at 17:00 UTC. Did I miss something?
(In reply to rkoberman from comment #52) It's the path of those files prefixed with /compat/linux, so in your case it would be /compat/linux/usr/ports/...
That did the trick. And makes more sense to me, too.
Created attachment 207391 [details] FMOD kernel patch This kernel patch should get FMOD past the pthread_attr_setschedparam call. It changes sched_get_priority_(min|max) to return the Linux priority range instead of the FreeBSD one. Then it also changes sched_getparam, sched_setparam, and sched_setscheduler to translate between the Linux and FreeBSD range.
I noticed the source comment at https://github.com/freebsd/freebsd/blob/1d6e4247415d264485ee94b59fdbc12e0c566fd0/sys/sys/rtprio.h#L61 refers to 0 as the highest priority, while Linux seems to be the other way around. Am I reading this right?
(In reply to Alex S from comment #56) In struct sched_param larger values mean higher priority. Inside the kernel, larger values mean lower priority. Linux and FreeBSD are the same here. RTP_PRIO_(MAX|MIN) define the range in the FreeBSD kernel. I wanted to use P1B_PRIO_(MIN|MAX) as in sys/kern/ksched.c but they aren't defined in any header.
Created attachment 207411 [details] FMOD kernel patch (2) This patch fixes the values returned by sched_get_priority_(min|max).
(In reply to Tijl Coosemans from comment #57) > RTP_PRIO_(MAX|MIN) define the range in the FreeBSD kernel. > I wanted to use P1B_PRIO_(MIN|MAX) as in sys/kern/ksched.c > but they aren't defined in any header. Thanks for the explanation! I see now the actual conversion is done by p4prio_to_rtpprio/p4prio_to_tsprio macros, so that's very helpful. (In reply to Tijl Coosemans from comment #58) Works fine for me on FreeBSD 12.0.
Created attachment 207416 [details] FMOD kernel patch (3) Fix a locking issue in the error case in sched_setparam.
Are we waiting for more feedback?
What are the latest things people should test? I have updated to 12.1-BETA1 and I still need to preload the library so that PoE has sound. That is, with alsa libs installed, but not plugins.
I had second thoughts about the patch. There are fewer thread priority levels on FreeBSD than on Linux so the patch maps one FreeBSD priority level to multiple Linux priority levels. With the patch it's possible for a Linux thread to have a higher priority than another thread while the FreeBSD kernel treats them as if they had the same level. That's a problem for SCHED_FIFO threads because they just keep running until they are preempted by higher priority threads. The current behaviour where FreeBSD announces fewer priority levels via sched_get_priority_(min|max) is correct. A POSIX compliant program is supposed to use priority levels from this range. FMOD blindly uses priority levels that happen to work on current versions of Linux. Another solution will have to be found. Either the preload trick or maybe libfmod.so could be edited using something like "sed -i.bak 's,libasound\.so,/nonexistent,g' /path/to/libfmod.so"?
(In reply to Tijl Coosemans from comment #63) > Either the preload trick The main problem with that is discoverability. Even a nice wrapper script would still need to be advertised to end users. > or maybe libfmod.so could be edited using something like > "sed -i.bak 's,libasound\.so,/nonexistent,g' /path/to/libfmod.so"? Oh, I'm not above directly patching FMOD to use a lower priorities, in fact that should be very straightforward — we only need to print a backtrace from the preloaded pthread_attr_setschedparam wrapper to find the calling code and then look around a bit for a constant value. However, since FMOD is statically linked into these Unity Engine binaries, that is something that needs to be done per each game and per each update.
Could we instead patch libasound or replace it with an intermediary to detect whether it is being invoked from FMOD and behave accordingly? Everything that involves manually patching game binaries seems sub-optimal.
By the way, as far as discoverability goes, did anybody actually notice https://github.com/shkhln/linuxulator-steam-utils (I refuse to advertise that on Reddit), or, more importantly, read the related PRs such as bug #240989, bug #240990 and bug #240991? Those weren't assigned to emulation@, so I'm getting a bit nervous. (In reply to Hannes Hauswedell from comment #65) > Could we instead patch libasound > or replace it with an intermediary to detect > whether it is being invoked from FMOD and behave accordingly? How are we supposed to detect FMOD and what does this have to do with libasound?.
(In reply to Tijl Coosemans from comment #63) > The current behaviour where FreeBSD announces fewer priority levels via sched_get_priority_(min|max) is correct. > A POSIX compliant program is supposed to use priority levels from this range. Would it be acceptable to silently discard any values outside of the FreeBSD range but still within the valid Linux range? Maybe even with a corresponding sysctl variable to enable/disable that behavior. That's the most sane solution I can think of.
Any news on this issue? After I finished Pillars Of Eternity 1 with the FMOD-preload, I went ahead and got Pillars Of Eternity 2. Although it seems to be very similar on a technical level (also Unity engine), it does not need the FMOD-preload thing to emit correct sound. However, the game crashes about 30seconds into the first combat, dumping either SDLAudioP2.core or SDLHotplugALSA.core -- each around 3.3GB big. Using the FMOD-preload thing doesn't change this behaviour. Note that the game says the following upon starting: Preloaded 'libdiscord-rpc.so' Preloaded 'libAkFlanger.so' Preloaded 'libAkHarmonizer.so' Preloaded 'libAkPitchShifter.so' Preloaded 'libAkSoundEngine.so' Preloaded 'libAkStereoDelay.so' Preloaded 'libAkTremolo.so' Preloaded 'libMcDSP.so' Preloaded 'libsteam_api.so' Unable to preload the following plugins: ScreenSelector.so libSDL2-2.0.so It seems to load these dynamically and says that it doesn't load SDL2, although the library is available and the crash dumps seem to indicate that it is using SDL, as well.
Calling strings on the binary does show that FMOD is still used and suggests that there is an OSS backend still available: FMOD OSS Output /home/builduser/buildslave/fmod/build/linux/src/fmod_output_oss.cpp Maybe we need to disable more stuff?
> After I finished Pillars Of Eternity 1, Incredible (since it's so boring). > I went ahead and got Pillars Of Eternity 2. ... > However, the game crashes about 30seconds into the first combat Try LD_PRELOAD=libSegFault.so, assuming the game does not bundle some stupid crash reporting tool (it likely does), that should get you a proper backtrace.
> Incredible (since it's so boring). Wasn't that bad ;) > Try LD_PRELOAD=libSegFault.so, assuming the game does not bundle some stupid crash reporting tool (it likely does), that should get you a proper backtrace Doesn't produce more output. Looking at the player log, I did notice some things: =============== Only libSegFault preloaded ==================== ALSA lib pcm.c:8424:(snd_pcm_recover) underrun occurred (multiple times) Thread (nil) may have been prematurely finalized ... FMOD failed to initialize the output device, attempting to initialize the null output. (Filename: Line: 1121) FMOD failed to initialize ... An error occured that wasn't supposed to. Contact support. .... Receiving unhandled NULL exception Receiving unhandled NULL exception ============== FMOD workaround from PoE1 ========================= Thread (nil) may have been prematurely finalized ... AudioManager: Using OSS: /dev/dsp ... Receiving unhandled NULL exception Receiving unhandled NULL exception =============== So the second one does look better, but it crashes all the same.
Doesn't look like a sound issue. Might be a problem with the game even. Here is a dumb Linuxulator debugging trick: make a copy of the game executable and overwrite (with a hex editor) the two "GNU" strings placed roughly at the start of the file. After that you should be able to open the core dump with lldb by pointing it at the core dump and the modified executable.
Are we still waiting for something?
(In reply to Alex S from comment #73) I'll add a sysctl to my patch this weekend.
Comment on attachment 207416 [details] FMOD kernel patch (3) I've uploaded a new patch for review at https://reviews.freebsd.org/D23790.
A commit references this bug: Author: tijl Date: Sun Mar 1 13:12:04 UTC 2020 New revision: 358483 URL: https://svnweb.freebsd.org/changeset/base/358483 Log: linuxulator: Map scheduler priorities to Linux priorities. On Linux the valid range of priorities for the SCHED_FIFO and SCHED_RR scheduling policies is [1,99]. For SCHED_OTHER the single valid priority is 0. On FreeBSD it is [0,31] for all policies. Programs are supposed to query the valid range using sched_get_priority_(min|max), but of course some programs assume the Linux values are valid. This commit adds a tunable compat.linux.map_sched_prio. When enabled sched_get_priority_(min|max) return the Linux values and sched_setscheduler and sched_(get|set)param translate between FreeBSD and Linux values. Because there are more Linux levels than FreeBSD levels, multiple Linux levels map to a single FreeBSD level, which means pre-emption might not happen as it does on Linux, so the tunable allows to disable this behaviour. It is enabled by default because I think it is unlikely that anyone runs real-time software under Linux emulation on FreeBSD that critically relies on correct pre-emption. This fixes FMOD, a commercial sound library used by several games. PR: 240043 Tested by: Alex S <iwtcex@gmail.com> Reviewed by: dchagin MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D23790 Changes: head/sys/compat/linux/linux_misc.c head/sys/compat/linux/linux_misc.h
Could this be backported to 12-STABLE? Then I will give it a try! Thanks!
Created attachment 215109 [details] fmod.stable.12.patch Here's a patch for stable/12.
A commit references this bug: Author: trasz Date: Mon Aug 24 12:43:55 UTC 2020 New revision: 364664 URL: https://svnweb.freebsd.org/changeset/base/364664 Log: MFC r358483 by tijl: linuxulator: Map scheduler priorities to Linux priorities. On Linux the valid range of priorities for the SCHED_FIFO and SCHED_RR scheduling policies is [1,99]. For SCHED_OTHER the single valid priority is 0. On FreeBSD it is [0,31] for all policies. Programs are supposed to query the valid range using sched_get_priority_(min|max), but of course some programs assume the Linux values are valid. This commit adds a tunable compat.linux.map_sched_prio. When enabled sched_get_priority_(min|max) return the Linux values and sched_setscheduler and sched_(get|set)param translate between FreeBSD and Linux values. Because there are more Linux levels than FreeBSD levels, multiple Linux levels map to a single FreeBSD level, which means pre-emption might not happen as it does on Linux, so the tunable allows to disable this behaviour. It is enabled by default because I think it is unlikely that anyone runs real-time software under Linux emulation on FreeBSD that critically relies on correct pre-emption. This fixes FMOD, a commercial sound library used by several games. PR: 240043 Tested by: Alex S <iwtcex@gmail.com> Changes: _U stable/12/ stable/12/sys/compat/linux/linux_misc.c stable/12/sys/compat/linux/linux_misc.h
I think this can be closed now.