Skip to content

Commit

Permalink
cleaning up IHost (pure virtual) and adding host name for AUv2 (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
defiantnerd committed Apr 26, 2024
1 parent fb5d9ce commit 68a00da
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 27 deletions.
29 changes: 5 additions & 24 deletions src/clap_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
64 changes: 63 additions & 1 deletion src/detail/auv2/auv2_base_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -475,6 +535,8 @@ class WrapAsAUV2 : public ausdk::AUBase,
bool _midi_understands_midi2 = false;
// std::vector<clap_note_port_info_t> _midi_outports_info;

std::string _hostname = "CLAP-as-AUv2-wrapper";

#ifdef DUAL_SCHEDULING_ENABLED
bool _midi_dualscheduling_mode = false;
#endif
Expand Down
24 changes: 24 additions & 0 deletions src/detail/standalone/standalone_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/wrapasauv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/wrapasvst3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 68a00da

Please sign in to comment.