mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Implement start_processing, stop_processing, reset
This commit is contained in:
@@ -91,6 +91,27 @@ bool ClapLogger::log_request(bool is_host_plugin,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClapLogger::log_request(bool is_host_plugin,
|
||||||
|
const clap::plugin::StartProcessing& request) {
|
||||||
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
||||||
|
message << request.instance_id << ": clap_plugin::start_processing()";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClapLogger::log_request(bool is_host_plugin,
|
||||||
|
const clap::plugin::StopProcessing& request) {
|
||||||
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
||||||
|
message << request.instance_id << ": clap_plugin::stop_processing()";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClapLogger::log_request(bool is_host_plugin,
|
||||||
|
const clap::plugin::Reset& request) {
|
||||||
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
||||||
|
message << request.instance_id << ": clap_plugin::reset()";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
message << "Requesting <Configuration>";
|
message << "Requesting <Configuration>";
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ class ClapLogger {
|
|||||||
bool log_request(bool is_host_plugin, const clap::plugin::Activate&);
|
bool log_request(bool is_host_plugin, const clap::plugin::Activate&);
|
||||||
bool log_request(bool is_host_plugin, const clap::plugin::Deactivate&);
|
bool log_request(bool is_host_plugin, const clap::plugin::Deactivate&);
|
||||||
|
|
||||||
// TODO: Audio thread requests
|
bool log_request(bool is_host_plugin, const clap::plugin::StartProcessing&);
|
||||||
// bool log_request(bool is_host_plugin,
|
bool log_request(bool is_host_plugin, const clap::plugin::StopProcessing&);
|
||||||
// const YaAudioProcessor::SetBusArrangements&);
|
bool log_request(bool is_host_plugin, const clap::plugin::Reset&);
|
||||||
|
|
||||||
bool log_request(bool is_host_plugin, const WantsConfiguration&);
|
bool log_request(bool is_host_plugin, const WantsConfiguration&);
|
||||||
|
|
||||||
|
|||||||
@@ -76,8 +76,9 @@ struct ClapAudioThreadControlRequest {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
ClapAudioThreadControlRequest(T request) : payload(std::move(request)) {}
|
ClapAudioThreadControlRequest(T request) : payload(std::move(request)) {}
|
||||||
|
|
||||||
// TODO:
|
using Payload = std::variant<clap::plugin::StartProcessing,
|
||||||
using Payload = std::variant<WantsConfiguration>;
|
clap::plugin::StopProcessing,
|
||||||
|
clap::plugin::Reset>;
|
||||||
|
|
||||||
Payload payload;
|
Payload payload;
|
||||||
|
|
||||||
|
|||||||
@@ -108,8 +108,8 @@ clap_plugin_proxy::plugin_start_processing(const struct clap_plugin* plugin) {
|
|||||||
assert(plugin && plugin->plugin_data);
|
assert(plugin && plugin->plugin_data);
|
||||||
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
||||||
|
|
||||||
// TODO: Implement
|
return self->bridge_.send_audio_thread_message(
|
||||||
return false;
|
clap::plugin::StartProcessing{.instance_id = self->instance_id()});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLAP_ABI
|
void CLAP_ABI
|
||||||
@@ -117,7 +117,8 @@ clap_plugin_proxy::plugin_stop_processing(const struct clap_plugin* plugin) {
|
|||||||
assert(plugin && plugin->plugin_data);
|
assert(plugin && plugin->plugin_data);
|
||||||
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
||||||
|
|
||||||
// TODO: Implement
|
self->bridge_.send_audio_thread_message(
|
||||||
|
clap::plugin::StopProcessing{.instance_id = self->instance_id()});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLAP_ABI
|
void CLAP_ABI
|
||||||
@@ -125,7 +126,8 @@ clap_plugin_proxy::plugin_reset(const struct clap_plugin* plugin) {
|
|||||||
assert(plugin && plugin->plugin_data);
|
assert(plugin && plugin->plugin_data);
|
||||||
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
||||||
|
|
||||||
// TODO: Implement
|
self->bridge_.send_audio_thread_message(
|
||||||
|
clap::plugin::Reset{.instance_id = self->instance_id()});
|
||||||
}
|
}
|
||||||
|
|
||||||
clap_process_status CLAP_ABI
|
clap_process_status CLAP_ABI
|
||||||
|
|||||||
@@ -115,17 +115,15 @@ class ClapPluginBridge : PluginBridge<ClapSockets<std::jthread>> {
|
|||||||
object, std::pair<ClapLogger&, bool>(logger_, true));
|
object, std::pair<ClapLogger&, bool>(logger_, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Send an a message to a plugin instance's audio thread. This is
|
* Send an a message to a plugin instance's audio thread. This is separate
|
||||||
// separate
|
* from `send_message()`, which shares one socket for all plugin instances.
|
||||||
// * from `send_message()`, which shares one socket for all plugin
|
*/
|
||||||
// instances.
|
template <typename T>
|
||||||
// */
|
typename T::Response send_audio_thread_message(const T& object) {
|
||||||
// template <typename T>
|
return sockets_.send_audio_thread_message(
|
||||||
// typename T::Response send_audio_thread_message(const T& object) {
|
object, std::pair<ClapLogger&, bool>(logger_, true));
|
||||||
// return sockets_.send_audio_processor_message(
|
}
|
||||||
// object, std::pair<ClapLogger&, bool>(logger_, true));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Send an audio thread control message to a specific plugin instance,
|
// * Send an audio thread control message to a specific plugin instance,
|
||||||
|
|||||||
@@ -489,28 +489,49 @@ void ClapBridge::register_plugin_instance(
|
|||||||
|
|
||||||
// Every plugin instance gets its own audio thread
|
// Every plugin instance gets its own audio thread
|
||||||
std::promise<void> socket_listening_latch;
|
std::promise<void> socket_listening_latch;
|
||||||
object_instances_.at(instance_id)
|
object_instances_.at(instance_id).audio_thread_handler =
|
||||||
.audio_thread_handler = Win32Thread([&, instance_id]() {
|
Win32Thread([&, instance_id]() {
|
||||||
set_realtime_priority(true);
|
set_realtime_priority(true);
|
||||||
|
|
||||||
// XXX: Like with VST2 worker threads, when using plugin groups the
|
// XXX: Like with VST2 worker threads, when using plugin groups the
|
||||||
// thread names from different plugins will clash. Not a huge
|
// thread names from different plugins will clash. Not a huge
|
||||||
// deal probably, since duplicate thread names are still more
|
// deal probably, since duplicate thread names are still more
|
||||||
// useful than no thread names.
|
// useful than no thread names.
|
||||||
const std::string thread_name = "audio-" + std::to_string(instance_id);
|
const std::string thread_name =
|
||||||
pthread_setname_np(pthread_self(), thread_name.c_str());
|
"audio-" + std::to_string(instance_id);
|
||||||
|
pthread_setname_np(pthread_self(), thread_name.c_str());
|
||||||
|
|
||||||
sockets_.add_audio_thread_and_listen(
|
sockets_.add_audio_thread_and_listen(
|
||||||
instance_id, socket_listening_latch,
|
instance_id, socket_listening_latch,
|
||||||
overload{
|
overload{
|
||||||
[&](const WantsConfiguration&) -> WantsConfiguration::Response {
|
[&](const clap::plugin::StartProcessing& request)
|
||||||
// FIXME: This overload shouldn't be here, but
|
-> clap::plugin::StartProcessing::Response {
|
||||||
// bitsery simply won't allow us to serialize the
|
const auto& [instance, _] =
|
||||||
// variant without it.
|
get_instance(request.instance_id);
|
||||||
return {};
|
|
||||||
},
|
return instance.plugin->start_processing(
|
||||||
});
|
instance.plugin.get());
|
||||||
});
|
},
|
||||||
|
[&](const clap::plugin::StopProcessing& request)
|
||||||
|
-> clap::plugin::StopProcessing::Response {
|
||||||
|
const auto& [instance, _] =
|
||||||
|
get_instance(request.instance_id);
|
||||||
|
|
||||||
|
instance.plugin->stop_processing(instance.plugin.get());
|
||||||
|
|
||||||
|
return Ack{};
|
||||||
|
},
|
||||||
|
[&](const clap::plugin::Reset& request)
|
||||||
|
-> clap::plugin::Reset::Response {
|
||||||
|
const auto& [instance, _] =
|
||||||
|
get_instance(request.instance_id);
|
||||||
|
|
||||||
|
instance.plugin->reset(instance.plugin.get());
|
||||||
|
|
||||||
|
return Ack{};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Wait for the new socket to be listening on before continuing. Otherwise
|
// Wait for the new socket to be listening on before continuing. Otherwise
|
||||||
// the native plugin may try to connect to it before our thread is up and
|
// the native plugin may try to connect to it before our thread is up and
|
||||||
|
|||||||
Reference in New Issue
Block a user