From 68a00da7eeb7f597c7116ce10116582cf767a382 Mon Sep 17 00:00:00 2001 From: defiantnerd <97224712+defiantnerd@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:09:17 +0200 Subject: [PATCH] cleaning up IHost (pure virtual) and adding host name for AUv2 (#248) --- src/clap_proxy.h | 29 ++--------- src/detail/auv2/auv2_base_classes.h | 64 ++++++++++++++++++++++++- src/detail/standalone/standalone_host.h | 24 ++++++++++ src/wrapasauv2.cpp | 2 +- src/wrapasvst3.cpp | 2 +- 5 files changed, 94 insertions(+), 27 deletions(-) diff --git a/src/clap_proxy.h b/src/clap_proxy.h index e0c1590e..2d6b3a52 100644 --- a/src/clap_proxy.h +++ b/src/clap_proxy.h @@ -76,32 +76,13 @@ class IHost // actually, everything here should be virtual only, but until all wrappers are updated, // IHost provides default implementations. - virtual bool supportsContextMenu() const - { - return false; - } - + virtual bool supportsContextMenu() const = 0; virtual bool context_menu_populate(const clap_context_menu_target_t* target, - const clap_context_menu_builder_t* builder) - { - return false; - } - - virtual bool context_menu_perform(const clap_context_menu_target_t* target, clap_id action_id) - { - return false; - } - - virtual bool context_menu_can_popup() - { - return false; - } - + const clap_context_menu_builder_t* builder) = 0; + virtual bool context_menu_perform(const clap_context_menu_target_t* target, clap_id action_id) = 0; + virtual bool context_menu_can_popup() = 0; virtual bool context_menu_popup(const clap_context_menu_target_t* target, int32_t screen_index, - int32_t x, int32_t y) - { - return false; - } + int32_t x, int32_t y) = 0; #if LIN virtual bool register_fd(int fd, clap_posix_fd_flags_t flags) = 0; diff --git a/src/detail/auv2/auv2_base_classes.h b/src/detail/auv2/auv2_base_classes.h index a7c51063..bca5b40b 100644 --- a/src/detail/auv2/auv2_base_classes.h +++ b/src/detail/auv2/auv2_base_classes.h @@ -425,7 +425,43 @@ class WrapAsAUV2 : public ausdk::AUBase, const char* host_get_name() override { - return "Clap-As-AUV2-Wrapper"; + char text[65]; + + CFBundleRef applicationBundle = CFBundleGetMainBundle(); + if (applicationBundle != NULL) + { + CFStringRef myProductString = + (CFStringRef)CFBundleGetValueForInfoDictionaryKey(applicationBundle, kCFBundleNameKey); + if (myProductString) + { + CFStringGetCString(myProductString, text, 64, kCFStringEncodingUTF8); + _hostname = text; + CFRelease(myProductString); + } + else + { + CFStringRef applicationBundleID = CFBundleGetIdentifier(applicationBundle); + if (applicationBundleID) + { + CFStringGetCString(applicationBundleID, text, 64, kCFStringEncodingUTF8); + _hostname = text; + CFRelease(applicationBundleID); + } + } + // CFRelease(applicationBundle); Don't release it + CFStringRef myVersionString = + (CFStringRef)CFBundleGetValueForInfoDictionaryKey(applicationBundle, kCFBundleVersionKey); + if (myVersionString) + { + CFStringGetCString(myVersionString, text, 64, kCFStringEncodingUTF8); + _hostname.append(" ("); + _hostname.append(text); + _hostname.append(")"); + CFRelease(myVersionString); + } + _hostname.append(" (CLAP-as-AUv2-wrapper)"); + } + return _hostname.c_str(); } // --------------- IAutomation @@ -436,6 +472,30 @@ class WrapAsAUV2 : public ausdk::AUBase, // --------------- IPlugObject void onIdle() override; + // context menu extension + bool supportsContextMenu() const override + { + return false; + } + bool context_menu_populate(const clap_context_menu_target_t* target, + const clap_context_menu_builder_t* builder) override + { + return false; + } + bool context_menu_perform(const clap_context_menu_target_t* target, clap_id action_id) override + { + return false; + } + bool context_menu_can_popup() override + { + return false; + } + bool context_menu_popup(const clap_context_menu_target_t* target, int32_t screen_index, int32_t x, + int32_t y) override + { + return false; + } + // --------------- IMIDIOutputs void send(const Clap::AUv2::clap_multi_event_t& event) override; @@ -475,6 +535,8 @@ class WrapAsAUV2 : public ausdk::AUBase, bool _midi_understands_midi2 = false; // std::vector _midi_outports_info; + std::string _hostname = "CLAP-as-AUv2-wrapper"; + #ifdef DUAL_SCHEDULING_ENABLED bool _midi_dualscheduling_mode = false; #endif diff --git a/src/detail/standalone/standalone_host.h b/src/detail/standalone/standalone_host.h index 91f40a5f..231163bb 100644 --- a/src/detail/standalone/standalone_host.h +++ b/src/detail/standalone/standalone_host.h @@ -198,6 +198,30 @@ struct StandaloneHost : Clap::IHost const char *host_get_name() override; + // context menu extension + bool supportsContextMenu() const override + { + return false; + } + bool context_menu_populate(const clap_context_menu_target_t *target, + const clap_context_menu_builder_t *builder) override + { + return false; + } + bool context_menu_perform(const clap_context_menu_target_t *target, clap_id action_id) override + { + return false; + } + bool context_menu_can_popup() override + { + return false; + } + bool context_menu_popup(const clap_context_menu_target_t *target, int32_t screen_index, int32_t x, + int32_t y) override + { + return false; + } + #if LIN bool register_fd(int fd, clap_posix_fd_flags_t flags) override; bool modify_fd(int fd, clap_posix_fd_flags_t flags) override; diff --git a/src/wrapasauv2.cpp b/src/wrapasauv2.cpp index f5fb8512..8df41684 100644 --- a/src/wrapasauv2.cpp +++ b/src/wrapasauv2.cpp @@ -131,7 +131,7 @@ WrapAsAUV2::WrapAsAUV2(AUV2_Type type, const std::string& clapname, const std::s * ToDo: Stand up the host, create the plugin instance here */ - // pffffrzz(); + // pffffrzz(); // <- enable this to have a hook to attach a debugger _plugin = Clap::Plugin::createInstance(_library._pluginFactory, _desc->id, this); _plugin->initialize(); diff --git a/src/wrapasvst3.cpp b/src/wrapasvst3.cpp index 1052e6a9..6ce37dd5 100644 --- a/src/wrapasvst3.cpp +++ b/src/wrapasvst3.cpp @@ -997,7 +997,7 @@ const char* ClapAsVst3::host_get_name() if (kResultOk == vst3HostApplication->getName(res)) { wrapper_hostname = VST3::StringConvert::convert(res); - wrapper_hostname.append(" (CLAP-as-VST3-wrapper)"); + wrapper_hostname.append(" (CLAP-as-VST3)"); } } return wrapper_hostname.c_str();