mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Rename the VST3 mutual recursion functions
This commit is contained in:
@@ -355,12 +355,11 @@ void Vst3Bridge::run() {
|
|||||||
// much slower in Ardour, but there's no other non-hacky
|
// much slower in Ardour, but there's no other non-hacky
|
||||||
// solution for this (and bypassing Ardour's connection
|
// solution for this (and bypassing Ardour's connection
|
||||||
// proxies sort of goes against the idea behind yabridge)
|
// proxies sort of goes against the idea behind yabridge)
|
||||||
return do_mutual_recursion_or_handle_in_main_context<tresult>(
|
return do_mutual_recursion_on_gui_thread<tresult>([&]() {
|
||||||
[&]() {
|
return object_instances[request.instance_id]
|
||||||
return object_instances[request.instance_id]
|
.connection_point->notify(
|
||||||
.connection_point->notify(
|
request.message_ptr.get_original());
|
||||||
request.message_ptr.get_original());
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
[&](YaContextMenuTarget::ExecuteMenuItem& request)
|
[&](YaContextMenuTarget::ExecuteMenuItem& request)
|
||||||
-> YaContextMenuTarget::ExecuteMenuItem::Response {
|
-> YaContextMenuTarget::ExecuteMenuItem::Response {
|
||||||
@@ -781,11 +780,10 @@ void Vst3Bridge::run() {
|
|||||||
// not run from the GUI thread
|
// not run from the GUI thread
|
||||||
Steinberg::ViewRect size{};
|
Steinberg::ViewRect size{};
|
||||||
const tresult result =
|
const tresult result =
|
||||||
do_mutual_recursion_or_handle_in_main_context<tresult>(
|
do_mutual_recursion_on_gui_thread<tresult>([&]() {
|
||||||
[&]() {
|
return object_instances[request.owner_instance_id]
|
||||||
return object_instances[request.owner_instance_id]
|
.plug_view_instance->plug_view->getSize(&size);
|
||||||
.plug_view_instance->plug_view->getSize(&size);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return YaPlugView::GetSizeResponse{.result = result,
|
return YaPlugView::GetSizeResponse{.result = result,
|
||||||
.size = std::move(size)};
|
.size = std::move(size)};
|
||||||
@@ -800,12 +798,11 @@ void Vst3Bridge::run() {
|
|||||||
// code on the same thread that's currently waiting for a
|
// code on the same thread that's currently waiting for a
|
||||||
// response to the message it sent. See the docstring of
|
// response to the message it sent. See the docstring of
|
||||||
// this function for more information on how this works.
|
// this function for more information on how this works.
|
||||||
return do_mutual_recursion_or_handle_in_main_context<tresult>(
|
return do_mutual_recursion_on_gui_thread<tresult>([&]() {
|
||||||
[&]() {
|
return object_instances[request.owner_instance_id]
|
||||||
return object_instances[request.owner_instance_id]
|
.plug_view_instance->plug_view->onSize(
|
||||||
.plug_view_instance->plug_view->onSize(
|
&request.new_size);
|
||||||
&request.new_size);
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
[&](const YaPlugView::OnFocus& request)
|
[&](const YaPlugView::OnFocus& request)
|
||||||
-> YaPlugView::OnFocus::Response {
|
-> YaPlugView::OnFocus::Response {
|
||||||
@@ -848,21 +845,19 @@ void Vst3Bridge::run() {
|
|||||||
-> YaPlugView::CanResize::Response {
|
-> YaPlugView::CanResize::Response {
|
||||||
// To prevent weird behaviour we'll perform all size related
|
// To prevent weird behaviour we'll perform all size related
|
||||||
// functions from the GUI thread, including this one
|
// functions from the GUI thread, including this one
|
||||||
return do_mutual_recursion_or_handle_in_main_context<tresult>(
|
return do_mutual_recursion_on_gui_thread<tresult>([&]() {
|
||||||
[&]() {
|
return object_instances[request.owner_instance_id]
|
||||||
return object_instances[request.owner_instance_id]
|
.plug_view_instance->plug_view->canResize();
|
||||||
.plug_view_instance->plug_view->canResize();
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
[&](YaPlugView::CheckSizeConstraint& request)
|
[&](YaPlugView::CheckSizeConstraint& request)
|
||||||
-> YaPlugView::CheckSizeConstraint::Response {
|
-> YaPlugView::CheckSizeConstraint::Response {
|
||||||
const tresult result =
|
const tresult result =
|
||||||
do_mutual_recursion_or_handle_in_main_context<tresult>(
|
do_mutual_recursion_on_gui_thread<tresult>([&]() {
|
||||||
[&]() {
|
return object_instances[request.owner_instance_id]
|
||||||
return object_instances[request.owner_instance_id]
|
.plug_view_instance->plug_view->checkSizeConstraint(
|
||||||
.plug_view_instance->plug_view
|
&request.rect);
|
||||||
->checkSizeConstraint(&request.rect);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return YaPlugView::CheckSizeConstraintResponse{
|
return YaPlugView::CheckSizeConstraintResponse{
|
||||||
.result = result, .updated_rect = std::move(request.rect)};
|
.result = result, .updated_rect = std::move(request.rect)};
|
||||||
@@ -1311,11 +1306,11 @@ size_t Vst3Bridge::register_object_instance(
|
|||||||
// TODO: Check if this causes any issues when activating
|
// TODO: Check if this causes any issues when activating
|
||||||
// plugins while simultaneously resizing another
|
// plugins while simultaneously resizing another
|
||||||
// instance of the same plugin
|
// instance of the same plugin
|
||||||
return do_mutual_recursion_or_handle_in_main_context<
|
return do_mutual_recursion_on_gui_thread<tresult>(
|
||||||
tresult>([&]() {
|
[&]() {
|
||||||
return object_instances[request.instance_id]
|
return object_instances[request.instance_id]
|
||||||
.component->setActive(request.state);
|
.component->setActive(request.state);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[&](const YaPrefetchableSupport::GetPrefetchableSupport&
|
[&](const YaPrefetchableSupport::GetPrefetchableSupport&
|
||||||
request)
|
request)
|
||||||
|
|||||||
@@ -245,15 +245,15 @@ class Vst3Bridge : public HostBridge {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Spawn a new thread and call `send_message()` from there, and then handle
|
* Spawn a new thread and call `send_message()` from there, and then handle
|
||||||
* functions passed by calls to
|
* functions passed by calls to `do_mutual_recursion_on_gui_thread()` on
|
||||||
* `do_mutual_recursion_or_handle_in_main_context()` on this thread until
|
* this thread until the original message we're trying to send has
|
||||||
* the original message we're trying to send has succeeded. This is a very
|
* succeeded. This is a very specific solution to a very specific problem.
|
||||||
* specific solution to a very specific problem. When a plugin wants to
|
* When a plugin wants to resize itself, it will call
|
||||||
* resize itself, it will call `IPlugFrame::resizeView()` from within the
|
* `IPlugFrame::resizeView()` from within the WIn32 message loop. The host
|
||||||
* WIn32 message loop. The host will then call `IPlugView::onSize()` on the
|
* will then call `IPlugView::onSize()` on the plugin's `IPlugView` to
|
||||||
* plugin's `IPlugView` to actually resize the plugin. The issue is that
|
* actually resize the plugin. The issue is that that call to
|
||||||
* that call to `IPlugView::onSize()` has to be handled from the UI thread,
|
* `IPlugView::onSize()` has to be handled from the UI thread, but in this
|
||||||
* but in this sequence that thread is being blocked by a call to
|
* sequence that thread is being blocked by a call to
|
||||||
* `IPlugFrame::resizeView()`.
|
* `IPlugFrame::resizeView()`.
|
||||||
*
|
*
|
||||||
* We also need to use this for when a plugin calls
|
* We also need to use this for when a plugin calls
|
||||||
@@ -316,16 +316,16 @@ class Vst3Bridge : public HostBridge {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Crazy functions ask for crazy naming. This is the other part of
|
* Crazy functions ask for crazy naming. This is the other part of
|
||||||
* `send_mutually_recursive_message()`. If another thread is currently
|
* `send_mutually_recursive_message()`, for executing mutually recursive
|
||||||
* calling that function (from the UI thread), then we'll execute `f` from
|
* functions on the GUI thread. If another thread is currently calling that
|
||||||
* the UI thread using the IO context started in the above function.
|
* function (from the UI thread), then we'll execute `f` from the UI thread
|
||||||
* Otherwise `f` will be run on the UI thread through `main_context` as
|
* using the IO context started in the above function. Otherwise `f` will be
|
||||||
* usual.
|
* run on the UI thread through `main_context` as usual.
|
||||||
*
|
*
|
||||||
* @see Vst3Bridge::send_mutually_recursive_message
|
* @see Vst3Bridge::send_mutually_recursive_message
|
||||||
*/
|
*/
|
||||||
template <typename T, typename F>
|
template <typename T, typename F>
|
||||||
T do_mutual_recursion_or_handle_in_main_context(F f) {
|
T do_mutual_recursion_on_gui_thread(F f) {
|
||||||
std::packaged_task<T()> do_call(std::move(f));
|
std::packaged_task<T()> do_call(std::move(f));
|
||||||
std::future<T> do_call_response = do_call.get_future();
|
std::future<T> do_call_response = do_call.get_future();
|
||||||
|
|
||||||
@@ -355,10 +355,10 @@ class Vst3Bridge : public HostBridge {
|
|||||||
* The same as the above function, but we'll just execute the function on
|
* The same as the above function, but we'll just execute the function on
|
||||||
* this thread when the mutual recursion context is not active.
|
* this thread when the mutual recursion context is not active.
|
||||||
*
|
*
|
||||||
* @see Vst3Bridge::do_mutual_recursion_or_handle_in_main_context
|
* @see Vst3Bridge::do_mutual_recursion_on_gui_thread
|
||||||
*/
|
*/
|
||||||
template <typename T, typename F>
|
template <typename T, typename F>
|
||||||
T do_mutual_recursion(F f) {
|
T do_mutual_recursion_on_off_thread(F f) {
|
||||||
std::packaged_task<T()> do_call(std::move(f));
|
std::packaged_task<T()> do_call(std::move(f));
|
||||||
std::future<T> do_call_response = do_call.get_future();
|
std::future<T> do_call_response = do_call.get_future();
|
||||||
|
|
||||||
@@ -472,12 +472,12 @@ class Vst3Bridge : public HostBridge {
|
|||||||
std::mutex object_instances_mutex;
|
std::mutex object_instances_mutex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The IO contexts used in `send_mutually_recursive_message()` to be able to
|
* The IO contexts used in `Vst3Bridge::send_mutually_recursive_message()`
|
||||||
* execute functions from that same calling thread while we're waiting for a
|
* to be able to execute functions from that same calling thread while we're
|
||||||
* response. We need an entire stack of these to be able to handle nested
|
* waiting for a response. We need an entire stack of these to be able to
|
||||||
* mutually recursive function calls. See the docstring there for more
|
* handle nested mutually recursive function calls. See the docstring there
|
||||||
* information. When this doesn't contain an IO context, this function is
|
* for more information. When this doesn't contain an IO context, this
|
||||||
* not being called and `do_mutual_recursion_or_handle_in_main_context()`
|
* function is not being called and `do_mutual_recursion_on_gui_thread()`
|
||||||
* should post the task directly to the main IO context.
|
* should post the task directly to the main IO context.
|
||||||
*/
|
*/
|
||||||
std::vector<std::shared_ptr<boost::asio::io_context>>
|
std::vector<std::shared_ptr<boost::asio::io_context>>
|
||||||
|
|||||||
Reference in New Issue
Block a user