microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.32k stars 6.45k forks source link

[portaudio] Add JACK and ASIO backend support #41006

Open generic-pers0n opened 2 months ago

generic-pers0n commented 2 months ago

Is your feature request related to a problem? Please describe.

This feature is not related to any problem, but it is related to efforts to upstream Tenacity's legacy vcpkg fork. In this port is a custom PortAudio port that has two features: jack and asio, which enable the respective backends. By implementing new port features or changes, we can enable JACK by default and introduce a new port feature to allow projects to easily enable ASIO.

I'm aware that you need to provide an ASIO SDK in vcpkg/buildtrees/portaudio/src to get ASIO automatically built, as according to: https://github.com/microsoft/vcpkg/blob/86fba13068f1e8111e7d885de2aef11378435139/ports/portaudio/portfile.cmake#L14

Alternatively, PortAudio can automatically download the source as well, which might be slightly more convenient, although that requires CMake 3.18 or later. This can be done if the asio feature is enabled and we have CMake 3.18 or later.

Proposed solution

My proposed solution is simply adding new port features for jack and asio to enable the respective backends. ASIO would be disabled by default due to licensing restrictions while jack would be enabled by default.

Describe alternatives you've considered

Alternatively, for enabling JACK, we can simply modify the port to also depend on jack2 and other appropriate dependencies (i.e., tre for windows | mingw and pthread for windows) and always enable the JACK backend. This might be a more sensible option since PortAudio's JACK backend should work across Windows, macOS, and Linux.

For ASIO, I do not see any other alternative due to licensing restrictions.

Additional context

There is this issue from tenacity-legacy related to getting JACK working on Windows. I believe it was possible and probably happened at one point, but nowadays this isn't possible with modern Tenacity.

The whole intention of making this issue is to discuss a) whether these changes should be implemented, and b) how they should be implemented. I intend to open a PR once we have all of this discussed should we decide to proceed.

JoergAtGithub commented 2 months ago

Just for reference, mixxxdj has also an overlay port of portaudio with some additional patches: https://github.com/mixxxdj/vcpkg/tree/2.5/overlay/ports/portaudio

FrankXie05 commented 2 months ago

@generic-pers0n About Jack and ASIO:

I agree that adding new port features (such as jack and asio) to PortAudio to support the corresponding backends. Enabling JACK as the default configuration is a good choice because it works well on multiple platforms (Windows, macOS, Linux).

It is also reasonable to disable ASIO by default because of its license restrictions. We can decide whether to automatically compile the ASIO backend based on whether the user provides the ASIO SDK.

Automatic download of ASIO:

If using CMake 3.18 or higher, allowing automatic download of ASIO source code can indeed provide convenience to users. I think this is an improvement point worth exploring, and you can check the CMake version when the asio feature is enabled and choose whether to download it based on the version.

JoergAtGithub commented 2 months ago

ASIO SDK is already a VCPKG port: https://github.com/microsoft/vcpkg/tree/master/ports/asiosdk It should be a dependency for the Windows specific port feature 'asiosdk':

"features": {
"asiosdk": {
      "description": "Build with Steinberg ASIO SDK support",
      "supports": "windows",
      "dependencies": [
        {
          "name": "asiosdk"
        }
      ]
    }
}
generic-pers0n commented 2 months ago

ASIO SDK is already a VCPKG port: https://github.com/microsoft/vcpkg/tree/master/ports/asiosdk

I didn't realize ASIO was already a port. That'll be even more convenient!

I'll make a PR soon with the proposed changes. We'll see how that goes!

generic-pers0n commented 2 months ago

Looking into the matter, for JACK at least, it looks like that JACK is only available on UNIX-based/UNIX-like sysetms (i.e., macOS, Linux, etc). It won't be until v19.8 that we will be able to enable this backend by default for Windows.

There is also a similar case with ASIO, as the PortAudio 19.7 source will not auto-download it. However, we can use the asiosdk port as mentioned earlier. I'll figure out how to do that.

JoergAtGithub commented 2 months ago

PortAudio supports JACK also on Windows. At least Git HEAD of PortAudio - might be that this feature was added after last PortAudio release.

generic-pers0n commented 2 months ago

PortAudio supports JACK also on Windows. At least Git HEAD of PortAudio - might be that this feature was added after last PortAudio release.

Indeed they do, but it was added after the latest PortAudio release.