Rename PluginContext to MainContext for clarity

This commit is contained in:
Robbert van der Helm
2020-10-28 01:02:56 +01:00
parent fac820c25a
commit bece654c2d
7 changed files with 47 additions and 46 deletions
+9 -9
View File
@@ -84,14 +84,14 @@ StdIoCapture::~StdIoCapture() {
GroupBridge::GroupBridge(boost::filesystem::path group_socket_path)
: logger(Logger::create_from_environment(
create_logger_prefix(group_socket_path))),
plugin_context(),
main_context(),
stdio_context(),
stdout_redirect(stdio_context, STDOUT_FILENO),
stderr_redirect(stdio_context, STDERR_FILENO),
group_socket_endpoint(group_socket_path.string()),
group_socket_acceptor(create_acceptor_if_inactive(plugin_context.context,
group_socket_acceptor(create_acceptor_if_inactive(main_context.context,
group_socket_endpoint)),
shutdown_timer(plugin_context.context) {
shutdown_timer(main_context.context) {
// Write this process's original STDOUT and STDERR streams to the logger
// TODO: This works for output generated by plugins, but not for debug
// messages generated by wineserver. Is it possible to catch those?
@@ -125,7 +125,7 @@ void GroupBridge::handle_plugin_dispatch(size_t plugin_id) {
// potentially corrupt our heap. This way we can also properly join the
// thread again. If no active plugins remain, then we'll terminate the
// process.
boost::asio::post(plugin_context.context, [this, plugin_id]() {
boost::asio::post(main_context.context, [this, plugin_id]() {
std::lock_guard lock(active_plugins_mutex);
// The join is implicit because we're using Win32Thread (which mimics
@@ -147,7 +147,7 @@ void GroupBridge::handle_plugin_dispatch(size_t plugin_id) {
if (active_plugins.size() == 0) {
logger.log(
"All plugins have exited, shutting down the group process");
plugin_context.stop();
main_context.stop();
}
});
}
@@ -158,7 +158,7 @@ void GroupBridge::handle_incoming_connections() {
logger.log(
"Group host is up and running, now accepting incoming connections");
plugin_context.run();
main_context.run();
}
bool GroupBridge::should_skip_message_loop() {
@@ -188,7 +188,7 @@ void GroupBridge::accept_requests() {
logger.log("Error while listening for incoming connections:");
logger.log(error.message());
plugin_context.stop();
main_context.stop();
}
// Read the parameters, and then host the plugin in this process
@@ -208,7 +208,7 @@ void GroupBridge::accept_requests() {
request.endpoint_base_dir + "'");
try {
auto bridge = std::make_unique<Vst2Bridge>(
plugin_context, request.plugin_path,
main_context, request.plugin_path,
request.endpoint_base_dir);
logger.log("Finished initializing '" + request.plugin_path +
"'");
@@ -235,7 +235,7 @@ void GroupBridge::accept_requests() {
}
void GroupBridge::async_handle_events() {
plugin_context.async_handle_events([&]() {
main_context.async_handle_events([&]() {
{
// Always handle X11 events
std::lock_guard lock(active_plugins_mutex);
+6 -6
View File
@@ -179,7 +179,7 @@ class GroupBridge {
* event handling and message loop interaction also has to be done from that
* thread, which is why we initialize the plugin here and use the
* `handle_dispatch()` function to run events within the same
* `plugin_context`.
* `main_context`.
*
* @see handle_plugin_dispatch
*/
@@ -217,13 +217,13 @@ class GroupBridge {
* operations that may involve the Win32 mesasge loop (e.g. initialization
* and most `AEffect::dispatcher()` calls) should be run on.
*/
PluginContext plugin_context;
MainContext main_context;
/**
* A seperate IO context that handles the STDIO redirect through
* `StdIoCapture`. This is seperated the `plugin_context` above so that
* STDIO capture does not get blocked by blocking GUI operations. Since
* every GUI related operation should be run from the same thread, we can't
* just add another thread to the main IO context.
* `StdIoCapture`. This is separated from the `main_context` above so that
* STDIO capture does not get blocked by GUI operations. Since every GUI
* related operation should be run from the same thread, we can't just add
* another thread to the main IO context.
*/
boost::asio::io_context stdio_context;
+4 -4
View File
@@ -66,13 +66,13 @@ Vst2Bridge& get_bridge_instance(const AEffect* plugin) {
return *static_cast<Vst2Bridge*>(plugin->ptr1);
}
Vst2Bridge::Vst2Bridge(PluginContext& main_context,
Vst2Bridge::Vst2Bridge(MainContext& main_context,
std::string plugin_dll_path,
std::string endpoint_base_dir)
: vst_plugin_path(plugin_dll_path),
plugin_context(main_context),
main_context(main_context),
plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary),
sockets(plugin_context.context, endpoint_base_dir, false) {
sockets(main_context.context, endpoint_base_dir, false) {
// Got to love these C APIs
if (!plugin_handle) {
throw std::runtime_error("Could not load the Windows .dll file at '" +
@@ -350,7 +350,7 @@ void Vst2Bridge::handle_dispatch() {
// and where the Win32 message loop is handled.
if (unsafe_opcodes.contains(opcode)) {
std::promise<intptr_t> dispatch_result;
boost::asio::dispatch(plugin_context.context, [&]() {
boost::asio::dispatch(main_context.context, [&]() {
const intptr_t result = dispatch_wrapper(
plugin, opcode, index, value, data, option);
+2 -2
View File
@@ -74,7 +74,7 @@ class Vst2Bridge {
* @throw std::runtime_error Thrown when the VST plugin could not be loaded,
* or if communication could not be set up.
*/
Vst2Bridge(PluginContext& main_context,
Vst2Bridge(MainContext& main_context,
std::string plugin_dll_path,
std::string endpoint_base_dir);
@@ -164,7 +164,7 @@ class Vst2Bridge {
* message handling can be performed from a single thread, even when hosting
* multiple plugins.
*/
PluginContext& plugin_context;
MainContext& main_context;
/**
* The configuration for this instance of yabridge based on the `.so` file