mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Allow serializing CLAP plugin factory list message
This commit is contained in:
@@ -22,12 +22,12 @@
|
|||||||
|
|
||||||
ClapLogger::ClapLogger(Logger& generic_logger) : logger_(generic_logger) {}
|
ClapLogger::ClapLogger(Logger& generic_logger) : logger_(generic_logger) {}
|
||||||
|
|
||||||
// bool ClapLogger::log_request(bool is_host_plugin,
|
bool ClapLogger::log_request(bool is_host_plugin,
|
||||||
// const ClapPluginFactoryProxy::Construct&) {
|
const clap::plugin_factory::List&) {
|
||||||
// return log_request_base(is_host_plugin, [&](auto& message) {
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
||||||
// message << "GetPluginFactory()";
|
message << "clap_plugin_factory::list()";
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
bool ClapLogger::log_request(bool is_host_plugin, const WantsConfiguration&) {
|
bool ClapLogger::log_request(bool is_host_plugin, const WantsConfiguration&) {
|
||||||
return log_request_base(is_host_plugin, [&](auto& message) {
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
||||||
@@ -40,6 +40,19 @@ bool ClapLogger::log_request(bool is_host_plugin, const WantsConfiguration&) {
|
|||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
bool ClapLogger::log_response(
|
||||||
|
bool is_host_plugin,
|
||||||
|
const clap::plugin_factory::ListResponse& response) {
|
||||||
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
||||||
|
if (response.descriptors) {
|
||||||
|
message << "<clap_plugin_factory containing "
|
||||||
|
<< response.descriptors->size() << " plugin descriptors>";
|
||||||
|
} else {
|
||||||
|
message << "<not supported>";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void ClapLogger::log_response(bool is_host_plugin, const Configuration&) {
|
void ClapLogger::log_response(bool is_host_plugin, const Configuration&) {
|
||||||
log_response_base(is_host_plugin,
|
log_response_base(is_host_plugin,
|
||||||
[&](auto& message) { message << "<Configuration>"; });
|
[&](auto& message) { message << "<Configuration>"; });
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ class ClapLogger {
|
|||||||
// `log_request()` call returned `true`. This way we can filter out the
|
// `log_request()` call returned `true`. This way we can filter out the
|
||||||
// log message for the response together with the request.
|
// log message for the response together with the request.
|
||||||
|
|
||||||
// TODO: Main thread rquests
|
bool log_request(bool is_host_plugin, const clap::plugin_factory::List&);
|
||||||
// bool log_request(bool is_host_plugin,
|
|
||||||
// const ClapPluginFactoryProxy::Construct&);
|
|
||||||
|
|
||||||
// TODO: Audio thread requests
|
// TODO: Audio thread requests
|
||||||
// bool log_request(bool is_host_plugin,
|
// bool log_request(bool is_host_plugin,
|
||||||
@@ -55,11 +53,9 @@ class ClapLogger {
|
|||||||
|
|
||||||
bool log_request(bool is_host_plugin, const WantsConfiguration&);
|
bool log_request(bool is_host_plugin, const WantsConfiguration&);
|
||||||
|
|
||||||
// TOOD: Main thread responses
|
|
||||||
// void log_response(bool is_host_plugin, const Ack&);
|
// void log_response(bool is_host_plugin, const Ack&);
|
||||||
// void log_response(bool is_host_plugin,
|
bool log_response(bool is_host_plugin,
|
||||||
// const UniversalTResult&,
|
const clap::plugin_factory::ListResponse&);
|
||||||
// bool from_cache = false);
|
|
||||||
|
|
||||||
// TODO: Audio thread responses
|
// TODO: Audio thread responses
|
||||||
// void log_response(bool is_host_plugin,
|
// void log_response(bool is_host_plugin,
|
||||||
|
|||||||
@@ -36,8 +36,10 @@
|
|||||||
* request of type `ClapControlRequest(T)` should send back a `T::Response`.
|
* request of type `ClapControlRequest(T)` should send back a `T::Response`.
|
||||||
* These messages are for main thread functions.
|
* These messages are for main thread functions.
|
||||||
*/
|
*/
|
||||||
// TODO: Remove placeholder, add actual types
|
// FIXME: Remove the `WantsConfiguration`. For some reason bitsery just won't
|
||||||
using ClapMainThreadControlRequest = std::variant<WantsConfiguration>;
|
// serialize this without it.
|
||||||
|
using ClapMainThreadControlRequest =
|
||||||
|
std::variant<WantsConfiguration, clap::plugin_factory::List>;
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s, ClapMainThreadControlRequest& payload) {
|
void serialize(S& s, ClapMainThreadControlRequest& payload) {
|
||||||
@@ -117,13 +119,12 @@ struct ClapAudioThreadControlRequest {
|
|||||||
// TODO: Placeholder
|
// TODO: Placeholder
|
||||||
using ClapMainThreadCallbackRequest = std::variant<WantsConfiguration>;
|
using ClapMainThreadCallbackRequest = std::variant<WantsConfiguration>;
|
||||||
|
|
||||||
// TODO: Uncomment after changing `ClapMainThreadCallbackRequest`
|
template <typename S>
|
||||||
// template <typename S>
|
void serialize(S& s, ClapMainThreadCallbackRequest& payload) {
|
||||||
// void serialize(S& s, ClapMainThreadCallbackRequest& payload) {
|
// All of the objects in `ClapMainThreadCallbackRequest` should have their
|
||||||
// // All of the objects in `ClapMainThreadCallbackRequest` should have their own
|
// own serialization function.
|
||||||
// // serialization function.
|
s.ext(payload, bitsery::ext::InPlaceVariant{});
|
||||||
// s.ext(payload, bitsery::ext::InPlaceVariant{});
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the `std::variant<>` from an audio thread request object. This will
|
* Fetch the `std::variant<>` from an audio thread request object. This will
|
||||||
|
|||||||
@@ -26,21 +26,27 @@ namespace plugin_factory {
|
|||||||
/**
|
/**
|
||||||
* The response to the `clap::plugin_factory::list` message defined below.
|
* The response to the `clap::plugin_factory::list` message defined below.
|
||||||
*/
|
*/
|
||||||
struct list_response {
|
struct ListResponse {
|
||||||
std::vector<clap::plugin::descriptor> descriptors;
|
/**
|
||||||
|
* The descriptors for the plugins in the factory. This will be a nullopt if
|
||||||
|
* the plugin does not support the plugin factory.
|
||||||
|
*/
|
||||||
|
std::optional<std::vector<clap::plugin::descriptor>> descriptors;
|
||||||
|
|
||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s) {
|
void serialize(S& s) {
|
||||||
s.container(descriptors, 8192);
|
s.ext(descriptors, bitsery::ext::InPlaceOptional{},
|
||||||
|
[](S& s, auto& v) { s.container(v, 8192); });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Message combining `clap_plugin_factory::count()` with
|
* Message combining `clap_plugin_factory::count()` with
|
||||||
* `clap_plugin_factory::get()` to get all plugin descriptors in one go.
|
* `clap_plugin_factory::get()` to get all plugin descriptors in one go. Will
|
||||||
|
* return a nullopt if the plugin does not support the plugin factory.
|
||||||
*/
|
*/
|
||||||
struct list {
|
struct List {
|
||||||
using Response = list_response;
|
using Response = ListResponse;
|
||||||
|
|
||||||
// Since we send this to a specific CLAP plugin library, there are no
|
// Since we send this to a specific CLAP plugin library, there are no
|
||||||
// parameters here
|
// parameters here
|
||||||
|
|||||||
@@ -70,16 +70,21 @@ bool ClapBridge::inhibits_event_loop() noexcept {
|
|||||||
void ClapBridge::run() {
|
void ClapBridge::run() {
|
||||||
set_realtime_priority(true);
|
set_realtime_priority(true);
|
||||||
|
|
||||||
// TODO: Listen on the socket
|
sockets_.host_plugin_main_thread_control_.receive_messages(
|
||||||
// sockets_.host_plugin_control_.receive_messages(
|
std::nullopt,
|
||||||
// std::nullopt,
|
overload{
|
||||||
// overload{
|
[&](const WantsConfiguration&) -> WantsConfiguration::Response {
|
||||||
// [&](const ClapPluginFactoryProxy::Construct&)
|
// FIXME: This overload shouldn't be here, but
|
||||||
// -> ClapPluginFactoryProxy::Construct::Response {
|
// bitsery simply won't allow us to serialize the
|
||||||
// return ClapPluginFactoryProxy::ConstructArgs(
|
// variant without it.
|
||||||
// module_->getFactory().get());
|
return {};
|
||||||
// },
|
},
|
||||||
// });
|
[&](const clap::plugin_factory::List&)
|
||||||
|
-> clap::plugin_factory::List::Response {
|
||||||
|
// FIXME: Actually load this
|
||||||
|
return clap::plugin_factory::ListResponse{};
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement this
|
// TODO: Implement this
|
||||||
|
|||||||
Reference in New Issue
Block a user