mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Add logging for CLAP extension queries
This commit is contained in:
@@ -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()";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<const clap_host_proxy*>(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
|
||||
|
||||
Reference in New Issue
Block a user