BleuBleu/FamiStudio

[Bug]: Audio issues with Pipewire on Linux

Closed this issue · 1 comments

Main issue:

I have tried investigating why FamiStudio kept bugging my whole sound server, not letting other programs play any sound when it's open. I ended up writing a small doc explaining everything i've tried doing. And also read some other issues with the same theme, like #79 and #169. Latter helped me solve the issue, but i still want to share what i've found out while testing. My distribution is Void Linux

The doc itself

What i have discovered with all this debugging:

From fuser(1):

fuser - identify processes using files or sockets
...
    ACCESS shows how the process accesses the file.
    ...
    F      open file for writing.
    ...
    m      mmap'ed file or shared library.
    .      placeholder.
...

And from some Linux-Sound Subsystem doc:

/dev/snd/pcmC0D0p is a playback device, p at the end of the device
name stands for playback
...
/dev/snd/controlC0 is a control node that applications use for
controlling volume gain and such
...

Running fuser --verbose /dev/snd/* to understand what's happening

W/ nothing:

Pipewire is running without any programs that use audio:

                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  klink      5920 F.... wireplumber
/dev/snd/seq:        klink      5899 F.... pipewire

All sound related activities work as intended.

W/ target:

FamiStudio is running with target="libopenal32.so" in FamiStudio.exe.config

                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  klink      5920 F.... wireplumber
/dev/snd/pcmC0D0p:   klink      7028 F...m FamiStudio
/dev/snd/seq:        klink      5899 F.... pipewire
                     klink      7028 F.... FamiStudio

FamiStudio interferes with all other programs that use sound while being able to produce it itself. Trying to play videos, audio files
or anything similar in other programs results in them hanging. I presume it is because /dev/snd/pcmC0D0p, the audio playback device, is mmaped by FamiStudio. Is it supposed to do that?

W/O target:

FamiStudio is running without target="libopenal32.so". Only works after installing libopenal-devel package:

                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  klink      5899 F.... pipewire
                     klink      5920 F.... wireplumber
/dev/snd/pcmC0D0p:   klink      5899 F...m pipewire
/dev/snd/seq:        klink      5899 F.... pipewire
                     klink      7082 F.... FamiStudio

FamiStudio works as intended, not interfering with any other programs that use sound and plays it itself.

Extra note:

Without the alsa-pipewire package, FamiStudio hangs trying to play any sound. All other programs work fine. By reading issue #79 i realized that it is because libopenal.so doesn't have any support for Pulseaudio or Pipewire drivers, only ALSA it seems

Another extra note:

Sometimes FamiStudio randomly sends a Segmentation Fault when closed:

mono FamiStudio.exe
Default OpenAL audio device is 'OpenAL Soft'
Segmentation fault

digging in the system logs i've found this error:

Apr 22 17:24:49 [kernel] [ 6143.361615] FamiStudio[9465]: segfault at 7fabb5f80fe0 ip 00007fabb759eca2 sp 00007fababffea10 error 4 in libpipewire-0.3.so.0.368.0[7fabb7556000+5f000] likely on CPU 1 (core 1, socket 0)
Apr 22 17:24:49 [kernel] [ 6143.361654] Code: 0f 1f 84 00 00 00 00 00 53 83 bf 30 01 00 00 01 48 89 fb 74 73 f6 83 00 13 00 00 40 74 22 48 8b 83 f0 12 00 00 48 85 c0 74 5b <48> 8b 40 40 48 85 c0 74 52 48 8b bb f8 12 00 00 5b ff e0 0f 1f 00

Nevermind i fixed it

After tinkering a lot more i found out what was causing all this nonsense. One small thing was not configured properly, it being that PipeWire was starting its own session manager, WirePlumber, itself. From pipewire.conf:

# You can optionally start the session manager here,
# but it is better to start it as a systemd service.
# Run the session manager with -h for options.
#
{ path = "/usr/bin/wireplumber" args = "" }

So, i commented the last line and made my desktop environment start PipeWire and WirePlumber instead. That seems to have solved the issue