mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-15 21:15:51 +02:00
Also cache CLAP parameter infos
This commit is contained in:
+11
-18
@@ -60,8 +60,9 @@ bool ClapLogger::log_request(bool is_host_plugin,
|
||||
});
|
||||
}
|
||||
|
||||
bool ClapLogger::log_request(bool is_host_plugin,
|
||||
const clap::factory::plugin_factory::Create& request) {
|
||||
bool ClapLogger::log_request(
|
||||
bool is_host_plugin,
|
||||
const clap::factory::plugin_factory::Create& request) {
|
||||
return log_request_base(is_host_plugin, [&](auto& message) {
|
||||
message << "clap_plugin_factory::create(host = <clap_host_t*>, "
|
||||
"plugin_id = \""
|
||||
@@ -328,20 +329,12 @@ bool ClapLogger::log_request(
|
||||
});
|
||||
}
|
||||
|
||||
bool ClapLogger::log_request(bool is_host_plugin,
|
||||
const clap::ext::params::plugin::Count& request) {
|
||||
return log_request_base(is_host_plugin, [&](auto& message) {
|
||||
message << request.instance_id << ": clap_plugin_params::count()";
|
||||
});
|
||||
}
|
||||
|
||||
bool ClapLogger::log_request(
|
||||
bool is_host_plugin,
|
||||
const clap::ext::params::plugin::GetInfo& request) {
|
||||
const clap::ext::params::plugin::GetInfos& request) {
|
||||
return log_request_base(is_host_plugin, [&](auto& message) {
|
||||
message << request.instance_id
|
||||
<< ": clap_plugin_params::get_info(param_index = "
|
||||
<< request.param_index << ", *param_info)";
|
||||
<< ": clap_plugin_params::get_info(..., *param_info) (batched)";
|
||||
});
|
||||
}
|
||||
|
||||
@@ -942,13 +935,13 @@ void ClapLogger::log_response(
|
||||
|
||||
void ClapLogger::log_response(
|
||||
bool is_host_plugin,
|
||||
const clap::ext::params::plugin::GetInfoResponse& response) {
|
||||
const clap::ext::params::plugin::GetInfosResponse& response,
|
||||
bool from_cache) {
|
||||
log_response_base(is_host_plugin, [&](auto& message) {
|
||||
if (response.result) {
|
||||
message << "true, <clap_param_info_t* for \""
|
||||
<< response.result->name << "\">";
|
||||
} else {
|
||||
message << "false";
|
||||
message << "<clap_param_info_t*> for " << response.infos.size()
|
||||
<< " parameters";
|
||||
if (from_cache) {
|
||||
message << " (from cache)";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,8 +80,10 @@ class ClapLogger {
|
||||
// log message for the response together with the request.
|
||||
|
||||
// Main thread control messages
|
||||
bool log_request(bool is_host_plugin, const clap::factory::plugin_factory::List&);
|
||||
bool log_request(bool is_host_plugin, const clap::factory::plugin_factory::Create&);
|
||||
bool log_request(bool is_host_plugin,
|
||||
const clap::factory::plugin_factory::List&);
|
||||
bool log_request(bool is_host_plugin,
|
||||
const clap::factory::plugin_factory::Create&);
|
||||
bool log_request(bool is_host_plugin, const clap::plugin::Init&);
|
||||
bool log_request(bool is_host_plugin, const clap::plugin::Destroy&);
|
||||
bool log_request(bool is_host_plugin, const clap::plugin::Activate&);
|
||||
@@ -127,9 +129,7 @@ class ClapLogger {
|
||||
bool log_request(bool is_host_plugin,
|
||||
const clap::ext::note_ports::plugin::Get&);
|
||||
bool log_request(bool is_host_plugin,
|
||||
const clap::ext::params::plugin::Count&);
|
||||
bool log_request(bool is_host_plugin,
|
||||
const clap::ext::params::plugin::GetInfo&);
|
||||
const clap::ext::params::plugin::GetInfos&);
|
||||
bool log_request(bool is_host_plugin,
|
||||
const clap::ext::params::plugin::GetValue&);
|
||||
bool log_request(bool is_host_plugin,
|
||||
@@ -229,7 +229,8 @@ class ClapLogger {
|
||||
void log_response(bool is_host_plugin,
|
||||
const clap::ext::note_ports::plugin::GetResponse&);
|
||||
void log_response(bool is_host_plugin,
|
||||
const clap::ext::params::plugin::GetInfoResponse&);
|
||||
const clap::ext::params::plugin::GetInfosResponse&,
|
||||
bool from_cache = false);
|
||||
void log_response(bool is_host_plugin,
|
||||
const clap::ext::params::plugin::GetValueResponse&);
|
||||
void log_response(bool is_host_plugin,
|
||||
|
||||
@@ -83,8 +83,7 @@ using ClapMainThreadControlRequest =
|
||||
clap::ext::note_name::plugin::Get,
|
||||
clap::ext::note_ports::plugin::Count,
|
||||
clap::ext::note_ports::plugin::Get,
|
||||
clap::ext::params::plugin::Count,
|
||||
clap::ext::params::plugin::GetInfo,
|
||||
clap::ext::params::plugin::GetInfos,
|
||||
clap::ext::params::plugin::GetValue,
|
||||
clap::ext::params::plugin::ValueToText,
|
||||
clap::ext::params::plugin::TextToValue,
|
||||
|
||||
@@ -79,45 +79,41 @@ struct ParamInfo {
|
||||
namespace plugin {
|
||||
|
||||
/**
|
||||
* Message struct for `clap_plugin_params::count()`.
|
||||
*/
|
||||
struct Count {
|
||||
using Response = PrimitiveResponse<uint32_t>;
|
||||
|
||||
native_size_t instance_id;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The response to the `clap::ext::params::plugin::GetInfo` message defined
|
||||
* The response to the `clap::ext::params::plugin::GetInfos` message defined
|
||||
* below.
|
||||
*/
|
||||
struct GetInfoResponse {
|
||||
std::optional<ParamInfo> result;
|
||||
struct GetInfosResponse {
|
||||
/**
|
||||
* All of the plugin's parameter infos. If the plugin somehow returned an
|
||||
* error for a parameter that should be in range, then this contains a
|
||||
* nullopt value.
|
||||
*/
|
||||
std::vector<std::optional<ParamInfo>> infos;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.ext(result, bitsery::ext::InPlaceOptional());
|
||||
s.container(infos, 1 << 16, [](S& s, auto& v) {
|
||||
s.ext(v, bitsery::ext::InPlaceOptional{});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Message struct for `clap_plugin_params::get_info()`.
|
||||
* Message struct for querying the information for all parameters using
|
||||
* `clap_plugin_params::count()` and `clap_plugin_params::get_info()`. This
|
||||
* information is then cached until the plugin tells the host that the
|
||||
* parameters have changed. No specific plugins or hosts seem to require this at
|
||||
* the moment, but this mimics the behavior of the VST3 bridge which needed this
|
||||
* to work around a Kontakt bug.
|
||||
*/
|
||||
struct GetInfo {
|
||||
using Response = GetInfoResponse;
|
||||
struct GetInfos {
|
||||
using Response = GetInfosResponse;
|
||||
|
||||
native_size_t instance_id;
|
||||
uint32_t param_index;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.value4b(param_index);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user