diff --git a/src/common/logging/clap.cpp b/src/common/logging/clap.cpp index 549c771f..576f6071 100644 --- a/src/common/logging/clap.cpp +++ b/src/common/logging/clap.cpp @@ -24,6 +24,27 @@ ClapLogger::ClapLogger(Logger& generic_logger) : logger_(generic_logger) {} +void ClapLogger::log_extension_query(const char* where, + bool result, + const char* extension_id) { + if (logger_.verbosity_ >= Logger::Verbosity::all_events) [[unlikely]] { + assert(where && extension_id); + + std::ostringstream message; + if (result) { + message << "[extension query] " << where << "(extension_id = \"" + << extension_id << "\")"; + } else { + // TODO: DIfferentiate between extensions we don't implement and + // extensions the object doesn't implement + message << "[unknown extension] " << where << "(extension_id = \"" + << extension_id << "\")"; + } + + log(message.str()); + } +} + void ClapLogger::log_callback_request(size_t instance_id) { log_request_base(false, Logger::Verbosity::all_events, [&](auto& message) { message << instance_id << ": clap_host::request_callback()"; diff --git a/src/common/logging/clap.h b/src/common/logging/clap.h index 7d27eb34..9841818f 100644 --- a/src/common/logging/clap.h +++ b/src/common/logging/clap.h @@ -35,7 +35,22 @@ class ClapLogger { */ inline void log(const std::string& message) { logger_.log(message); } - // TODO: Logging for extension queries, factory type queries + /** + * Log calls to `clap_plugin::get_extension()` and + * `clap_host::get_extension()`. This makes it possible to tell which + * extensions the host or plugin is querying, and which of those we don't + * support yet. + * + * @param where The name of the function where this query occurred. In the + * format `clap_foo::get_extension`, without parentheses. This is a `const + * char*` to avoid allocations. + * @param result True if we returned an extension pointer, or false if we + * returned a null pointer. + * @param id The ID of the extension the plugin or host was trying to query. + */ + void log_extension_query(const char* where, + bool result, + const char* extension_id); /** * Logging for `clap_host::request_callback()`. This is handled purely on diff --git a/src/plugin/bridges/clap-impls/plugin-proxy.cpp b/src/plugin/bridges/clap-impls/plugin-proxy.cpp index 3031f65f..40bd0140 100644 --- a/src/plugin/bridges/clap-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/clap-impls/plugin-proxy.cpp @@ -174,12 +174,16 @@ clap_plugin_proxy::plugin_get_extension(const struct clap_plugin* plugin, // TODO: When implementing the GUI option, add a `clap_no_scaling` option to // disable HiDPI scaling just like we have for VST3. Or rename the // existing one. + const void* extension_ptr = nullptr; if (self->supported_extensions_.supports_audio_ports && strcmp(id, CLAP_EXT_AUDIO_PORTS) == 0) { - return &self->ext_audio_ports_vtable; - } else { - return nullptr; + extension_ptr = &self->ext_audio_ports_vtable; } + + self->bridge_.logger_.log_extension_query("clap_plugin::get_extension", + extension_ptr, id); + + return extension_ptr; } void CLAP_ABI diff --git a/src/wine-host/bridges/clap-impls/host-proxy.cpp b/src/wine-host/bridges/clap-impls/host-proxy.cpp index 65a12322..c00dd605 100644 --- a/src/wine-host/bridges/clap-impls/host-proxy.cpp +++ b/src/wine-host/bridges/clap-impls/host-proxy.cpp @@ -55,12 +55,16 @@ clap_host_proxy::host_get_extension(const struct clap_host* host, assert(host && host->host_data && extension_id); auto self = static_cast(host->host_data); + const void* extension_ptr = nullptr; if (self->supported_extensions_.supports_audio_ports && strcmp(extension_id, CLAP_EXT_AUDIO_PORTS) == 0) { - return &self->ext_audio_ports_vtable; - } else { - return nullptr; + extension_ptr = &self->ext_audio_ports_vtable; } + + self->bridge_.logger_.log_extension_query("clap_host::get_extension", + extension_ptr, extension_id); + + return extension_ptr; } void CLAP_ABI