TerryCavanagh / VVVVVV

The source code to VVVVVV! http://thelettervsixtim.es/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Audio dropout issue in 2.4.x (and possibly earlier) on Linux when using Pipewire

KSSBrawl opened this issue · comments

commented

The issue

When 2.4 released, I immediately ran into an issue on my Linux system where the audio would either drop out at some random point and then never come back or be absent from the moment the game started. Additionally, not only does this issue persist in 2.4.1 but also once this happens the game's running process sometimes fails to terminate when closing the game.

The cause (?)

I had just replaced PulseAudio on my system with PipeWire which led me to suspect that the cause may have lied with PipeWire, and a look at the SDL2 build system turns up this part of $(SDL2_SOURCE_DIR)/cmake/sdlchecks.cmake:

macro(CheckPipewire)
    if(SDL_PIPEWIRE)
        pkg_check_modules(PKG_PIPEWIRE libpipewire-0.3>=0.3.20)
        if(PKG_PIPEWIRE_FOUND)
            set(HAVE_PIPEWIRE TRUE)
            file(GLOB PIPEWIRE_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pipewire/*.c)
            list(APPEND SOURCE_FILES ${PIPEWIRE_SOURCES})
            set(SDL_AUDIO_DRIVER_PIPEWIRE 1)
            list(APPEND EXTRA_CFLAGS ${PKG_PIPEWIRE_CFLAGS})
            if(SDL_PIPEWIRE_SHARED AND NOT HAVE_SDL_LOADSO)
                message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading")
            endif()
            FindLibraryAndSONAME("pipewire-0.3" LIBDIRS ${PKG_PIPEWIRE_LIBRARY_DIRS})
            if(SDL_PIPEWIRE_SHARED AND PIPEWIRE_0.3_LIB AND HAVE_SDL_LOADSO)
                set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"")
                set(HAVE_PIPEWIRE_SHARED TRUE)
            else()
                list(APPEND EXTRA_LDFLAGS ${PKG_PIPEWIRE_LDFLAGS})
            endif()
            set(HAVE_SDL_AUDIO TRUE)
        endif()
    endif()
endmacro()

which essentially makes it so that native PipeWire support will only be compiled into the SDL2 binary if a recent enough version of libpipewire is installed on the system. This leads me to believe that the system on which SDL2 was compiled to be included with the Steam release of VVVVVV did not have libpipewire (although I obviously cannot say this for certain as I was not the one who compiled it) and thus PipeWire must capture and emulate PulseAudio calls from SDL2 which from my understanding is still somewhat buggy.

My fix

I realize this is a bit of a "it works on my machine" but compiling SDL2 2.28.5 (though earlier versions may also work) from source on my machine that does have libpipewire and replacing the libSDL2-2.0.so.0 included with the game with the newly-compiled one immediately fixed the issue.

How to reproduce

  • Replace PulseAudio with PipeWire on a system running Linux Mint 21
  • Download VVVVVV from Steam
  • Open the game. If the bug does not occur, close the game and reopen it until it does

Does this happen with SDL 2.30.1? If so, definitely file this here as well:

https://github.com/libsdl-org/SDL/issues

You may also be able to get around the issue with SDL_AUDIODRIVER=pipewire.

commented

After testing with 2.30.1, it does still happen once I prevent it from compiling and including the PipeWire support. Will definitely submit the issue to the SDL repo.