From 55ce91fc87288ccec19ad445e6cc23a419e70d2a Mon Sep 17 00:00:00 2001 From: Trinitou <106991375+Trinitou@users.noreply.github.com> Date: Thu, 8 Feb 2024 23:02:19 +0100 Subject: [PATCH 1/7] PluginProxy: Fix order of constructor initialization list (#55) --- include/clap/helpers/plugin-proxy.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/helpers/plugin-proxy.hh b/include/clap/helpers/plugin-proxy.hh index fd55f5f..a92760d 100644 --- a/include/clap/helpers/plugin-proxy.hh +++ b/include/clap/helpers/plugin-proxy.hh @@ -10,7 +10,7 @@ namespace clap { namespace helpers { template class PluginProxy { public: - PluginProxy(const clap_plugin& plugin, const Host& host) : _plugin{plugin}, _host{host} {} + PluginProxy(const clap_plugin& plugin, const Host& host) : _host{host}, _plugin{plugin} {} ///////////////// // clap_plugin // From 58eeaada48aa41c4c5c6253fd759e8d0ec9ec09c Mon Sep 17 00:00:00 2001 From: Trinitou <106991375+Trinitou@users.noreply.github.com> Date: Thu, 8 Feb 2024 13:45:18 +0100 Subject: [PATCH 2/7] Extension-specific proxy interfaces (#54) * PluginProxy: extension-specific proxy interfaces * HostProxy: extension-specific proxy interfaces --- include/clap/helpers/host-proxy.hh | 321 ++++++++++++++++++++++----- include/clap/helpers/plugin-proxy.hh | 263 +++++++++++++++++----- 2 files changed, 473 insertions(+), 111 deletions(-) diff --git a/include/clap/helpers/host-proxy.hh b/include/clap/helpers/host-proxy.hh index 4031251..72626b4 100644 --- a/include/clap/helpers/host-proxy.hh +++ b/include/clap/helpers/host-proxy.hh @@ -8,8 +8,215 @@ #include "misbehaviour-handler.hh" namespace clap { namespace helpers { + // clap_host_log template - class HostProxy { + class HostLogProxy { + public: + virtual bool canUseHostLog() const noexcept = 0; + virtual void log(clap_log_severity severity, const char *msg) const noexcept = 0; + }; + + // clap_host_thread_check + template + class HostThreadCheckProxy { + public: + virtual bool canUseThreadCheck() const noexcept = 0; + virtual bool isMainThread() const noexcept = 0; + virtual bool isAudioThread() const noexcept = 0; + }; + + // clap_host_audio_ports_config + template + class HostAudioPortsConfigProxy { + public: + virtual bool canUseAudioPortsConfig() const noexcept = 0; + virtual void audioPortsConfigRescan() const noexcept = 0; + }; + + // clap_host_audio_ports + template + class HostAudioPortsProxy { + public: + virtual bool canUseAudioPorts() const noexcept = 0; + virtual void audioPortsRescan(uint32_t flags) const noexcept = 0; + }; + + // clap_host_note_ports + template + class HostNotePortsProxy { + public: + virtual bool canUseNotePorts() const noexcept = 0; + virtual void notePortsRescan(uint32_t flags) const noexcept = 0; + }; + + // clap_host_state + template + class HostStateProxy { + public: + virtual bool canUseState() const noexcept = 0; + virtual void stateMarkDirty() const noexcept = 0; + }; + + // clap_host_latency + template + class HostLatencyProxy { + public: + virtual bool canUseLatency() const noexcept = 0; + virtual void latencyChanged() const noexcept = 0; + }; + + // clap_host_tail + template + class HostTailProxy { + public: + virtual bool canUseTail() const noexcept = 0; + virtual void tailChanged() const noexcept = 0; + }; + + // clap_host_note_name + template + class HostNoteNameProxy { + public: + virtual bool canUseNoteName() const noexcept = 0; + virtual void noteNameChanged() const noexcept = 0; + }; + + // clap_host_params + template + class HostParamsProxy { + public: + virtual bool canUseParams() const noexcept = 0; + virtual void paramsRescan(clap_param_rescan_flags flags) const noexcept = 0; + virtual void paramsClear(clap_id param_id, clap_param_clear_flags flags) const noexcept = 0; + virtual void paramsRequestFlush() const noexcept = 0; + }; + + // clap_host_track_info + template + class HostTrackInfoProxy { + public: + virtual bool canUseTrackInfo() const noexcept = 0; + virtual bool trackInfoGet(clap_track_info *info) const noexcept = 0; + }; + + // clap_host_gui + template + class HostGuiProxy { + public: + virtual bool canUseGui() const noexcept = 0; + virtual void guiResizeHintsChanged() const noexcept = 0; + virtual bool guiRequestResize(uint32_t width, uint32_t height) const noexcept = 0; + virtual bool guiRequestShow() const noexcept = 0; + virtual bool guiRequestHide() const noexcept = 0; + virtual void guiClosed(bool wasDestroyed) const noexcept = 0; + }; + + // clap_host_timer_support + template + class HostTimerSupportProxy { + public: + virtual bool canUseTimerSupport() const noexcept = 0; + virtual bool timerSupportRegister(uint32_t period_ms, clap_id *timer_id) const noexcept = 0; + virtual bool timerSupportUnregister(clap_id timer_id) const noexcept = 0; + }; + + // clap_host_fd_support + template + class HostPosixFdSupportProxy { + public: + virtual bool canUsePosixFdSupport() const noexcept = 0; + virtual bool posixFdSupportRegister(int fd, clap_posix_fd_flags_t flags) const noexcept = 0; + virtual bool posixFdSupportModify(int fd, clap_posix_fd_flags_t flags) const noexcept = 0; + virtual bool posixFdSupportUnregister(int fd) const noexcept = 0; + }; + + // clap_host_remote_controls + template + class HostRemoteControlsProxy { + public: + virtual bool canUseRemoteControls() const noexcept = 0; + virtual void remoteControlsChanged() const noexcept = 0; + virtual void remoteControlsSuggestPage(clap_id page_id) const noexcept = 0; + }; + + // clap_host_thread_pool + template + class HostThreadPoolProxy { + public: + virtual bool canUseThreadPool() const noexcept = 0; + virtual bool threadPoolRequestExec(uint32_t numTasks) const noexcept = 0; + }; + + // clap_host_voice_info + template + class HostVoiceInfoProxy { + public: + virtual bool canUseVoiceInfo() const noexcept = 0; + virtual void voiceInfoChanged() const noexcept = 0; + }; + + // clap_host_context_menu + template + class HostContextMenuProxy { + public: + virtual bool canUseContextMenu() const noexcept = 0; + virtual bool + contextMenuPopulate(const clap_context_menu_target_t *target, + const clap_context_menu_builder_t *builder) const noexcept = 0; + virtual bool contextMenuPerform(const clap_context_menu_target_t *target, + clap_id action_id) const noexcept = 0; + virtual bool contextMenuCanPopup() const noexcept = 0; + virtual bool contextMenuPopup(const clap_context_menu_target_t *target, + int32_t screen_index, + int32_t x, + int32_t y) const noexcept = 0; + }; + + // clap_host_preset_load + template + class HostPresetLoadProxy { + public: + virtual bool canUsePresetLoad() const noexcept = 0; + virtual void presetLoadOnError(uint32_t location_kind, + const char *location, + const char *load_key, + int32_t os_error, + const char *msg) const noexcept = 0; + virtual void presetLoadLoaded(uint32_t location_kind, + const char *location, + const char *load_key) const noexcept = 0; + }; + + // clap_host_resource_directory + template + class HostResourceDirectoryProxy { + public: + virtual bool canUseResourceDirectory() const noexcept = 0; + virtual bool requestDirectory(bool isShared) const noexcept = 0; + virtual void releaseDirectory(bool isShared) const noexcept = 0; + }; + + template + class HostProxy : public HostLogProxy, + public HostThreadCheckProxy, + public HostAudioPortsConfigProxy, + public HostAudioPortsProxy, + public HostNotePortsProxy, + public HostStateProxy, + public HostLatencyProxy, + public HostTailProxy, + public HostNoteNameProxy, + public HostParamsProxy, + public HostTrackInfoProxy, + public HostGuiProxy, + public HostTimerSupportProxy, + public HostPosixFdSupportProxy, + public HostRemoteControlsProxy, + public HostThreadPoolProxy, + public HostVoiceInfoProxy, + public HostContextMenuProxy, + public HostPresetLoadProxy, + public HostResourceDirectoryProxy { public: HostProxy(const clap_host *host); @@ -35,8 +242,8 @@ namespace clap { namespace helpers { /////////////////// // clap_host_log // /////////////////// - bool canUseHostLog() const noexcept; - void log(clap_log_severity severity, const char *msg) const noexcept; + bool canUseHostLog() const noexcept override; + void log(clap_log_severity severity, const char *msg) const noexcept override; void hostMisbehaving(const char *msg) const noexcept; void hostMisbehaving(const std::string &msg) const noexcept { hostMisbehaving(msg.c_str()); } void pluginMisbehaving(const char *msg) const noexcept; @@ -47,143 +254,143 @@ namespace clap { namespace helpers { //////////////////////////// // clap_host_thread_check // //////////////////////////// - bool canUseThreadCheck() const noexcept; - bool isMainThread() const noexcept; - bool isAudioThread() const noexcept; + bool canUseThreadCheck() const noexcept override; + bool isMainThread() const noexcept override; + bool isAudioThread() const noexcept override; ////////////////////////////////// // clap_host_audio_ports_config // ////////////////////////////////// - bool canUseAudioPortsConfig() const noexcept; - void audioPortsConfigRescan() const noexcept; + bool canUseAudioPortsConfig() const noexcept override; + void audioPortsConfigRescan() const noexcept override; /////////////////////////// // clap_host_audio_ports // /////////////////////////// - bool canUseAudioPorts() const noexcept; - void audioPortsRescan(uint32_t flags) const noexcept; + bool canUseAudioPorts() const noexcept override; + void audioPortsRescan(uint32_t flags) const noexcept override; ////////////////////////// // clap_host_note_ports // ////////////////////////// - bool canUseNotePorts() const noexcept; - void notePortsRescan(uint32_t flags) const noexcept; + bool canUseNotePorts() const noexcept override; + void notePortsRescan(uint32_t flags) const noexcept override; ///////////////////// // clap_host_state // ///////////////////// - bool canUseState() const noexcept; - void stateMarkDirty() const noexcept; + bool canUseState() const noexcept override; + void stateMarkDirty() const noexcept override; /////////////////////// // clap_host_latency // /////////////////////// - bool canUseLatency() const noexcept; - void latencyChanged() const noexcept; + bool canUseLatency() const noexcept override; + void latencyChanged() const noexcept override; //////////////////// // clap_host_tail // //////////////////// - bool canUseTail() const noexcept; - void tailChanged() const noexcept; + bool canUseTail() const noexcept override; + void tailChanged() const noexcept override; ///////////////////////// // clap_host_note_name // ///////////////////////// - bool canUseNoteName() const noexcept; - void noteNameChanged() const noexcept; + bool canUseNoteName() const noexcept override; + void noteNameChanged() const noexcept override; ////////////////////// // clap_host_params // ////////////////////// - bool canUseParams() const noexcept; - void paramsRescan(clap_param_rescan_flags flags) const noexcept; - void paramsClear(clap_id param_id, clap_param_clear_flags flags) const noexcept; - void paramsRequestFlush() const noexcept; + bool canUseParams() const noexcept override; + void paramsRescan(clap_param_rescan_flags flags) const noexcept override; + void paramsClear(clap_id param_id, clap_param_clear_flags flags) const noexcept override; + void paramsRequestFlush() const noexcept override; ////////////////////////// // clap_host_track_info // ////////////////////////// - bool canUseTrackInfo() const noexcept; - bool trackInfoGet(clap_track_info *info) const noexcept; + bool canUseTrackInfo() const noexcept override; + bool trackInfoGet(clap_track_info *info) const noexcept override; /////////////////// // clap_host_gui // /////////////////// - bool canUseGui() const noexcept; - void guiResizeHintsChanged() const noexcept; - bool guiRequestResize(uint32_t width, uint32_t height) const noexcept; - bool guiRequestShow() const noexcept; - bool guiRequestHide() const noexcept; - void guiClosed(bool wasDestroyed) const noexcept; + bool canUseGui() const noexcept override; + void guiResizeHintsChanged() const noexcept override; + bool guiRequestResize(uint32_t width, uint32_t height) const noexcept override; + bool guiRequestShow() const noexcept override; + bool guiRequestHide() const noexcept override; + void guiClosed(bool wasDestroyed) const noexcept override; ///////////////////////////// // clap_host_timer_support // ///////////////////////////// - bool canUseTimerSupport() const noexcept; - bool timerSupportRegister(uint32_t period_ms, clap_id *timer_id) const noexcept; - bool timerSupportUnregister(clap_id timer_id) const noexcept; + bool canUseTimerSupport() const noexcept override; + bool timerSupportRegister(uint32_t period_ms, clap_id *timer_id) const noexcept override; + bool timerSupportUnregister(clap_id timer_id) const noexcept override; ////////////////////////// // clap_host_fd_support // ////////////////////////// - bool canUsePosixFdSupport() const noexcept; - bool posixFdSupportRegister(int fd, clap_posix_fd_flags_t flags) const noexcept; - bool posixFdSupportModify(int fd, clap_posix_fd_flags_t flags) const noexcept; - bool posixFdSupportUnregister(int fd) const noexcept; + bool canUsePosixFdSupport() const noexcept override; + bool posixFdSupportRegister(int fd, clap_posix_fd_flags_t flags) const noexcept override; + bool posixFdSupportModify(int fd, clap_posix_fd_flags_t flags) const noexcept override; + bool posixFdSupportUnregister(int fd) const noexcept override; ////////////////////////////// // clap_host_remote_controls // ////////////////////////////// - bool canUseRemoteControls() const noexcept; - void remoteControlsChanged() const noexcept; - void remoteControlsSuggestPage(clap_id page_id) const noexcept; + bool canUseRemoteControls() const noexcept override; + void remoteControlsChanged() const noexcept override; + void remoteControlsSuggestPage(clap_id page_id) const noexcept override; /////////////////////////// // clap_host_thread_pool // /////////////////////////// - bool canUseThreadPool() const noexcept; - bool threadPoolRequestExec(uint32_t numTasks) const noexcept; + bool canUseThreadPool() const noexcept override; + bool threadPoolRequestExec(uint32_t numTasks) const noexcept override; ////////////////////////// // clap_host_voice_info // ////////////////////////// - bool canUseVoiceInfo() const noexcept; - void voiceInfoChanged() const noexcept; + bool canUseVoiceInfo() const noexcept override; + void voiceInfoChanged() const noexcept override; //////////////////////////// // clap_host_context_menu // //////////////////////////// - bool canUseContextMenu() const noexcept; + bool canUseContextMenu() const noexcept override; bool contextMenuPopulate(const clap_context_menu_target_t *target, - const clap_context_menu_builder_t *builder) const noexcept; + const clap_context_menu_builder_t *builder) const noexcept override; bool contextMenuPerform(const clap_context_menu_target_t *target, - clap_id action_id) const noexcept; - bool contextMenuCanPopup() const noexcept; + clap_id action_id) const noexcept override; + bool contextMenuCanPopup() const noexcept override; bool contextMenuPopup(const clap_context_menu_target_t *target, int32_t screen_index, int32_t x, - int32_t y) const noexcept; + int32_t y) const noexcept override; /////////////////////////// // clap_host_preset_load // /////////////////////////// - bool canUsePresetLoad() const noexcept; + bool canUsePresetLoad() const noexcept override; void presetLoadOnError(uint32_t location_kind, const char *location, const char *load_key, int32_t os_error, - const char *msg) const noexcept; + const char *msg) const noexcept override; void presetLoadLoaded(uint32_t location_kind, const char *location, - const char *load_key) const noexcept; + const char *load_key) const noexcept override; ////////////////////////////////// // clap_host_resource_directory // ////////////////////////////////// - bool canUseResourceDirectory() const noexcept; - bool requestDirectory(bool isShared) const noexcept; - void releaseDirectory(bool isShared) const noexcept; + bool canUseResourceDirectory() const noexcept override; + bool requestDirectory(bool isShared) const noexcept override; + void releaseDirectory(bool isShared) const noexcept override; protected: void ensureMainThread(const char *method) const noexcept; diff --git a/include/clap/helpers/plugin-proxy.hh b/include/clap/helpers/plugin-proxy.hh index a92760d..ef82a77 100644 --- a/include/clap/helpers/plugin-proxy.hh +++ b/include/clap/helpers/plugin-proxy.hh @@ -7,8 +7,160 @@ #include "host.hh" namespace clap { namespace helpers { + // clap_plugin_audio_ports template - class PluginProxy { + class PluginAudioPortsProxy { + public: + virtual bool canUseAudioPorts() const noexcept = 0; + virtual uint32_t audioPortsCount(bool isInput) const noexcept = 0; + virtual bool + audioPortsGet(uint32_t index, bool isInput, clap_audio_port_info_t *info) const noexcept = 0; + }; + + // clap_plugin_gui + template + class PluginGuiProxy { + public: + virtual bool canUseGui() const noexcept = 0; + virtual bool guiIsApiSupported(const char *api, bool isFloating) const noexcept = 0; + virtual bool guiGetPreferredApi(const char **api, bool *isFloating) const noexcept = 0; + virtual bool guiCreate(const char *api, bool isFloating) const noexcept = 0; + virtual void guiDestroy() const noexcept = 0; + virtual bool guiSetScale(double scale) const noexcept = 0; + virtual bool guiGetSize(uint32_t *width, uint32_t *height) const noexcept = 0; + virtual bool guiCanResize() const noexcept = 0; + virtual bool guiGetResizeHints(clap_gui_resize_hints_t *hints) const noexcept = 0; + virtual bool guiAdjustSize(uint32_t *width, uint32_t *height) const noexcept = 0; + virtual bool guiSetSize(uint32_t width, uint32_t height) const noexcept = 0; + virtual bool guiSetParent(const clap_window_t *window) const noexcept = 0; + virtual bool guiSetTransient(const clap_window_t *window) const noexcept = 0; + virtual void guiSuggestTitle(const char *title) const noexcept = 0; + virtual bool guiShow() const noexcept = 0; + virtual bool guiHide() const noexcept = 0; + }; + + // clap_plugin_latency + template + class PluginLatencyProxy { + public: + virtual bool canUseLatency() const noexcept = 0; + virtual uint32_t latencyGet() const noexcept = 0; + }; + + // clap_plugin_note_ports + template + class PluginNotePortsProxy { + public: + virtual bool canUseNotePorts() const noexcept = 0; + virtual uint32_t notePortsCount(bool is_input) const noexcept = 0; + virtual bool + notePortsGet(uint32_t index, bool is_input, clap_note_port_info_t *info) const noexcept = 0; + }; + + // clap_plugin_params + template + class PluginParamsProxy { + public: + virtual bool canUseParams() const noexcept = 0; + virtual uint32_t paramsCount() const noexcept = 0; + virtual bool paramsGetInfo(uint32_t paramIndex, + clap_param_info_t *paramInfo) const noexcept = 0; + virtual bool paramsGetValue(clap_id paramId, double *outValue) const noexcept = 0; + virtual bool paramsValueToText(clap_id paramId, + double value, + char *outBuffer, + uint32_t outBufferCapacity) const noexcept = 0; + virtual bool paramsTextToValue(clap_id paramId, + const char *paramValueText, + double *outValue) const noexcept = 0; + virtual void paramsFlush(const clap_input_events_t *in, + const clap_output_events_t *out) const noexcept = 0; + }; + + // clap_plugin_posix_fd_support + template + class PluginPosixFdSupportProxy { + public: + virtual bool canUsePosixFdSupport() const noexcept = 0; + virtual void posixFdSupportOnFd(int fd, clap_posix_fd_flags_t flags) const noexcept = 0; + }; + + // clap_plugin_preset_load + template + class PluginPresetLoadProxy { + public: + virtual bool canUsePresetLoad() const noexcept = 0; + virtual bool presetLoadFromLocation(uint32_t locationKind, + const char *location, + const char *loadKey) const noexcept = 0; + }; + + // clap_plugin_remote_controls + template + class PluginRemoteControlsProxy { + public: + virtual bool canUseRemoteControls() const noexcept = 0; + virtual uint32_t remoteControlsCount() const noexcept = 0; + virtual bool remoteControlsGet(uint32_t pageIndex, + clap_remote_controls_page_t *page) const noexcept = 0; + }; + + // clap_plugin_render + template + class PluginRenderProxy { + public: + virtual bool canUseRender() const noexcept = 0; + virtual bool renderHasHardRealtimeRequirement() const noexcept = 0; + virtual bool renderSet(clap_plugin_render_mode mode) const noexcept = 0; + }; + + // clap_plugin_state + template + class PluginStateProxy { + public: + virtual bool canUseState() const noexcept = 0; + virtual bool stateSave(const clap_ostream_t *stream) const noexcept = 0; + virtual bool stateLoad(const clap_istream_t *stream) const noexcept = 0; + }; + + // clap_plugin_tail + template + class PluginTailProxy { + public: + virtual bool canUseTail() const noexcept = 0; + virtual uint32_t tailGet() const noexcept = 0; + }; + + // clap_plugin_thread_pool + template + class PluginThreadPoolProxy { + public: + virtual bool canUseThreadPool() const noexcept = 0; + virtual void threadPoolExec(uint32_t taskIndex) const noexcept = 0; + }; + + // clap_plugin_timer_support + template + class PluginTimerSupportProxy { + public: + virtual bool canUseTimerSupport() const noexcept = 0; + virtual void timerSupportOnTimer(clap_id timerId) const noexcept = 0; + }; + + template + class PluginProxy : public PluginAudioPortsProxy, + public PluginGuiProxy, + public PluginLatencyProxy, + public PluginNotePortsProxy, + public PluginParamsProxy, + public PluginPosixFdSupportProxy, + public PluginPresetLoadProxy, + public PluginRemoteControlsProxy, + public PluginRenderProxy, + public PluginStateProxy, + public PluginTailProxy, + public PluginThreadPoolProxy, + public PluginTimerSupportProxy { public: PluginProxy(const clap_plugin& plugin, const Host& host) : _host{host}, _plugin{plugin} {} @@ -31,114 +183,117 @@ namespace clap { namespace helpers { ///////////////////////////// // clap_plugin_audio_ports // ///////////////////////////// - bool canUseAudioPorts() const noexcept; - uint32_t audioPortsCount(bool isInput) const noexcept; - bool audioPortsGet(uint32_t index, bool isInput, clap_audio_port_info_t *info) const noexcept; + bool canUseAudioPorts() const noexcept override; + uint32_t audioPortsCount(bool isInput) const noexcept override; + bool audioPortsGet(uint32_t index, + bool isInput, + clap_audio_port_info_t *info) const noexcept override; ///////////////////// // clap_plugin_gui // ///////////////////// - bool canUseGui() const noexcept; - bool guiIsApiSupported(const char *api, bool isFloating) const noexcept; - bool guiGetPreferredApi(const char **api, bool *isFloating) const noexcept; - bool guiCreate(const char *api, bool isFloating) const noexcept; - void guiDestroy() const noexcept; - bool guiSetScale(double scale) const noexcept; - bool guiGetSize(uint32_t *width, uint32_t *height) const noexcept; - bool guiCanResize() const noexcept; - bool guiGetResizeHints(clap_gui_resize_hints_t *hints) const noexcept; - bool guiAdjustSize(uint32_t *width, uint32_t *height) const noexcept; - bool guiSetSize(uint32_t width, uint32_t height) const noexcept; - bool guiSetParent(const clap_window_t *window) const noexcept; - bool guiSetTransient(const clap_window_t *window) const noexcept; - void guiSuggestTitle(const char *title) const noexcept; - bool guiShow() const noexcept; - bool guiHide() const noexcept; + bool canUseGui() const noexcept override; + bool guiIsApiSupported(const char *api, bool isFloating) const noexcept override; + bool guiGetPreferredApi(const char **api, bool *isFloating) const noexcept override; + bool guiCreate(const char *api, bool isFloating) const noexcept override; + void guiDestroy() const noexcept override; + bool guiSetScale(double scale) const noexcept override; + bool guiGetSize(uint32_t *width, uint32_t *height) const noexcept override; + bool guiCanResize() const noexcept override; + bool guiGetResizeHints(clap_gui_resize_hints_t *hints) const noexcept override; + bool guiAdjustSize(uint32_t *width, uint32_t *height) const noexcept override; + bool guiSetSize(uint32_t width, uint32_t height) const noexcept override; + bool guiSetParent(const clap_window_t *window) const noexcept override; + bool guiSetTransient(const clap_window_t *window) const noexcept override; + void guiSuggestTitle(const char *title) const noexcept override; + bool guiShow() const noexcept override; + bool guiHide() const noexcept override; ///////////////////////// // clap_plugin_latency // ///////////////////////// - bool canUseLatency() const noexcept; - uint32_t latencyGet() const noexcept; + bool canUseLatency() const noexcept override; + uint32_t latencyGet() const noexcept override; //////////////////////////// // clap_plugin_note_ports // //////////////////////////// - bool canUseNotePorts() const noexcept; - uint32_t notePortsCount(bool is_input) const noexcept; - bool notePortsGet(uint32_t index, - bool is_input, - clap_note_port_info_t *info) const noexcept; + bool canUseNotePorts() const noexcept override; + uint32_t notePortsCount(bool is_input) const noexcept override; + bool notePortsGet(uint32_t index, + bool is_input, + clap_note_port_info_t *info) const noexcept override; //////////////////////// // clap_plugin_params // //////////////////////// - bool canUseParams() const noexcept; - uint32_t paramsCount() const noexcept; - bool paramsGetInfo(uint32_t paramIndex, clap_param_info_t *paramInfo) const noexcept; - bool paramsGetValue(clap_id paramId, double *outValue) const noexcept; + bool canUseParams() const noexcept override; + uint32_t paramsCount() const noexcept override; + bool paramsGetInfo(uint32_t paramIndex, clap_param_info_t *paramInfo) const noexcept override; + bool paramsGetValue(clap_id paramId, double *outValue) const noexcept override; bool paramsValueToText(clap_id paramId, double value, char *outBuffer, - uint32_t outBufferCapacity) const noexcept; + uint32_t outBufferCapacity) const noexcept override; bool paramsTextToValue(clap_id paramId, const char *paramValueText, - double *outValue) const noexcept; - void paramsFlush(const clap_input_events_t *in, const clap_output_events_t *out) const noexcept; + double *outValue) const noexcept override; + void paramsFlush(const clap_input_events_t *in, + const clap_output_events_t *out) const noexcept override; ////////////////////////////////// // clap_plugin_posix_fd_support // ////////////////////////////////// - bool canUsePosixFdSupport() const noexcept; - void posixFdSupportOnFd(int fd, clap_posix_fd_flags_t flags) const noexcept; + bool canUsePosixFdSupport() const noexcept override; + void posixFdSupportOnFd(int fd, clap_posix_fd_flags_t flags) const noexcept override; ///////////////////////////// // clap_plugin_preset_load // ///////////////////////////// - bool canUsePresetLoad() const noexcept; + bool canUsePresetLoad() const noexcept override; bool presetLoadFromLocation(uint32_t locationKind, const char *location, - const char *loadKey) const noexcept; + const char *loadKey) const noexcept override; ///////////////////////////////// // clap_plugin_remote_controls // ///////////////////////////////// - bool canUseRemoteControls() const noexcept; - uint32_t remoteControlsCount() const noexcept; - bool remoteControlsGet(uint32_t pageIndex, - clap_remote_controls_page_t *page) const noexcept; + bool canUseRemoteControls() const noexcept override; + uint32_t remoteControlsCount() const noexcept override; + bool remoteControlsGet(uint32_t pageIndex, + clap_remote_controls_page_t *page) const noexcept override; //////////////////////// // clap_plugin_render // //////////////////////// - bool canUseRender() const noexcept; - bool renderHasHardRealtimeRequirement() const noexcept; - bool renderSet(clap_plugin_render_mode mode) const noexcept; + bool canUseRender() const noexcept override; + bool renderHasHardRealtimeRequirement() const noexcept override; + bool renderSet(clap_plugin_render_mode mode) const noexcept override; /////////////////////// // clap_plugin_state // /////////////////////// - bool canUseState() const noexcept; - bool stateSave(const clap_ostream_t *stream) const noexcept; - bool stateLoad(const clap_istream_t *stream) const noexcept; + bool canUseState() const noexcept override; + bool stateSave(const clap_ostream_t *stream) const noexcept override; + bool stateLoad(const clap_istream_t *stream) const noexcept override; ////////////////////// // clap_plugin_tail // ////////////////////// - bool canUseTail() const noexcept; - uint32_t tailGet() const noexcept; + bool canUseTail() const noexcept override; + uint32_t tailGet() const noexcept override; ///////////////////////////// // clap_plugin_thread_pool // ///////////////////////////// - bool canUseThreadPool() const noexcept; - void threadPoolExec(uint32_t taskIndex) const noexcept; + bool canUseThreadPool() const noexcept override; + void threadPoolExec(uint32_t taskIndex) const noexcept override; /////////////////////////////// // clap_plugin_timer_support // /////////////////////////////// - bool canUseTimerSupport() const noexcept; - void timerSupportOnTimer(clap_id timerId) const noexcept; + bool canUseTimerSupport() const noexcept override; + void timerSupportOnTimer(clap_id timerId) const noexcept override; protected: ///////////////////// From 3be22cd3289f9fa6b5c4f78195ba6da42de93f55 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Fri, 9 Feb 2024 07:15:12 -0500 Subject: [PATCH 3/7] Revert "Extension-specific proxy interfaces (#54)" This reverts commit 0e0a98162df858298797cce11bb0a481013e859a. This was merged to next pre-review in error --- include/clap/helpers/host-proxy.hh | 321 +++++---------------------- include/clap/helpers/plugin-proxy.hh | 263 +++++----------------- 2 files changed, 111 insertions(+), 473 deletions(-) diff --git a/include/clap/helpers/host-proxy.hh b/include/clap/helpers/host-proxy.hh index 72626b4..4031251 100644 --- a/include/clap/helpers/host-proxy.hh +++ b/include/clap/helpers/host-proxy.hh @@ -8,215 +8,8 @@ #include "misbehaviour-handler.hh" namespace clap { namespace helpers { - // clap_host_log template - class HostLogProxy { - public: - virtual bool canUseHostLog() const noexcept = 0; - virtual void log(clap_log_severity severity, const char *msg) const noexcept = 0; - }; - - // clap_host_thread_check - template - class HostThreadCheckProxy { - public: - virtual bool canUseThreadCheck() const noexcept = 0; - virtual bool isMainThread() const noexcept = 0; - virtual bool isAudioThread() const noexcept = 0; - }; - - // clap_host_audio_ports_config - template - class HostAudioPortsConfigProxy { - public: - virtual bool canUseAudioPortsConfig() const noexcept = 0; - virtual void audioPortsConfigRescan() const noexcept = 0; - }; - - // clap_host_audio_ports - template - class HostAudioPortsProxy { - public: - virtual bool canUseAudioPorts() const noexcept = 0; - virtual void audioPortsRescan(uint32_t flags) const noexcept = 0; - }; - - // clap_host_note_ports - template - class HostNotePortsProxy { - public: - virtual bool canUseNotePorts() const noexcept = 0; - virtual void notePortsRescan(uint32_t flags) const noexcept = 0; - }; - - // clap_host_state - template - class HostStateProxy { - public: - virtual bool canUseState() const noexcept = 0; - virtual void stateMarkDirty() const noexcept = 0; - }; - - // clap_host_latency - template - class HostLatencyProxy { - public: - virtual bool canUseLatency() const noexcept = 0; - virtual void latencyChanged() const noexcept = 0; - }; - - // clap_host_tail - template - class HostTailProxy { - public: - virtual bool canUseTail() const noexcept = 0; - virtual void tailChanged() const noexcept = 0; - }; - - // clap_host_note_name - template - class HostNoteNameProxy { - public: - virtual bool canUseNoteName() const noexcept = 0; - virtual void noteNameChanged() const noexcept = 0; - }; - - // clap_host_params - template - class HostParamsProxy { - public: - virtual bool canUseParams() const noexcept = 0; - virtual void paramsRescan(clap_param_rescan_flags flags) const noexcept = 0; - virtual void paramsClear(clap_id param_id, clap_param_clear_flags flags) const noexcept = 0; - virtual void paramsRequestFlush() const noexcept = 0; - }; - - // clap_host_track_info - template - class HostTrackInfoProxy { - public: - virtual bool canUseTrackInfo() const noexcept = 0; - virtual bool trackInfoGet(clap_track_info *info) const noexcept = 0; - }; - - // clap_host_gui - template - class HostGuiProxy { - public: - virtual bool canUseGui() const noexcept = 0; - virtual void guiResizeHintsChanged() const noexcept = 0; - virtual bool guiRequestResize(uint32_t width, uint32_t height) const noexcept = 0; - virtual bool guiRequestShow() const noexcept = 0; - virtual bool guiRequestHide() const noexcept = 0; - virtual void guiClosed(bool wasDestroyed) const noexcept = 0; - }; - - // clap_host_timer_support - template - class HostTimerSupportProxy { - public: - virtual bool canUseTimerSupport() const noexcept = 0; - virtual bool timerSupportRegister(uint32_t period_ms, clap_id *timer_id) const noexcept = 0; - virtual bool timerSupportUnregister(clap_id timer_id) const noexcept = 0; - }; - - // clap_host_fd_support - template - class HostPosixFdSupportProxy { - public: - virtual bool canUsePosixFdSupport() const noexcept = 0; - virtual bool posixFdSupportRegister(int fd, clap_posix_fd_flags_t flags) const noexcept = 0; - virtual bool posixFdSupportModify(int fd, clap_posix_fd_flags_t flags) const noexcept = 0; - virtual bool posixFdSupportUnregister(int fd) const noexcept = 0; - }; - - // clap_host_remote_controls - template - class HostRemoteControlsProxy { - public: - virtual bool canUseRemoteControls() const noexcept = 0; - virtual void remoteControlsChanged() const noexcept = 0; - virtual void remoteControlsSuggestPage(clap_id page_id) const noexcept = 0; - }; - - // clap_host_thread_pool - template - class HostThreadPoolProxy { - public: - virtual bool canUseThreadPool() const noexcept = 0; - virtual bool threadPoolRequestExec(uint32_t numTasks) const noexcept = 0; - }; - - // clap_host_voice_info - template - class HostVoiceInfoProxy { - public: - virtual bool canUseVoiceInfo() const noexcept = 0; - virtual void voiceInfoChanged() const noexcept = 0; - }; - - // clap_host_context_menu - template - class HostContextMenuProxy { - public: - virtual bool canUseContextMenu() const noexcept = 0; - virtual bool - contextMenuPopulate(const clap_context_menu_target_t *target, - const clap_context_menu_builder_t *builder) const noexcept = 0; - virtual bool contextMenuPerform(const clap_context_menu_target_t *target, - clap_id action_id) const noexcept = 0; - virtual bool contextMenuCanPopup() const noexcept = 0; - virtual bool contextMenuPopup(const clap_context_menu_target_t *target, - int32_t screen_index, - int32_t x, - int32_t y) const noexcept = 0; - }; - - // clap_host_preset_load - template - class HostPresetLoadProxy { - public: - virtual bool canUsePresetLoad() const noexcept = 0; - virtual void presetLoadOnError(uint32_t location_kind, - const char *location, - const char *load_key, - int32_t os_error, - const char *msg) const noexcept = 0; - virtual void presetLoadLoaded(uint32_t location_kind, - const char *location, - const char *load_key) const noexcept = 0; - }; - - // clap_host_resource_directory - template - class HostResourceDirectoryProxy { - public: - virtual bool canUseResourceDirectory() const noexcept = 0; - virtual bool requestDirectory(bool isShared) const noexcept = 0; - virtual void releaseDirectory(bool isShared) const noexcept = 0; - }; - - template - class HostProxy : public HostLogProxy, - public HostThreadCheckProxy, - public HostAudioPortsConfigProxy, - public HostAudioPortsProxy, - public HostNotePortsProxy, - public HostStateProxy, - public HostLatencyProxy, - public HostTailProxy, - public HostNoteNameProxy, - public HostParamsProxy, - public HostTrackInfoProxy, - public HostGuiProxy, - public HostTimerSupportProxy, - public HostPosixFdSupportProxy, - public HostRemoteControlsProxy, - public HostThreadPoolProxy, - public HostVoiceInfoProxy, - public HostContextMenuProxy, - public HostPresetLoadProxy, - public HostResourceDirectoryProxy { + class HostProxy { public: HostProxy(const clap_host *host); @@ -242,8 +35,8 @@ namespace clap { namespace helpers { /////////////////// // clap_host_log // /////////////////// - bool canUseHostLog() const noexcept override; - void log(clap_log_severity severity, const char *msg) const noexcept override; + bool canUseHostLog() const noexcept; + void log(clap_log_severity severity, const char *msg) const noexcept; void hostMisbehaving(const char *msg) const noexcept; void hostMisbehaving(const std::string &msg) const noexcept { hostMisbehaving(msg.c_str()); } void pluginMisbehaving(const char *msg) const noexcept; @@ -254,143 +47,143 @@ namespace clap { namespace helpers { //////////////////////////// // clap_host_thread_check // //////////////////////////// - bool canUseThreadCheck() const noexcept override; - bool isMainThread() const noexcept override; - bool isAudioThread() const noexcept override; + bool canUseThreadCheck() const noexcept; + bool isMainThread() const noexcept; + bool isAudioThread() const noexcept; ////////////////////////////////// // clap_host_audio_ports_config // ////////////////////////////////// - bool canUseAudioPortsConfig() const noexcept override; - void audioPortsConfigRescan() const noexcept override; + bool canUseAudioPortsConfig() const noexcept; + void audioPortsConfigRescan() const noexcept; /////////////////////////// // clap_host_audio_ports // /////////////////////////// - bool canUseAudioPorts() const noexcept override; - void audioPortsRescan(uint32_t flags) const noexcept override; + bool canUseAudioPorts() const noexcept; + void audioPortsRescan(uint32_t flags) const noexcept; ////////////////////////// // clap_host_note_ports // ////////////////////////// - bool canUseNotePorts() const noexcept override; - void notePortsRescan(uint32_t flags) const noexcept override; + bool canUseNotePorts() const noexcept; + void notePortsRescan(uint32_t flags) const noexcept; ///////////////////// // clap_host_state // ///////////////////// - bool canUseState() const noexcept override; - void stateMarkDirty() const noexcept override; + bool canUseState() const noexcept; + void stateMarkDirty() const noexcept; /////////////////////// // clap_host_latency // /////////////////////// - bool canUseLatency() const noexcept override; - void latencyChanged() const noexcept override; + bool canUseLatency() const noexcept; + void latencyChanged() const noexcept; //////////////////// // clap_host_tail // //////////////////// - bool canUseTail() const noexcept override; - void tailChanged() const noexcept override; + bool canUseTail() const noexcept; + void tailChanged() const noexcept; ///////////////////////// // clap_host_note_name // ///////////////////////// - bool canUseNoteName() const noexcept override; - void noteNameChanged() const noexcept override; + bool canUseNoteName() const noexcept; + void noteNameChanged() const noexcept; ////////////////////// // clap_host_params // ////////////////////// - bool canUseParams() const noexcept override; - void paramsRescan(clap_param_rescan_flags flags) const noexcept override; - void paramsClear(clap_id param_id, clap_param_clear_flags flags) const noexcept override; - void paramsRequestFlush() const noexcept override; + bool canUseParams() const noexcept; + void paramsRescan(clap_param_rescan_flags flags) const noexcept; + void paramsClear(clap_id param_id, clap_param_clear_flags flags) const noexcept; + void paramsRequestFlush() const noexcept; ////////////////////////// // clap_host_track_info // ////////////////////////// - bool canUseTrackInfo() const noexcept override; - bool trackInfoGet(clap_track_info *info) const noexcept override; + bool canUseTrackInfo() const noexcept; + bool trackInfoGet(clap_track_info *info) const noexcept; /////////////////// // clap_host_gui // /////////////////// - bool canUseGui() const noexcept override; - void guiResizeHintsChanged() const noexcept override; - bool guiRequestResize(uint32_t width, uint32_t height) const noexcept override; - bool guiRequestShow() const noexcept override; - bool guiRequestHide() const noexcept override; - void guiClosed(bool wasDestroyed) const noexcept override; + bool canUseGui() const noexcept; + void guiResizeHintsChanged() const noexcept; + bool guiRequestResize(uint32_t width, uint32_t height) const noexcept; + bool guiRequestShow() const noexcept; + bool guiRequestHide() const noexcept; + void guiClosed(bool wasDestroyed) const noexcept; ///////////////////////////// // clap_host_timer_support // ///////////////////////////// - bool canUseTimerSupport() const noexcept override; - bool timerSupportRegister(uint32_t period_ms, clap_id *timer_id) const noexcept override; - bool timerSupportUnregister(clap_id timer_id) const noexcept override; + bool canUseTimerSupport() const noexcept; + bool timerSupportRegister(uint32_t period_ms, clap_id *timer_id) const noexcept; + bool timerSupportUnregister(clap_id timer_id) const noexcept; ////////////////////////// // clap_host_fd_support // ////////////////////////// - bool canUsePosixFdSupport() const noexcept override; - bool posixFdSupportRegister(int fd, clap_posix_fd_flags_t flags) const noexcept override; - bool posixFdSupportModify(int fd, clap_posix_fd_flags_t flags) const noexcept override; - bool posixFdSupportUnregister(int fd) const noexcept override; + bool canUsePosixFdSupport() const noexcept; + bool posixFdSupportRegister(int fd, clap_posix_fd_flags_t flags) const noexcept; + bool posixFdSupportModify(int fd, clap_posix_fd_flags_t flags) const noexcept; + bool posixFdSupportUnregister(int fd) const noexcept; ////////////////////////////// // clap_host_remote_controls // ////////////////////////////// - bool canUseRemoteControls() const noexcept override; - void remoteControlsChanged() const noexcept override; - void remoteControlsSuggestPage(clap_id page_id) const noexcept override; + bool canUseRemoteControls() const noexcept; + void remoteControlsChanged() const noexcept; + void remoteControlsSuggestPage(clap_id page_id) const noexcept; /////////////////////////// // clap_host_thread_pool // /////////////////////////// - bool canUseThreadPool() const noexcept override; - bool threadPoolRequestExec(uint32_t numTasks) const noexcept override; + bool canUseThreadPool() const noexcept; + bool threadPoolRequestExec(uint32_t numTasks) const noexcept; ////////////////////////// // clap_host_voice_info // ////////////////////////// - bool canUseVoiceInfo() const noexcept override; - void voiceInfoChanged() const noexcept override; + bool canUseVoiceInfo() const noexcept; + void voiceInfoChanged() const noexcept; //////////////////////////// // clap_host_context_menu // //////////////////////////// - bool canUseContextMenu() const noexcept override; + bool canUseContextMenu() const noexcept; bool contextMenuPopulate(const clap_context_menu_target_t *target, - const clap_context_menu_builder_t *builder) const noexcept override; + const clap_context_menu_builder_t *builder) const noexcept; bool contextMenuPerform(const clap_context_menu_target_t *target, - clap_id action_id) const noexcept override; - bool contextMenuCanPopup() const noexcept override; + clap_id action_id) const noexcept; + bool contextMenuCanPopup() const noexcept; bool contextMenuPopup(const clap_context_menu_target_t *target, int32_t screen_index, int32_t x, - int32_t y) const noexcept override; + int32_t y) const noexcept; /////////////////////////// // clap_host_preset_load // /////////////////////////// - bool canUsePresetLoad() const noexcept override; + bool canUsePresetLoad() const noexcept; void presetLoadOnError(uint32_t location_kind, const char *location, const char *load_key, int32_t os_error, - const char *msg) const noexcept override; + const char *msg) const noexcept; void presetLoadLoaded(uint32_t location_kind, const char *location, - const char *load_key) const noexcept override; + const char *load_key) const noexcept; ////////////////////////////////// // clap_host_resource_directory // ////////////////////////////////// - bool canUseResourceDirectory() const noexcept override; - bool requestDirectory(bool isShared) const noexcept override; - void releaseDirectory(bool isShared) const noexcept override; + bool canUseResourceDirectory() const noexcept; + bool requestDirectory(bool isShared) const noexcept; + void releaseDirectory(bool isShared) const noexcept; protected: void ensureMainThread(const char *method) const noexcept; diff --git a/include/clap/helpers/plugin-proxy.hh b/include/clap/helpers/plugin-proxy.hh index ef82a77..a92760d 100644 --- a/include/clap/helpers/plugin-proxy.hh +++ b/include/clap/helpers/plugin-proxy.hh @@ -7,160 +7,8 @@ #include "host.hh" namespace clap { namespace helpers { - // clap_plugin_audio_ports template - class PluginAudioPortsProxy { - public: - virtual bool canUseAudioPorts() const noexcept = 0; - virtual uint32_t audioPortsCount(bool isInput) const noexcept = 0; - virtual bool - audioPortsGet(uint32_t index, bool isInput, clap_audio_port_info_t *info) const noexcept = 0; - }; - - // clap_plugin_gui - template - class PluginGuiProxy { - public: - virtual bool canUseGui() const noexcept = 0; - virtual bool guiIsApiSupported(const char *api, bool isFloating) const noexcept = 0; - virtual bool guiGetPreferredApi(const char **api, bool *isFloating) const noexcept = 0; - virtual bool guiCreate(const char *api, bool isFloating) const noexcept = 0; - virtual void guiDestroy() const noexcept = 0; - virtual bool guiSetScale(double scale) const noexcept = 0; - virtual bool guiGetSize(uint32_t *width, uint32_t *height) const noexcept = 0; - virtual bool guiCanResize() const noexcept = 0; - virtual bool guiGetResizeHints(clap_gui_resize_hints_t *hints) const noexcept = 0; - virtual bool guiAdjustSize(uint32_t *width, uint32_t *height) const noexcept = 0; - virtual bool guiSetSize(uint32_t width, uint32_t height) const noexcept = 0; - virtual bool guiSetParent(const clap_window_t *window) const noexcept = 0; - virtual bool guiSetTransient(const clap_window_t *window) const noexcept = 0; - virtual void guiSuggestTitle(const char *title) const noexcept = 0; - virtual bool guiShow() const noexcept = 0; - virtual bool guiHide() const noexcept = 0; - }; - - // clap_plugin_latency - template - class PluginLatencyProxy { - public: - virtual bool canUseLatency() const noexcept = 0; - virtual uint32_t latencyGet() const noexcept = 0; - }; - - // clap_plugin_note_ports - template - class PluginNotePortsProxy { - public: - virtual bool canUseNotePorts() const noexcept = 0; - virtual uint32_t notePortsCount(bool is_input) const noexcept = 0; - virtual bool - notePortsGet(uint32_t index, bool is_input, clap_note_port_info_t *info) const noexcept = 0; - }; - - // clap_plugin_params - template - class PluginParamsProxy { - public: - virtual bool canUseParams() const noexcept = 0; - virtual uint32_t paramsCount() const noexcept = 0; - virtual bool paramsGetInfo(uint32_t paramIndex, - clap_param_info_t *paramInfo) const noexcept = 0; - virtual bool paramsGetValue(clap_id paramId, double *outValue) const noexcept = 0; - virtual bool paramsValueToText(clap_id paramId, - double value, - char *outBuffer, - uint32_t outBufferCapacity) const noexcept = 0; - virtual bool paramsTextToValue(clap_id paramId, - const char *paramValueText, - double *outValue) const noexcept = 0; - virtual void paramsFlush(const clap_input_events_t *in, - const clap_output_events_t *out) const noexcept = 0; - }; - - // clap_plugin_posix_fd_support - template - class PluginPosixFdSupportProxy { - public: - virtual bool canUsePosixFdSupport() const noexcept = 0; - virtual void posixFdSupportOnFd(int fd, clap_posix_fd_flags_t flags) const noexcept = 0; - }; - - // clap_plugin_preset_load - template - class PluginPresetLoadProxy { - public: - virtual bool canUsePresetLoad() const noexcept = 0; - virtual bool presetLoadFromLocation(uint32_t locationKind, - const char *location, - const char *loadKey) const noexcept = 0; - }; - - // clap_plugin_remote_controls - template - class PluginRemoteControlsProxy { - public: - virtual bool canUseRemoteControls() const noexcept = 0; - virtual uint32_t remoteControlsCount() const noexcept = 0; - virtual bool remoteControlsGet(uint32_t pageIndex, - clap_remote_controls_page_t *page) const noexcept = 0; - }; - - // clap_plugin_render - template - class PluginRenderProxy { - public: - virtual bool canUseRender() const noexcept = 0; - virtual bool renderHasHardRealtimeRequirement() const noexcept = 0; - virtual bool renderSet(clap_plugin_render_mode mode) const noexcept = 0; - }; - - // clap_plugin_state - template - class PluginStateProxy { - public: - virtual bool canUseState() const noexcept = 0; - virtual bool stateSave(const clap_ostream_t *stream) const noexcept = 0; - virtual bool stateLoad(const clap_istream_t *stream) const noexcept = 0; - }; - - // clap_plugin_tail - template - class PluginTailProxy { - public: - virtual bool canUseTail() const noexcept = 0; - virtual uint32_t tailGet() const noexcept = 0; - }; - - // clap_plugin_thread_pool - template - class PluginThreadPoolProxy { - public: - virtual bool canUseThreadPool() const noexcept = 0; - virtual void threadPoolExec(uint32_t taskIndex) const noexcept = 0; - }; - - // clap_plugin_timer_support - template - class PluginTimerSupportProxy { - public: - virtual bool canUseTimerSupport() const noexcept = 0; - virtual void timerSupportOnTimer(clap_id timerId) const noexcept = 0; - }; - - template - class PluginProxy : public PluginAudioPortsProxy, - public PluginGuiProxy, - public PluginLatencyProxy, - public PluginNotePortsProxy, - public PluginParamsProxy, - public PluginPosixFdSupportProxy, - public PluginPresetLoadProxy, - public PluginRemoteControlsProxy, - public PluginRenderProxy, - public PluginStateProxy, - public PluginTailProxy, - public PluginThreadPoolProxy, - public PluginTimerSupportProxy { + class PluginProxy { public: PluginProxy(const clap_plugin& plugin, const Host& host) : _host{host}, _plugin{plugin} {} @@ -183,117 +31,114 @@ namespace clap { namespace helpers { ///////////////////////////// // clap_plugin_audio_ports // ///////////////////////////// - bool canUseAudioPorts() const noexcept override; - uint32_t audioPortsCount(bool isInput) const noexcept override; - bool audioPortsGet(uint32_t index, - bool isInput, - clap_audio_port_info_t *info) const noexcept override; + bool canUseAudioPorts() const noexcept; + uint32_t audioPortsCount(bool isInput) const noexcept; + bool audioPortsGet(uint32_t index, bool isInput, clap_audio_port_info_t *info) const noexcept; ///////////////////// // clap_plugin_gui // ///////////////////// - bool canUseGui() const noexcept override; - bool guiIsApiSupported(const char *api, bool isFloating) const noexcept override; - bool guiGetPreferredApi(const char **api, bool *isFloating) const noexcept override; - bool guiCreate(const char *api, bool isFloating) const noexcept override; - void guiDestroy() const noexcept override; - bool guiSetScale(double scale) const noexcept override; - bool guiGetSize(uint32_t *width, uint32_t *height) const noexcept override; - bool guiCanResize() const noexcept override; - bool guiGetResizeHints(clap_gui_resize_hints_t *hints) const noexcept override; - bool guiAdjustSize(uint32_t *width, uint32_t *height) const noexcept override; - bool guiSetSize(uint32_t width, uint32_t height) const noexcept override; - bool guiSetParent(const clap_window_t *window) const noexcept override; - bool guiSetTransient(const clap_window_t *window) const noexcept override; - void guiSuggestTitle(const char *title) const noexcept override; - bool guiShow() const noexcept override; - bool guiHide() const noexcept override; + bool canUseGui() const noexcept; + bool guiIsApiSupported(const char *api, bool isFloating) const noexcept; + bool guiGetPreferredApi(const char **api, bool *isFloating) const noexcept; + bool guiCreate(const char *api, bool isFloating) const noexcept; + void guiDestroy() const noexcept; + bool guiSetScale(double scale) const noexcept; + bool guiGetSize(uint32_t *width, uint32_t *height) const noexcept; + bool guiCanResize() const noexcept; + bool guiGetResizeHints(clap_gui_resize_hints_t *hints) const noexcept; + bool guiAdjustSize(uint32_t *width, uint32_t *height) const noexcept; + bool guiSetSize(uint32_t width, uint32_t height) const noexcept; + bool guiSetParent(const clap_window_t *window) const noexcept; + bool guiSetTransient(const clap_window_t *window) const noexcept; + void guiSuggestTitle(const char *title) const noexcept; + bool guiShow() const noexcept; + bool guiHide() const noexcept; ///////////////////////// // clap_plugin_latency // ///////////////////////// - bool canUseLatency() const noexcept override; - uint32_t latencyGet() const noexcept override; + bool canUseLatency() const noexcept; + uint32_t latencyGet() const noexcept; //////////////////////////// // clap_plugin_note_ports // //////////////////////////// - bool canUseNotePorts() const noexcept override; - uint32_t notePortsCount(bool is_input) const noexcept override; - bool notePortsGet(uint32_t index, - bool is_input, - clap_note_port_info_t *info) const noexcept override; + bool canUseNotePorts() const noexcept; + uint32_t notePortsCount(bool is_input) const noexcept; + bool notePortsGet(uint32_t index, + bool is_input, + clap_note_port_info_t *info) const noexcept; //////////////////////// // clap_plugin_params // //////////////////////// - bool canUseParams() const noexcept override; - uint32_t paramsCount() const noexcept override; - bool paramsGetInfo(uint32_t paramIndex, clap_param_info_t *paramInfo) const noexcept override; - bool paramsGetValue(clap_id paramId, double *outValue) const noexcept override; + bool canUseParams() const noexcept; + uint32_t paramsCount() const noexcept; + bool paramsGetInfo(uint32_t paramIndex, clap_param_info_t *paramInfo) const noexcept; + bool paramsGetValue(clap_id paramId, double *outValue) const noexcept; bool paramsValueToText(clap_id paramId, double value, char *outBuffer, - uint32_t outBufferCapacity) const noexcept override; + uint32_t outBufferCapacity) const noexcept; bool paramsTextToValue(clap_id paramId, const char *paramValueText, - double *outValue) const noexcept override; - void paramsFlush(const clap_input_events_t *in, - const clap_output_events_t *out) const noexcept override; + double *outValue) const noexcept; + void paramsFlush(const clap_input_events_t *in, const clap_output_events_t *out) const noexcept; ////////////////////////////////// // clap_plugin_posix_fd_support // ////////////////////////////////// - bool canUsePosixFdSupport() const noexcept override; - void posixFdSupportOnFd(int fd, clap_posix_fd_flags_t flags) const noexcept override; + bool canUsePosixFdSupport() const noexcept; + void posixFdSupportOnFd(int fd, clap_posix_fd_flags_t flags) const noexcept; ///////////////////////////// // clap_plugin_preset_load // ///////////////////////////// - bool canUsePresetLoad() const noexcept override; + bool canUsePresetLoad() const noexcept; bool presetLoadFromLocation(uint32_t locationKind, const char *location, - const char *loadKey) const noexcept override; + const char *loadKey) const noexcept; ///////////////////////////////// // clap_plugin_remote_controls // ///////////////////////////////// - bool canUseRemoteControls() const noexcept override; - uint32_t remoteControlsCount() const noexcept override; - bool remoteControlsGet(uint32_t pageIndex, - clap_remote_controls_page_t *page) const noexcept override; + bool canUseRemoteControls() const noexcept; + uint32_t remoteControlsCount() const noexcept; + bool remoteControlsGet(uint32_t pageIndex, + clap_remote_controls_page_t *page) const noexcept; //////////////////////// // clap_plugin_render // //////////////////////// - bool canUseRender() const noexcept override; - bool renderHasHardRealtimeRequirement() const noexcept override; - bool renderSet(clap_plugin_render_mode mode) const noexcept override; + bool canUseRender() const noexcept; + bool renderHasHardRealtimeRequirement() const noexcept; + bool renderSet(clap_plugin_render_mode mode) const noexcept; /////////////////////// // clap_plugin_state // /////////////////////// - bool canUseState() const noexcept override; - bool stateSave(const clap_ostream_t *stream) const noexcept override; - bool stateLoad(const clap_istream_t *stream) const noexcept override; + bool canUseState() const noexcept; + bool stateSave(const clap_ostream_t *stream) const noexcept; + bool stateLoad(const clap_istream_t *stream) const noexcept; ////////////////////// // clap_plugin_tail // ////////////////////// - bool canUseTail() const noexcept override; - uint32_t tailGet() const noexcept override; + bool canUseTail() const noexcept; + uint32_t tailGet() const noexcept; ///////////////////////////// // clap_plugin_thread_pool // ///////////////////////////// - bool canUseThreadPool() const noexcept override; - void threadPoolExec(uint32_t taskIndex) const noexcept override; + bool canUseThreadPool() const noexcept; + void threadPoolExec(uint32_t taskIndex) const noexcept; /////////////////////////////// // clap_plugin_timer_support // /////////////////////////////// - bool canUseTimerSupport() const noexcept override; - void timerSupportOnTimer(clap_id timerId) const noexcept override; + bool canUseTimerSupport() const noexcept; + void timerSupportOnTimer(clap_id timerId) const noexcept; protected: ///////////////////// From 3ee56ecdde7ea3882b4563bb97a4d492f658433a Mon Sep 17 00:00:00 2001 From: Trinitou <106991375+Trinitou@users.noreply.github.com> Date: Fri, 9 Feb 2024 14:24:40 +0100 Subject: [PATCH 4/7] PresetDiscoveryProvider: fix error message (#53) --- include/clap/helpers/preset-discovery-provider.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/clap/helpers/preset-discovery-provider.hxx b/include/clap/helpers/preset-discovery-provider.hxx index 6af9798..e202178 100644 --- a/include/clap/helpers/preset-discovery-provider.hxx +++ b/include/clap/helpers/preset-discovery-provider.hxx @@ -48,7 +48,7 @@ namespace clap { namespace helpers { if (l >= CheckingLevel::Minimal) { if (self._isBeingDestroyed) { - std::cerr << "clap_preset_discovery_provider.init() was called twice" << std::endl; + std::cerr << "clap_preset_discovery_provider.destroy() was called twice" << std::endl; if (h == MisbehaviourHandler::Terminate) std::terminate(); return; @@ -95,4 +95,4 @@ namespace clap { namespace helpers { } } } -}} // namespace clap::helpers \ No newline at end of file +}} // namespace clap::helpers From 5d64e46be08ce20b6920a1de3de31a71962ff864 Mon Sep 17 00:00:00 2001 From: Trinitou <106991375+Trinitou@users.noreply.github.com> Date: Sat, 10 Feb 2024 14:16:02 +0100 Subject: [PATCH 5/7] Add instanciation test for PluginProxy (#56) --- tests/create-an-actual-host.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/create-an-actual-host.cc b/tests/create-an-actual-host.cc index c11196e..973d2fc 100644 --- a/tests/create-an-actual-host.cc +++ b/tests/create-an-actual-host.cc @@ -4,6 +4,8 @@ #include "clap/helpers/host.hh" #include "clap/helpers/host.hxx" +#include "clap/helpers/plugin-proxy.hh" +#include "clap/helpers/plugin-proxy.hxx" #include @@ -34,3 +36,14 @@ CATCH_TEST_CASE("Create an Actual Host") CATCH_REQUIRE(std::is_constructible::value); } } + +using test_plugin_proxy = clap::helpers::PluginProxy; + +CATCH_TEST_CASE("Create an Actual Plugin Proxy") +{ + CATCH_SECTION("Test Plugin Proxy is Creatable") + { + CATCH_REQUIRE(std::is_constructible::value); + } +} From ea88647873d22f8181940729507fee3b2a3db5bf Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 13 Feb 2024 12:41:51 -0500 Subject: [PATCH 6/7] Apply latency active patch (#59) Authored by David Schornsheim Reviewed by abique and me --- include/clap/helpers/plugin.hh | 1 + include/clap/helpers/plugin.hxx | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/clap/helpers/plugin.hh b/include/clap/helpers/plugin.hh index 28a1989..2ed3f32 100644 --- a/include/clap/helpers/plugin.hh +++ b/include/clap/helpers/plugin.hh @@ -550,6 +550,7 @@ namespace clap { namespace helpers { // state bool _wasInitialized = false; bool _isActive = false; + bool _isBeingActivated = false; bool _isProcessing = false; bool _isBeingDestroyed = false; double _sampleRate = 0; diff --git a/include/clap/helpers/plugin.hxx b/include/clap/helpers/plugin.hxx index c73aaaf..db8d4b2 100644 --- a/include/clap/helpers/plugin.hxx +++ b/include/clap/helpers/plugin.hxx @@ -319,12 +319,15 @@ namespace clap { namespace helpers { assert(!self._isActive); assert(self._sampleRate == 0); + self._isBeingActivated = true; if (!self.activate(sample_rate, minFrameCount, maxFrameCount)) { + self._isBeingActivated = false; assert(!self._isActive); assert(self._sampleRate == 0); return false; } + self._isBeingActivated = false; self._isActive = true; self._sampleRate = sample_rate; return true; @@ -506,7 +509,7 @@ namespace clap { namespace helpers { self.ensureMainThread("clap_plugin_latency.get"); if (l >= CheckingLevel::Minimal) { - if (!self._isActive) + if (!self._isActive && !self._isBeingActivated) self.hostMisbehaving("It is wrong to query the latency before the plugin is activated, " "because if the plugin dosen't know the sample rate, it can't " "know the number of samples of latency."); From a289f009b0da45caa7fcc0807b40f9658448ab08 Mon Sep 17 00:00:00 2001 From: Lucia Scarlet Date: Thu, 11 Apr 2024 18:46:28 +0200 Subject: [PATCH 7/7] Include to fix "std::terminate" errors --- include/clap/helpers/host-proxy.hxx | 1 + include/clap/helpers/plugin.hxx | 1 + 2 files changed, 2 insertions(+) diff --git a/include/clap/helpers/host-proxy.hxx b/include/clap/helpers/host-proxy.hxx index 42b069d..c91d5b4 100644 --- a/include/clap/helpers/host-proxy.hxx +++ b/include/clap/helpers/host-proxy.hxx @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include diff --git a/include/clap/helpers/plugin.hxx b/include/clap/helpers/plugin.hxx index db8d4b2..35d0159 100644 --- a/include/clap/helpers/plugin.hxx +++ b/include/clap/helpers/plugin.hxx @@ -1,5 +1,6 @@ #include #include +#include #include #include #include