From 015c554d79df86260a17535804a46b91f7e191f8 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 24 Apr 2022 15:24:35 +0200 Subject: [PATCH] Register the loggers for VST3 and CLAP plugins --- src/wrapper.rs | 3 +++ src/wrapper/clap.rs | 2 +- src/wrapper/util.rs | 4 ---- src/wrapper/vst3.rs | 6 +++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/wrapper.rs b/src/wrapper.rs index 7f60e2f8..2551e6e8 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -7,3 +7,6 @@ pub(crate) mod util; #[cfg(feature = "vst3")] pub mod vst3; + +// This is used by the wrappers. +pub use util::setup_logger; diff --git a/src/wrapper/clap.rs b/src/wrapper/clap.rs index 11469459..191cff4d 100644 --- a/src/wrapper/clap.rs +++ b/src/wrapper/clap.rs @@ -29,8 +29,8 @@ macro_rules! nih_export_clap { static ref FACTORY: ::nih_plug::wrapper::clap::Factory<$plugin_ty> = ::nih_plug::wrapper::clap::Factory::default(); } - // We don't need any special initialization or deinitialization handling pub extern "C" fn init(_plugin_path: *const ::std::os::raw::c_char) -> bool { + ::nih_plug::wrapper::setup_logger(); true } diff --git a/src/wrapper/util.rs b/src/wrapper/util.rs index 7573f9bf..305c7043 100644 --- a/src/wrapper/util.rs +++ b/src/wrapper/util.rs @@ -56,10 +56,6 @@ pub fn strlcpy(dest: &mut [c_char], src: &str) { /// `OutputDebugString()`. /// - A file path, in which case the output gets appended to the end of that file which will be /// created if necessary. -/// -/// # TODO -/// -/// Document `NIH_LOG` in an easier to find place. pub fn setup_logger() { // `win_dbg_logger` has no way to let us know that the logger has already been set up, so we'll // need to do it this way diff --git a/src/wrapper/vst3.rs b/src/wrapper/vst3.rs index 7bb21207..9721e88a 100644 --- a/src/wrapper/vst3.rs +++ b/src/wrapper/vst3.rs @@ -23,15 +23,13 @@ macro_rules! nih_export_vst3 { Box::into_raw(factory) as *mut ::std::ffi::c_void } - // We don't need any special initialization logic, so all of these module entry point - // functions just return true all the time - // These two entry points are used on Linux, and they would theoretically also be used on // the BSDs: // https://github.com/steinbergmedia/vst3_public_sdk/blob/c3948deb407bdbff89de8fb6ab8500ea4df9d6d9/source/main/linuxmain.cpp#L47-L52 #[no_mangle] #[cfg(all(target_family = "unix", not(target_os = "macos")))] pub extern "C" fn ModuleEntry(_lib_handle: *mut ::std::ffi::c_void) -> bool { + ::nih_plug::wrapper::setup_logger(); true } @@ -46,6 +44,7 @@ macro_rules! nih_export_vst3 { #[no_mangle] #[cfg(target_os = "macos")] pub extern "C" fn bundleEntry(_lib_handle: *mut ::std::ffi::c_void) -> bool { + ::nih_plug::wrapper::setup_logger(); true } @@ -60,6 +59,7 @@ macro_rules! nih_export_vst3 { #[no_mangle] #[cfg(target_os = "windows")] pub extern "system" fn InitDll() -> bool { + ::nih_plug::wrapper::setup_logger(); true }