mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
Add minimal boilerplate for a CLAP plugin
This commit is contained in:
+34
-1
@@ -22,6 +22,7 @@ project(
|
|||||||
is_64bit_system = build_machine.cpu_family() not in ['x86', 'arm']
|
is_64bit_system = build_machine.cpu_family() not in ['x86', 'arm']
|
||||||
with_32bit_libraries = (not is_64bit_system) or get_option('build.cpp_args').contains('-m32')
|
with_32bit_libraries = (not is_64bit_system) or get_option('build.cpp_args').contains('-m32')
|
||||||
with_bitbridge = get_option('bitbridge')
|
with_bitbridge = get_option('bitbridge')
|
||||||
|
with_clap = get_option('clap')
|
||||||
with_system_asio = get_option('system-asio')
|
with_system_asio = get_option('system-asio')
|
||||||
with_winedbg = get_option('winedbg')
|
with_winedbg = get_option('winedbg')
|
||||||
with_vst3 = get_option('vst3')
|
with_vst3 = get_option('vst3')
|
||||||
@@ -40,6 +41,7 @@ with_vst3 = get_option('vst3')
|
|||||||
# These variables are used to generate a `config.h` file. The library names will
|
# These variables are used to generate a `config.h` file. The library names will
|
||||||
# be prefixed with `lib` and suffixed with `.so`, and the host names will be
|
# be prefixed with `lib` and suffixed with `.so`, and the host names will be
|
||||||
# suffixed with `.exe`.
|
# suffixed with `.exe`.
|
||||||
|
clap_plugin_name = 'yabridge-clap'
|
||||||
vst2_plugin_name = 'yabridge-vst2'
|
vst2_plugin_name = 'yabridge-vst2'
|
||||||
vst3_plugin_name = 'yabridge-vst3'
|
vst3_plugin_name = 'yabridge-vst3'
|
||||||
host_name_64bit = 'yabridge-host'
|
host_name_64bit = 'yabridge-host'
|
||||||
@@ -101,6 +103,10 @@ if with_bitbridge
|
|||||||
compiler_options += '-DWITH_BITBRIDGE'
|
compiler_options += '-DWITH_BITBRIDGE'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if with_clap
|
||||||
|
compiler_options += '-DWITH_CLAP'
|
||||||
|
endif
|
||||||
|
|
||||||
# This provides an easy way to start the Wine VST host using winedbg since it
|
# This provides an easy way to start the Wine VST host using winedbg since it
|
||||||
# can be quite a pain to set up
|
# can be quite a pain to set up
|
||||||
if with_winedbg
|
if with_winedbg
|
||||||
@@ -239,6 +245,10 @@ wine_shell32_dep = declare_dependency(link_args : '-lshell32')
|
|||||||
wine_threads_dep = declare_dependency(link_args : '-lpthread')
|
wine_threads_dep = declare_dependency(link_args : '-lpthread')
|
||||||
wine_uuid_dep = declare_dependency(link_args : '-luuid')
|
wine_uuid_dep = declare_dependency(link_args : '-luuid')
|
||||||
|
|
||||||
|
if with_clap
|
||||||
|
clap_dep = dependency('clap', version : '>=1.1.1')
|
||||||
|
endif
|
||||||
|
|
||||||
# We need to build the VST3 SDK dependencies in tree because Meson won't let us
|
# We need to build the VST3 SDK dependencies in tree because Meson won't let us
|
||||||
# build both native, 32-bit cross compiled and 64-bit cross compiled
|
# build both native, 32-bit cross compiled and 64-bit cross compiled
|
||||||
# dependencies from a (CMake) subproject
|
# dependencies from a (CMake) subproject
|
||||||
@@ -293,9 +303,32 @@ shared_library(
|
|||||||
override_options : ['b_lto=true'],
|
override_options : ['b_lto=true'],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if with_clap
|
||||||
|
# This is the CLAP equivalent of `libyabridge-vst2.so`. The Wine host
|
||||||
|
# applications can handle VST2, VST3, and CLAP plugins.
|
||||||
|
shared_library(
|
||||||
|
clap_plugin_name,
|
||||||
|
clap_plugin_sources,
|
||||||
|
native : true,
|
||||||
|
include_directories : include_dir,
|
||||||
|
dependencies : clap_plugin_deps,
|
||||||
|
cpp_args : compiler_options,
|
||||||
|
)
|
||||||
|
# TODO: Chainloader
|
||||||
|
# shared_library(
|
||||||
|
# 'yabridge-chainloader-clap',
|
||||||
|
# clap_chainloader_sources,
|
||||||
|
# native : true,
|
||||||
|
# dependencies : chainloader_deps,
|
||||||
|
# cpp_args : compiler_options + chainloader_compiler_options,
|
||||||
|
# # See above
|
||||||
|
# override_options : ['b_lto=true'],
|
||||||
|
# )
|
||||||
|
endif
|
||||||
|
|
||||||
if with_vst3
|
if with_vst3
|
||||||
# This is the VST3 equivalent of `libyabridge-vst2.so`. The Wine host
|
# This is the VST3 equivalent of `libyabridge-vst2.so`. The Wine host
|
||||||
# applications can handle both VST2 and VST3 plugins.
|
# applications can handle both VST2, VST3 and CLAP plugins.
|
||||||
shared_library(
|
shared_library(
|
||||||
vst3_plugin_name,
|
vst3_plugin_name,
|
||||||
vst3_plugin_sources,
|
vst3_plugin_sources,
|
||||||
|
|||||||
@@ -5,6 +5,13 @@ option(
|
|||||||
description : 'Build a 32-bit host application for hosting 32-bit plugins. See the readme for full instructions on how to use this.'
|
description : 'Build a 32-bit host application for hosting 32-bit plugins. See the readme for full instructions on how to use this.'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(
|
||||||
|
'clap',
|
||||||
|
type : 'boolean',
|
||||||
|
value : true,
|
||||||
|
description : 'Whether to build the CLAP version of yabridge.'
|
||||||
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
'system-asio',
|
'system-asio',
|
||||||
type : 'boolean',
|
type : 'boolean',
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
// yabridge: a Wine plugin bridge
|
||||||
|
// Copyright (C) 2020-2022 Robbert van der Helm
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#include <clap/entry.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of active instances. Incremented when `clap_entry_init()` is
|
||||||
|
* called, decremented when `clap_entry_exit()` is called. We'll initialize the
|
||||||
|
* bridge when this is first incremented from 0, and we'll free the bridge again
|
||||||
|
* when a `clap_entry_exit()` call causes this to return back to 0.
|
||||||
|
*/
|
||||||
|
std::atomic_size_t active_instances = 0;
|
||||||
|
|
||||||
|
bool clap_entry_init(const char* plugin_path) {
|
||||||
|
// This function can be called multiple times, so we should make sure to
|
||||||
|
// only initialize the bridge on the first call
|
||||||
|
if (active_instances.fetch_add(1, std::memory_order_seq_cst) == 0) {
|
||||||
|
// TODO: Increase reference count, init factory if it was zero
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clap_entry_deinit() {
|
||||||
|
// We'll free the bridge when this exits brings the reference count back to
|
||||||
|
// zero
|
||||||
|
if (active_instances.fetch_sub(1, std::memory_order_seq_cst) == 1) {
|
||||||
|
// TODO: Destroy the bridge instance
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const void* clap_entry_get_factory(const char* factory_id) {
|
||||||
|
// TODO: Do the thing
|
||||||
|
// TODO: Assertion
|
||||||
|
}
|
||||||
|
|
||||||
|
CLAP_EXPORT const clap_plugin_entry_t clap_entry = {
|
||||||
|
.clap_version = CLAP_VERSION_INIT,
|
||||||
|
.init = clap_entry_init,
|
||||||
|
.deinit = clap_entry_deinit,
|
||||||
|
.get_factory = clap_entry_get_factory,
|
||||||
|
};
|
||||||
@@ -14,6 +14,22 @@ vst2_plugin_deps = [
|
|||||||
tomlplusplus_dep,
|
tomlplusplus_dep,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if with_clap
|
||||||
|
clap_plugin_deps = [
|
||||||
|
configuration_dep,
|
||||||
|
|
||||||
|
asio_dep,
|
||||||
|
bitsery_dep,
|
||||||
|
clap_dep,
|
||||||
|
dl_dep,
|
||||||
|
function2_dep,
|
||||||
|
ghc_filesystem_dep,
|
||||||
|
rt_dep,
|
||||||
|
threads_dep,
|
||||||
|
tomlplusplus_dep,
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
|
||||||
if with_vst3
|
if with_vst3
|
||||||
vst3_plugin_deps = [
|
vst3_plugin_deps = [
|
||||||
configuration_dep,
|
configuration_dep,
|
||||||
@@ -50,6 +66,12 @@ vst2_plugin_sources = files(
|
|||||||
'vst2-plugin.cpp',
|
'vst2-plugin.cpp',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if with_clap
|
||||||
|
clap_plugin_sources = files(
|
||||||
|
'clap-plugin.cpp',
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
if with_vst3
|
if with_vst3
|
||||||
vst3_plugin_sources = files(
|
vst3_plugin_sources = files(
|
||||||
'../common/communication/common.cpp',
|
'../common/communication/common.cpp',
|
||||||
|
|||||||
Reference in New Issue
Block a user