diff --git a/Cargo.lock b/Cargo.lock index 1c016dfa..62678752 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,7 +122,7 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "vst3-com" version = "0.1.0" -source = "git+https://github.com/robbert-vdh/vst3-sys.git?branch=fix/vst3-macro-generics#5dee36c1eac24e13c039d68f187a1899bc9069e6" +source = "git+https://github.com/RustAudio/vst3-sys.git#b65de68a7ad22b67e246948baf888ff08b3f31e9" dependencies = [ "vst3-com-macros", ] @@ -130,7 +130,7 @@ dependencies = [ [[package]] name = "vst3-com-macros" version = "0.2.0" -source = "git+https://github.com/robbert-vdh/vst3-sys.git?branch=fix/vst3-macro-generics#5dee36c1eac24e13c039d68f187a1899bc9069e6" +source = "git+https://github.com/RustAudio/vst3-sys.git#b65de68a7ad22b67e246948baf888ff08b3f31e9" dependencies = [ "proc-macro2", "quote", @@ -141,7 +141,7 @@ dependencies = [ [[package]] name = "vst3-com-macros-support" version = "0.2.0" -source = "git+https://github.com/robbert-vdh/vst3-sys.git?branch=fix/vst3-macro-generics#5dee36c1eac24e13c039d68f187a1899bc9069e6" +source = "git+https://github.com/RustAudio/vst3-sys.git#b65de68a7ad22b67e246948baf888ff08b3f31e9" dependencies = [ "proc-macro2", "quote", @@ -151,7 +151,7 @@ dependencies = [ [[package]] name = "vst3-sys" version = "0.1.0" -source = "git+https://github.com/robbert-vdh/vst3-sys.git?branch=fix/vst3-macro-generics#5dee36c1eac24e13c039d68f187a1899bc9069e6" +source = "git+https://github.com/RustAudio/vst3-sys.git#b65de68a7ad22b67e246948baf888ff08b3f31e9" dependencies = [ "vst3-com", ] diff --git a/Cargo.toml b/Cargo.toml index 49494be6..8662cf4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,5 @@ nih_plug_derive = { path = "nih_plug_derive" } lazy_static = "1.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -# Upstream currently does not support structs with generics and comments -vst3-sys = { git = "https://github.com/robbert-vdh/vst3-sys.git", branch = "fix/vst3-macro-generics" } +vst3-sys = { git = "https://github.com/RustAudio/vst3-sys.git" } widestring = "1.0.0-beta.1" diff --git a/src/wrapper/vst3.rs b/src/wrapper/vst3.rs index 90695377..c13cc2fb 100644 --- a/src/wrapper/vst3.rs +++ b/src/wrapper/vst3.rs @@ -29,10 +29,11 @@ use std::ptr; use std::sync::atomic::{AtomicBool, Ordering}; use vst3_sys::base::{kInvalidArgument, kNoInterface, kResultFalse, kResultOk, tresult, TBool}; use vst3_sys::base::{IBStream, IPluginBase, IPluginFactory, IPluginFactory2, IPluginFactory3}; +use vst3_sys::utils::VstPtr; use vst3_sys::vst::{ IAudioProcessor, IComponent, IEditController, IParamValueQueue, IParameterChanges, TChar, }; -use vst3_sys::{ComPtr, VST3}; +use vst3_sys::VST3; use widestring::U16CStr; use crate::params::{Param, ParamPtr}; @@ -295,10 +296,10 @@ impl IComponent for Wrapper<'_, P> { kResultOk } - unsafe fn set_state(&self, state: *mut c_void) -> tresult { + unsafe fn set_state(&self, state: VstPtr) -> tresult { check_null_ptr!(state); - let state: ComPtr = ComPtr::new(state as *mut _); + let state = state.upgrade().unwrap(); // We need to know how large the state is before we can read it. The current position can be // zero, but it can also be something else. Bitwig prepends the preset header in the stream, @@ -369,10 +370,10 @@ impl IComponent for Wrapper<'_, P> { kResultOk } - unsafe fn get_state(&self, state: *mut c_void) -> tresult { + unsafe fn get_state(&self, state: VstPtr) -> tresult { check_null_ptr!(state); - let state: ComPtr = ComPtr::new(state as *mut _); + let state = state.upgrade().unwrap(); // We'll serialize parmaeter values as a simple `string_param_id: display_value` map. let params = self @@ -411,12 +412,12 @@ impl IComponent for Wrapper<'_, P> { } impl IEditController for Wrapper<'_, P> { - unsafe fn set_component_state(&self, _state: *mut c_void) -> tresult { + unsafe fn set_component_state(&self, _state: VstPtr) -> tresult { // We have a single file component, so we don't need to do anything here kResultOk } - unsafe fn set_state(&self, state: *mut c_void) -> tresult { + unsafe fn set_state(&self, state: VstPtr) -> tresult { // We have a single file component, so there's only one `set_state()` function. Unlike C++, // Rust allows you to have multiple methods with the same name when they're provided by // different treats, but because of the Rust implementation the host may call either of @@ -424,7 +425,7 @@ impl IEditController for Wrapper<'_, P> { IComponent::set_state(self, state) } - unsafe fn get_state(&self, state: *mut c_void) -> tresult { + unsafe fn get_state(&self, state: VstPtr) -> tresult { // Same for this function IComponent::get_state(self, state) } @@ -589,7 +590,10 @@ impl IEditController for Wrapper<'_, P> { self.set_normalized_value_by_hash(id, value) } - unsafe fn set_component_handler(&self, _handler: *mut c_void) -> tresult { + unsafe fn set_component_handler( + &self, + _handler: VstPtr, + ) -> tresult { // TODO: Use this when we add GUI support kResultOk }