From 04779b57663f6f3f710cb813bde0e499a6515d17 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 13 Mar 2023 15:38:01 +0100 Subject: [PATCH 1/3] Update for CLAP 1.1.8 Based on https://github.com/free-audio/clap/compare/1.1.7...1.1.8 --- src/ext/draft/ambisonic.rs | 5 ++-- src/ext/draft/configurable_audio_ports.rs | 35 +++++++++++++++++++++++ src/ext/draft/extensible_audio_ports.rs | 27 +++++++++++++++++ src/ext/draft/mod.rs | 2 ++ src/ext/draft/preset_load.rs | 19 ++++++++---- src/ext/draft/surround.rs | 13 ++------- src/factory/draft/preset_discovery.rs | 17 +++++++---- src/plugin_features.rs | 4 +++ src/version.rs | 2 +- 9 files changed, 99 insertions(+), 25 deletions(-) create mode 100644 src/ext/draft/configurable_audio_ports.rs create mode 100644 src/ext/draft/extensible_audio_ports.rs diff --git a/src/ext/draft/ambisonic.rs b/src/ext/draft/ambisonic.rs index b8ebe18..7f8e840 100644 --- a/src/ext/draft/ambisonic.rs +++ b/src/ext/draft/ambisonic.rs @@ -1,9 +1,9 @@ -use crate::{host::*, id::*, plugin::*}; +use crate::{host::*, plugin::*}; use std::ffi::CStr; pub const CLAP_EXT_AMBISONIC: &CStr = - unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.ambisonic.draft/1\0") }; + unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.ambisonic.draft/2\0") }; pub const CLAP_PORT_AMBISONIC: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"ambisonic\0") }; @@ -30,7 +30,6 @@ pub struct clap_plugin_ambisonic { pub get_info: Option< unsafe extern "C" fn( plugin: *const clap_plugin, - config_id: clap_id, is_input: bool, port_index: u32, info: *mut clap_ambisonic_info, diff --git a/src/ext/draft/configurable_audio_ports.rs b/src/ext/draft/configurable_audio_ports.rs new file mode 100644 index 0000000..0e574ef --- /dev/null +++ b/src/ext/draft/configurable_audio_ports.rs @@ -0,0 +1,35 @@ +use crate::plugin::*; + +use std::ffi::{c_char, CStr}; + +pub const CLAP_EXT_CONFIGURABLE_AUDIO_PORTS: &CStr = + unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.configurable-audio-ports.draft0\0") }; + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct clap_audio_port_configuration_request { + pub is_best_effort: bool, + pub is_input: bool, + pub port_index: u32, + pub channel_count: u32, + pub port_type: *const c_char, + pub port_details: *const c_char, +} + +unsafe impl Send for clap_audio_port_configuration_request {} +unsafe impl Sync for clap_audio_port_configuration_request {} + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct clap_plugin_configurable_audio_ports { + pub is_port_configurable: Option< + unsafe extern "C" fn(plugin: *const clap_plugin, is_input: bool, port_index: u32) -> bool, + >, + pub request_configuration: Option< + unsafe extern "C" fn( + plugin: *const clap_plugin, + requests: *const clap_audio_port_configuration_request, + request_count: u32, + ) -> bool, + >, +} diff --git a/src/ext/draft/extensible_audio_ports.rs b/src/ext/draft/extensible_audio_ports.rs new file mode 100644 index 0000000..06bd7b0 --- /dev/null +++ b/src/ext/draft/extensible_audio_ports.rs @@ -0,0 +1,27 @@ +use crate::plugin::*; + +use std::ffi::{c_char, c_void, CStr}; + +pub const CLAP_EXT_EXTENSIBLE_AUDIO_PORTS: &CStr = + unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.extensible-audio-ports.draft0\0") }; + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct clap_plugin_extensible_audio_ports { + pub add_port: Option< + unsafe extern "C" fn( + plugin: *const clap_plugin, + is_input: bool, + channel_count: u32, + port_type: *const c_char, + port_details: *const c_void, + ) -> bool, + >, + pub remove_port: Option< + unsafe extern "C" fn( + plugin: *const clap_plugin, + is_input: bool, + channel_count: u32, + ) -> bool, + >, +} diff --git a/src/ext/draft/mod.rs b/src/ext/draft/mod.rs index 890fd53..a0e31e7 100644 --- a/src/ext/draft/mod.rs +++ b/src/ext/draft/mod.rs @@ -1,8 +1,10 @@ pub mod ambisonic; pub mod audio_ports_activation; pub mod check_for_update; +pub mod configurable_audio_ports; pub mod context_menu; pub mod cv; +pub mod extensible_audio_ports; pub mod midi_mappings; pub mod param_indication; pub mod preset_load; diff --git a/src/ext/draft/preset_load.rs b/src/ext/draft/preset_load.rs index 658e16d..6bd3cab 100644 --- a/src/ext/draft/preset_load.rs +++ b/src/ext/draft/preset_load.rs @@ -1,18 +1,20 @@ +use crate::factory::draft::preset_discovery::*; use crate::{host::*, plugin::*}; use std::ffi::CStr; use std::os::raw::c_char; pub const CLAP_EXT_PRESET_LOAD: &CStr = - unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.preset-load.draft/1\0") }; + unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.preset-load.draft/2\0") }; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct clap_plugin_preset_load { - pub from_uri: Option< + pub from_location: Option< unsafe extern "C" fn( plugin: *const clap_plugin, - uri: *const c_char, + location_kind: clap_preset_discovery_location_kind, + location: *const c_char, load_key: *const c_char, ) -> bool, >, @@ -24,12 +26,19 @@ pub struct clap_host_preset_load { pub on_error: Option< unsafe extern "C" fn( host: *const clap_host, - uri: *const c_char, + location_kind: clap_preset_discovery_location_kind, + location: *const c_char, + load_key: *const c_char, os_error: i32, msg: *const c_char, ), >, pub loaded: Option< - unsafe extern "C" fn(host: *const clap_host, uri: *const c_char, load_key: *const c_char), + unsafe extern "C" fn( + host: *const clap_host, + location_kind: clap_preset_discovery_location_kind, + location: *const c_char, + load_key: *const c_char, + ), >, } diff --git a/src/ext/draft/surround.rs b/src/ext/draft/surround.rs index fd5b4e6..ceac95a 100644 --- a/src/ext/draft/surround.rs +++ b/src/ext/draft/surround.rs @@ -1,9 +1,9 @@ -use crate::{host::*, id::*, plugin::*}; +use crate::{host::*, plugin::*}; use std::ffi::CStr; pub const CLAP_EXT_SURROUND: &CStr = - unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.surround.draft/2\0") }; + unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.surround.draft/3\0") }; pub const CLAP_PORT_SURROUND: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"surround\0") }; @@ -32,7 +32,6 @@ pub struct clap_plugin_surround { pub get_channel_map: Option< unsafe extern "C" fn( plugin: *const clap_plugin, - config_id: clap_id, is_input: bool, port_index: u32, channel_map: *mut u8, @@ -46,12 +45,4 @@ pub struct clap_plugin_surround { #[derive(Debug, Copy, Clone)] pub struct clap_host_surround { pub changed: Option, - pub get_preferred_channel_map: Option< - unsafe extern "C" fn( - plugin: *const clap_host, - channel_map: *mut u8, - channel_map_capacity: u32, - channel_count: *mut u32, - ), - >, } diff --git a/src/factory/draft/preset_discovery.rs b/src/factory/draft/preset_discovery.rs index 5ab7fee..8b37f7f 100644 --- a/src/factory/draft/preset_discovery.rs +++ b/src/factory/draft/preset_discovery.rs @@ -4,7 +4,12 @@ use std::ffi::{c_void, CStr}; use std::os::raw::c_char; pub const CLAP_PRESET_DISCOVERY_FACTORY_ID: &CStr = - unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.preset-discovery-factory/draft-1\0") }; + unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.preset-discovery-factory/draft-2\0") }; + +pub const CLAP_PRESET_DISCOVERY_LOCATION_FILE: clap_preset_discovery_location_kind = 0; +pub const CLAP_PRESET_DISCOVERY_LOCATION_PLUGIN: clap_preset_discovery_location_kind = 1; + +pub type clap_preset_discovery_location_kind = u32; pub const CLAP_PRESET_DISCOVERY_IS_FACTORY_CONTENT: u32 = 1 << 0; pub const CLAP_PRESET_DISCOVERY_IS_USER_CONTENT: u32 = 1 << 1; @@ -111,7 +116,8 @@ unsafe impl Sync for clap_preset_discovery_filetype {} pub struct clap_preset_discovery_location { pub flags: u32, pub name: *const c_char, - pub uri: *const c_char, + pub kind: clap_preset_discovery_location_kind, + pub location: *const c_char, } unsafe impl Send for clap_preset_discovery_location {} @@ -120,13 +126,13 @@ unsafe impl Sync for clap_preset_discovery_location {} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct clap_preset_discovery_soundpack { - pub flags: u64, + pub flags: u32, pub id: *const c_char, pub name: *const c_char, pub description: *const c_char, pub homepage_url: *const c_char, pub vendor: *const c_char, - pub image_uri: *const c_char, + pub image_path: *const c_char, pub release_timestamp: clap_timestamp, } @@ -155,7 +161,8 @@ pub struct clap_preset_discovery_provider { pub get_metadata: Option< unsafe extern "C" fn( provider: *const clap_preset_discovery_provider, - uri: *const c_char, + location_kind: clap_preset_discovery_location_kind, + location: *const c_char, metadata_receiver: *const clap_preset_discovery_metadata_receiver, ) -> bool, >, diff --git a/src/plugin_features.rs b/src/plugin_features.rs index b3c57ca..2de8456 100644 --- a/src/plugin_features.rs +++ b/src/plugin_features.rs @@ -47,6 +47,10 @@ pub const CLAP_PLUGIN_FEATURE_TRANSIENT_SHAPER: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"transient-shaper\0") }; pub const CLAP_PLUGIN_FEATURE_COMPRESSOR: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"compressor\0") }; +pub const CLAP_PLUGIN_FEATURE_EXPANDER: &CStr = + unsafe { CStr::from_bytes_with_nul_unchecked(b"expander\0") }; +pub const CLAP_PLUGIN_FEATURE_GATE: &CStr = + unsafe { CStr::from_bytes_with_nul_unchecked(b"gate\0") }; pub const CLAP_PLUGIN_FEATURE_LIMITER: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"limiter\0") }; diff --git a/src/version.rs b/src/version.rs index 20757b1..5e9603e 100644 --- a/src/version.rs +++ b/src/version.rs @@ -10,7 +10,7 @@ pub struct clap_version { pub const CLAP_VERSION_MAJOR: u32 = 1; pub const CLAP_VERSION_MINOR: u32 = 1; -pub const CLAP_VERSION_REVISION: u32 = 7; +pub const CLAP_VERSION_REVISION: u32 = 8; pub const CLAP_VERSION: clap_version = clap_version { major: CLAP_VERSION_MAJOR, From 0ac02dcceeb3a5f048b3cc3ed169c1b3cf6d3af8 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 5 Nov 2023 15:18:18 +0100 Subject: [PATCH 2/3] fixup! Update for CLAP 1.1.8 --- src/ext/draft/configurable_audio_ports.rs | 2 +- src/ext/draft/extensible_audio_ports.rs | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ext/draft/configurable_audio_ports.rs b/src/ext/draft/configurable_audio_ports.rs index 0e574ef..fc7d2c4 100644 --- a/src/ext/draft/configurable_audio_ports.rs +++ b/src/ext/draft/configurable_audio_ports.rs @@ -13,7 +13,7 @@ pub struct clap_audio_port_configuration_request { pub port_index: u32, pub channel_count: u32, pub port_type: *const c_char, - pub port_details: *const c_char, + pub port_details: *const c_void, } unsafe impl Send for clap_audio_port_configuration_request {} diff --git a/src/ext/draft/extensible_audio_ports.rs b/src/ext/draft/extensible_audio_ports.rs index 06bd7b0..294c4fc 100644 --- a/src/ext/draft/extensible_audio_ports.rs +++ b/src/ext/draft/extensible_audio_ports.rs @@ -18,10 +18,6 @@ pub struct clap_plugin_extensible_audio_ports { ) -> bool, >, pub remove_port: Option< - unsafe extern "C" fn( - plugin: *const clap_plugin, - is_input: bool, - channel_count: u32, - ) -> bool, + unsafe extern "C" fn(plugin: *const clap_plugin, is_input: bool, index: u32) -> bool, >, } From c65e8c27e0a94fcfed7c2913dab5a3ea8e90bbbb Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 5 Nov 2023 15:20:18 +0100 Subject: [PATCH 3/3] fixup! fixup! Update for CLAP 1.1.8 --- src/ext/draft/configurable_audio_ports.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ext/draft/configurable_audio_ports.rs b/src/ext/draft/configurable_audio_ports.rs index fc7d2c4..a93a8b6 100644 --- a/src/ext/draft/configurable_audio_ports.rs +++ b/src/ext/draft/configurable_audio_ports.rs @@ -1,6 +1,6 @@ use crate::plugin::*; -use std::ffi::{c_char, CStr}; +use std::ffi::{c_char, c_void, CStr}; pub const CLAP_EXT_CONFIGURABLE_AUDIO_PORTS: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.configurable-audio-ports.draft0\0") };