Discussion: Build dolphin-emu port with OSS as only audio option

This is just the beginning of your journey to become a great FreeBSD ports contributor :) Now take a look into the Porter's Handbook and get your hands dirty in trying to improve, extend or fix a port. Maybe you even want to become a maintainer of some ports. The FreeBSD community always needs more contributors.

You could start by adding ALSA, PULSEAUDIO and CUBEB port options to emulators/dolphin-emu in order to make these audio backends optional in the port. And cubeb is used in some other emulators too, for example emulators/pcsx2 and emulators/fbsd-duckstation. Damn! This is compiled over and over again! Create a new port for cubeb and unbundle this dependency in ports using it, so they use the new cubeb port instead. While there you will scream in anger, because cubeb enables dependencies when it finds the header files in the build environment, for example it enables ALSA support when it finds {LOCALBASE}/include/alsa/asoundlib.h during configuration stage. I hate this behavior! Now everytime some transient dependency happens to depend on audio/alsa-lib it pollutes your build. Nothing should be linked in without explicit consent, will they never learn... So you create a custom patch in your cubeb port which adds a build option no enable the audio backends in cubeb explicitly. Then you try to upstream your patch so that you can save humanity and make this world a better place.

Now the question is, also regarding your post, when is a default port dependency appropriate. 5.10. Dependencies of the handbook has a hint:

Regarding audio backends, I'd say enable all options by default (except pulseaudio ... not on my watch). There are times when one audio backend works better than another, depending on the port, the users machine and its configuration. For example: the OpenAL backend was broken for a specific release of games/gemrb, and while gemrb itself supports a SDL audio backend too, it wasn't available in the port at that time unfortunately (well granted, the SDL backend had huge latency back then, but at least it worked). Or emulators/mednafen: It supports ALSA and OSS, but the ALSA backend works just better right out of the box, for OSS it might be necessary to set some buffer options manually in the configuration file in order for it to work good on FreeBSD (at least that was on my machine with my configuration).

Space saving considerations are mood in this case. You want the best possible audio in all possible cases and don't limit the users of the port.
I found a function in cmake config file of cubeb and it is for "lazily" loading all shared libraries of sound backends. Thanks for information. I'll see if i can port cubeb and maybe add cubeb option for dolphin-emu if OP would like some help.


C-like:
option(LAZY_LOAD_LIBS "Lazily load shared libraries" ON)

if(LAZY_LOAD_LIBS)
  check_include_files(pulse/pulseaudio.h USE_PULSE)
  check_include_files(alsa/asoundlib.h   USE_ALSA)
  check_include_files(jack/jack.h        USE_JACK)
  check_include_files(sndio.h            USE_SNDIO)
  check_include_files(aaudio/AAudio.h    USE_AAUDIO)

  if(USE_PULSE OR USE_ALSA OR USE_JACK OR USE_SNDIO OR USE_AAUDIO)
    target_link_libraries(cubeb PRIVATE ${CMAKE_DL_LIBS})

    if(ANDROID)
      target_compile_definitions(cubeb PRIVATE __ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__)
    endif()
  endif()
 
I found a function in cmake config file of cubeb and it is for "lazily" loading all shared libraries of sound backends. Thanks for information. I'll see if i can port cubeb and maybe add cubeb option for dolphin-emu if OP would like some help.


C-like:
option(LAZY_LOAD_LIBS "Lazily load shared libraries" ON)

if(LAZY_LOAD_LIBS)
  check_include_files(pulse/pulseaudio.h USE_PULSE)
  check_include_files(alsa/asoundlib.h   USE_ALSA)
  check_include_files(jack/jack.h        USE_JACK)
  check_include_files(sndio.h            USE_SNDIO)
  check_include_files(aaudio/AAudio.h    USE_AAUDIO)

  if(USE_PULSE OR USE_ALSA OR USE_JACK OR USE_SNDIO OR USE_AAUDIO)
    target_link_libraries(cubeb PRIVATE ${CMAKE_DL_LIBS})

    if(ANDROID)
      target_compile_definitions(cubeb PRIVATE __ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__)
    endif()
  endif()
Yes, every help I can get would be appreciated.
If cubeb gets ported and works natively on FreeBSD then I can see if I can make it an option for Ryujinx.
Provided that cubeb has C# bindings.
As the things are now, Ryujinx only supports SDL2, OpenAL, and SoundIo.
I am not sure whether OpenAL or SDL2 directly communicate with OSS like cubeb does, but FreeBSD has OpenAL available, too.
SDL2 sadly goes out of sync in Paper Mario The Thousand Year Door Remake so, I am not really interested in it as a sound option.
 
I'd like to know if my cubeb port works fine for ports that use cubeb, please test.

I believe my cubeb port is OK now and created a PR. PR 284988.

I do not know enabling all audio backends for cubeb port is good or not.
 
I'd like to know if my cubeb port works fine for ports that use cubeb, please test.

I believe my cubeb port is OK now and created a PR. PR 284988.

I do not know enabling all audio backends for cubeb port is good or not.
That was really fast, thank you :)

I would rather not enable all audio backends by default, but make the user choose what he wants to enable, or not, and I would include options for all supported backends.
As default choice for users using pre-compiled pkgs, I would enable OSS, and ALSA as default for Cubeb.

So for dolphin-emu for example, besides NLS, CUBEB could also be made an option, and CUBEB should then let the user decide what he wants to have, or not.
 
I think that ports currently using non-port cubeb depends on all audio backends and my cubeb port has all audio backends enabled by default but users building their ports with custom options may choose what audio backend to use. I made a port once and was said that I should enable both x11 and wayland options and i think this is something like it.
 
I think that ports currently using non-port cubeb depends on all audio backends and my cubeb port has all audio backends enabled by default but users building their ports with custom options may choose what audio backend to use. I made a port once and was said that I should enable both x11 and wayland options and i think this is something like it.
And yes, you are right.
Cubeb external not strictly depends, but loads all available audio libs it finds.
To check that, you can install all available sound systems cubeb external detects, and then check in dolphin-emu which audio output you can use.
Since installing dolphin-emu by default includes already pulseaudio, jack, and sndio, it is safe to say that these audio options will be available to use.

In your case enabling all audio options by default in cubeb from ports is probably a good idea, since they are there, but the user has still the option to enable only what he wants.
 
Back
Top