From 0b9a16cf40f25870370033e369928a3416ef02e4 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 1 Jan 2022 21:07:17 +0100 Subject: [PATCH] Change the naming scheme for class field members I'm not a fan of Hungarian notation, but C++ kind of needs it with its implicit `this`. And of all the common options for this, I find suffixing members with an underscore the least offensive one. --- src/common/audio-shm.cpp | 42 +- src/common/audio-shm.h | 28 +- src/common/bitsery/ext/message-reference.h | 12 +- src/common/communication/common.h | 117 ++--- src/common/communication/vst2.h | 68 +-- src/common/communication/vst3.h | 80 +-- src/common/logging/common.cpp | 16 +- src/common/logging/common.h | 14 +- src/common/logging/vst2.cpp | 30 +- src/common/logging/vst2.h | 6 +- src/common/logging/vst3.cpp | 46 +- src/common/logging/vst3.h | 8 +- src/common/mutual-recursion.h | 23 +- src/common/plugins.h | 2 +- src/common/serialization/common.h | 10 +- src/common/serialization/vst2.cpp | 41 +- src/common/serialization/vst2.h | 23 +- .../serialization/vst3/attribute-list.cpp | 32 +- .../serialization/vst3/attribute-list.h | 16 +- src/common/serialization/vst3/base.cpp | 48 +- src/common/serialization/vst3/base.h | 22 +- src/common/serialization/vst3/bstream.cpp | 68 +-- src/common/serialization/vst3/bstream.h | 18 +- .../vst3/component-handler-proxy.cpp | 2 +- .../vst3/component-handler-proxy.h | 4 +- .../component-handler/component-handler-2.cpp | 2 +- .../component-handler/component-handler-2.h | 4 +- .../component-handler/component-handler-3.cpp | 2 +- .../component-handler/component-handler-3.h | 4 +- .../component-handler-bus-activation.cpp | 2 +- .../component-handler-bus-activation.h | 4 +- .../vst3/component-handler/progress.cpp | 2 +- .../vst3/component-handler/progress.h | 4 +- .../vst3/component-handler/unit-handler-2.cpp | 2 +- .../vst3/component-handler/unit-handler-2.h | 4 +- .../vst3/component-handler/unit-handler.cpp | 2 +- .../vst3/component-handler/unit-handler.h | 4 +- .../vst3/connection-point-proxy.cpp | 2 +- .../vst3/connection-point-proxy.h | 4 +- .../serialization/vst3/context-menu-proxy.cpp | 2 +- .../serialization/vst3/context-menu-proxy.h | 6 +- .../vst3/context-menu-target.cpp | 2 +- .../serialization/vst3/context-menu-target.h | 8 +- .../vst3/context-menu/context-menu.cpp | 2 +- .../vst3/context-menu/context-menu.h | 4 +- src/common/serialization/vst3/event-list.cpp | 20 +- src/common/serialization/vst3/event-list.h | 4 +- .../serialization/vst3/host-context-proxy.cpp | 2 +- .../serialization/vst3/host-context-proxy.h | 4 +- .../vst3/host-context/host-application.cpp | 2 +- .../vst3/host-context/host-application.h | 4 +- .../host-context/plug-interface-support.cpp | 5 +- .../host-context/plug-interface-support.h | 4 +- src/common/serialization/vst3/message.cpp | 30 +- src/common/serialization/vst3/message.h | 14 +- .../serialization/vst3/param-value-queue.cpp | 26 +- .../serialization/vst3/param-value-queue.h | 8 +- .../serialization/vst3/parameter-changes.cpp | 26 +- .../serialization/vst3/parameter-changes.h | 4 +- .../vst3/physical-ui-map-list.cpp | 10 +- .../serialization/vst3/physical-ui-map-list.h | 4 +- .../serialization/vst3/plug-frame-proxy.cpp | 2 +- .../serialization/vst3/plug-frame-proxy.h | 4 +- .../vst3/plug-frame/plug-frame.cpp | 2 +- .../vst3/plug-frame/plug-frame.h | 4 +- .../serialization/vst3/plug-view-proxy.cpp | 2 +- .../serialization/vst3/plug-view-proxy.h | 4 +- .../vst3/plug-view/parameter-finder.cpp | 2 +- .../vst3/plug-view/parameter-finder.h | 4 +- .../plug-view-content-scale-support.cpp | 2 +- .../plug-view-content-scale-support.h | 4 +- .../vst3/plug-view/plug-view.cpp | 2 +- .../serialization/vst3/plug-view/plug-view.h | 4 +- .../vst3/plugin-factory-proxy.cpp | 2 +- .../serialization/vst3/plugin-factory-proxy.h | 2 +- .../vst3/plugin-factory/plugin-factory.cpp | 26 +- .../vst3/plugin-factory/plugin-factory.h | 8 +- .../serialization/vst3/plugin-proxy.cpp | 50 +- src/common/serialization/vst3/plugin-proxy.h | 6 +- .../plugin/audio-presentation-latency.cpp | 2 +- .../vst3/plugin/audio-presentation-latency.h | 4 +- .../vst3/plugin/audio-processor.cpp | 2 +- .../vst3/plugin/audio-processor.h | 4 +- .../vst3/plugin/automation-state.cpp | 2 +- .../vst3/plugin/automation-state.h | 4 +- .../serialization/vst3/plugin/component.cpp | 2 +- .../serialization/vst3/plugin/component.h | 4 +- .../vst3/plugin/connection-point.cpp | 2 +- .../vst3/plugin/connection-point.h | 4 +- .../vst3/plugin/edit-controller-2.cpp | 2 +- .../vst3/plugin/edit-controller-2.h | 4 +- .../plugin/edit-controller-host-editing.cpp | 2 +- .../plugin/edit-controller-host-editing.h | 4 +- .../vst3/plugin/edit-controller.cpp | 2 +- .../vst3/plugin/edit-controller.h | 4 +- .../vst3/plugin/info-listener.cpp | 2 +- .../serialization/vst3/plugin/info-listener.h | 4 +- .../vst3/plugin/keyswitch-controller.cpp | 5 +- .../vst3/plugin/keyswitch-controller.h | 4 +- .../serialization/vst3/plugin/midi-learn.cpp | 2 +- .../serialization/vst3/plugin/midi-learn.h | 4 +- .../vst3/plugin/midi-mapping.cpp | 2 +- .../serialization/vst3/plugin/midi-mapping.h | 4 +- .../plugin/note-expression-controller.cpp | 2 +- .../vst3/plugin/note-expression-controller.h | 4 +- .../note-expression-physical-ui-mapping.cpp | 2 +- .../note-expression-physical-ui-mapping.h | 4 +- .../vst3/plugin/parameter-function-name.cpp | 5 +- .../vst3/plugin/parameter-function-name.h | 4 +- .../serialization/vst3/plugin/plugin-base.cpp | 2 +- .../serialization/vst3/plugin/plugin-base.h | 4 +- .../vst3/plugin/prefetchable-support.cpp | 5 +- .../vst3/plugin/prefetchable-support.h | 4 +- .../plugin/process-context-requirements.cpp | 2 +- .../plugin/process-context-requirements.h | 4 +- .../vst3/plugin/program-list-data.cpp | 2 +- .../vst3/plugin/program-list-data.h | 4 +- .../serialization/vst3/plugin/unit-data.cpp | 2 +- .../serialization/vst3/plugin/unit-data.h | 4 +- .../serialization/vst3/plugin/unit-info.cpp | 2 +- .../serialization/vst3/plugin/unit-info.h | 4 +- .../plugin/xml-representation-controller.cpp | 2 +- .../plugin/xml-representation-controller.h | 4 +- .../serialization/vst3/process-data.cpp | 135 +++--- src/common/serialization/vst3/process-data.h | 44 +- src/common/utils.cpp | 14 +- src/common/utils.h | 44 +- src/plugin/bridges/common.h | 161 +++--- src/plugin/bridges/vst2.cpp | 238 ++++----- src/plugin/bridges/vst2.h | 26 +- .../vst3-impls/context-menu-target.cpp | 9 +- .../bridges/vst3-impls/context-menu-target.h | 2 +- .../bridges/vst3-impls/plug-view-proxy.cpp | 116 ++--- .../bridges/vst3-impls/plug-view-proxy.h | 32 +- .../vst3-impls/plugin-factory-proxy.cpp | 29 +- .../bridges/vst3-impls/plugin-factory-proxy.h | 8 +- .../bridges/vst3-impls/plugin-proxy.cpp | 424 ++++++++-------- src/plugin/bridges/vst3-impls/plugin-proxy.h | 68 +-- src/plugin/bridges/vst3.cpp | 116 ++--- src/plugin/bridges/vst3.h | 38 +- src/plugin/host-process.cpp | 60 +-- src/plugin/host-process.h | 36 +- src/plugin/utils.cpp | 22 +- src/plugin/utils.h | 22 +- src/plugin/vst2-plugin.cpp | 2 +- src/wine-host/bridges/common.cpp | 12 +- src/wine-host/bridges/common.h | 12 +- src/wine-host/bridges/group.cpp | 129 ++--- src/wine-host/bridges/group.h | 54 +-- src/wine-host/bridges/vst2.cpp | 400 +++++++-------- src/wine-host/bridges/vst2.h | 50 +- .../vst3-impls/component-handler-proxy.cpp | 41 +- .../vst3-impls/component-handler-proxy.h | 2 +- .../vst3-impls/connection-point-proxy.cpp | 9 +- .../vst3-impls/connection-point-proxy.h | 2 +- .../bridges/vst3-impls/context-menu-proxy.cpp | 37 +- .../bridges/vst3-impls/context-menu-proxy.h | 6 +- .../bridges/vst3-impls/host-context-proxy.cpp | 18 +- .../bridges/vst3-impls/host-context-proxy.h | 2 +- .../bridges/vst3-impls/plug-frame-proxy.cpp | 11 +- .../bridges/vst3-impls/plug-frame-proxy.h | 2 +- src/wine-host/bridges/vst3.cpp | 101 ++-- src/wine-host/bridges/vst3.h | 48 +- src/wine-host/editor.cpp | 459 +++++++++--------- src/wine-host/editor.h | 94 ++-- src/wine-host/utils.cpp | 90 ++-- src/wine-host/utils.h | 85 ++-- src/wine-host/xdnd-proxy.cpp | 203 ++++---- src/wine-host/xdnd-proxy.h | 60 +-- 169 files changed, 2448 insertions(+), 2405 deletions(-) diff --git a/src/common/audio-shm.cpp b/src/common/audio-shm.cpp index 254b3e1c..b1c3111d 100644 --- a/src/common/audio-shm.cpp +++ b/src/common/audio-shm.cpp @@ -21,10 +21,10 @@ #include "logging/common.h" AudioShmBuffer::AudioShmBuffer(const Config& config) - : config(config), - shm(boost::interprocess::open_or_create, - config.name.c_str(), - boost::interprocess::read_write) { + : config_(config), + shm_(boost::interprocess::open_or_create, + config.name.c_str(), + boost::interprocess::read_write) { setup_mapping(); } @@ -32,35 +32,35 @@ AudioShmBuffer::~AudioShmBuffer() noexcept { // If either side drops this object then the buffer should always be // removed, so we'll do it on both sides to reduce the chance that we leak // shared memory - if (!is_moved) { - boost::interprocess::shared_memory_object::remove(config.name.c_str()); + if (!is_moved_) { + boost::interprocess::shared_memory_object::remove(config_.name.c_str()); } } AudioShmBuffer::AudioShmBuffer(AudioShmBuffer&& o) noexcept - : config(std::move(o.config)), - shm(std::move(o.shm)), - buffer(std::move(o.buffer)) { - o.is_moved = true; + : config_(std::move(o.config_)), + shm_(std::move(o.shm_)), + buffer_(std::move(o.buffer_)) { + o.is_moved_ = true; } AudioShmBuffer& AudioShmBuffer::operator=(AudioShmBuffer&& o) noexcept { - config = std::move(o.config); - shm = std::move(o.shm); - buffer = std::move(o.buffer); - o.is_moved = true; + config_ = std::move(o.config_); + shm_ = std::move(o.shm_); + buffer_ = std::move(o.buffer_); + o.is_moved_ = true; return *this; } void AudioShmBuffer::resize(const Config& new_config) { - if (new_config.name != config.name) { + if (new_config.name != config_.name) { throw std::invalid_argument("Expected buffer configuration for \"" + - config.name + "\", got \"" + + config_.name + "\", got \"" + new_config.name + "\""); } - config = new_config; + config_ = new_config; setup_mapping(); } @@ -68,10 +68,10 @@ void AudioShmBuffer::setup_mapping() { try { // Apparently you get a `Resource temporarily unavailable` when calling // `ftruncate()` with a size of 0 on shared memory - if (config.size > 0) { - shm.truncate(config.size); - buffer = boost::interprocess::mapped_region( - shm, boost::interprocess::read_write, 0, config.size, nullptr, + if (config_.size > 0) { + shm_.truncate(config_.size); + buffer_ = boost::interprocess::mapped_region( + shm_, boost::interprocess::read_write, 0, config_.size, nullptr, MAP_LOCKED); } } catch (const boost::interprocess::interprocess_exception& error) { diff --git a/src/common/audio-shm.h b/src/common/audio-shm.h index 91491f64..92f7d42c 100644 --- a/src/common/audio-shm.h +++ b/src/common/audio-shm.h @@ -135,11 +135,11 @@ class AudioShmBuffer { void resize(const Config& new_config); inline size_t num_input_channels(const uint32_t bus) const { - return config.input_offsets[bus].size(); + return config_.input_offsets[bus].size(); } inline size_t num_output_channels(const uint32_t bus) const { - return config.output_offsets[bus].size(); + return config_.output_offsets[bus].size(); } /** @@ -149,15 +149,15 @@ class AudioShmBuffer { */ template T* input_channel_ptr(const uint32_t bus, const uint32_t channel) noexcept { - return reinterpret_cast(buffer.get_address()) + - config.input_offsets[bus][channel]; + return reinterpret_cast(buffer_.get_address()) + + config_.input_offsets[bus][channel]; } template const T* input_channel_ptr(const uint32_t bus, const uint32_t channel) const noexcept { - return reinterpret_cast(buffer.get_address()) + - config.input_offsets[bus][channel]; + return reinterpret_cast(buffer_.get_address()) + + config_.input_offsets[bus][channel]; } /** @@ -167,18 +167,18 @@ class AudioShmBuffer { */ template T* output_channel_ptr(const uint32_t bus, const uint32_t channel) noexcept { - return reinterpret_cast(buffer.get_address()) + - config.output_offsets[bus][channel]; + return reinterpret_cast(buffer_.get_address()) + + config_.output_offsets[bus][channel]; } template const T* output_channel_ptr(const uint32_t bus, const uint32_t channel) const noexcept { - return reinterpret_cast(buffer.get_address()) + - config.output_offsets[bus][channel]; + return reinterpret_cast(buffer_.get_address()) + + config_.output_offsets[bus][channel]; } - Config config; + Config config_; private: /** @@ -186,8 +186,8 @@ class AudioShmBuffer { */ void setup_mapping(); - boost::interprocess::shared_memory_object shm; - boost::interprocess::mapped_region buffer; + boost::interprocess::shared_memory_object shm_; + boost::interprocess::mapped_region buffer_; - bool is_moved = false; + bool is_moved_ = false; }; diff --git a/src/common/bitsery/ext/message-reference.h b/src/common/bitsery/ext/message-reference.h index 426955c0..220f53f3 100644 --- a/src/common/bitsery/ext/message-reference.h +++ b/src/common/bitsery/ext/message-reference.h @@ -48,7 +48,7 @@ class MessageReference { * won't be touched. */ MessageReference(std::optional& backing_object) - : backing_object(backing_object){}; + : backing_object_(backing_object){}; template void serialize(Ser& ser, @@ -59,15 +59,15 @@ class MessageReference { template void deserialize(Des& des, ::MessageReference& object_ref, Fnc&&) const { - if (!backing_object) { - backing_object.emplace(); + if (!backing_object_) { + backing_object_.emplace(); } // Since we cannot directly deserialize into a reference, we'll // deserialize into this (persistent) backing object and then point the // reference to this object. - des.object(*backing_object); - object_ref = *backing_object; + des.object(*backing_object_); + object_ref = *backing_object_; } private: @@ -75,7 +75,7 @@ class MessageReference { * This contains the actual `T` we'll deserialize into so we can point the * reference to that object after deserializing. */ - std::optional& backing_object; + std::optional& backing_object_; }; } // namespace ext diff --git a/src/common/communication/common.h b/src/common/communication/common.h index 7bddb9cf..0390f18e 100644 --- a/src/common/communication/common.h +++ b/src/common/communication/common.h @@ -288,7 +288,7 @@ class Sockets { * @see Sockets::connect */ Sockets(const boost::filesystem::path& endpoint_base_dir) - : base_dir(endpoint_base_dir) {} + : base_dir_(endpoint_base_dir) {} /** * Shuts down and closes all sockets and then cleans up the directory @@ -306,14 +306,15 @@ class Sockets { // this should never be needed, but if it is, then I'm glad // we'll have it! const boost::filesystem::path temp_dir = get_temporary_directory(); - if (base_dir.string().starts_with(temp_dir.string())) { - boost::filesystem::remove_all(base_dir); + if (base_dir_.string().starts_with(temp_dir.string())) { + boost::filesystem::remove_all(base_dir_); } else { Logger logger = Logger::create_exception_logger(); logger.log(""); logger.log("WARNING: Unexpected socket base directory found,"); - logger.log(" not removing '" + base_dir.string() + "'"); + logger.log(" not removing '" + base_dir_.string() + + "'"); logger.log(""); } } catch (const boost::filesystem::filesystem_error&) { @@ -350,7 +351,7 @@ class Sockets { * The base directory for our socket endpoints. All `*_endpoint` variables * below are files within this directory. */ - const boost::filesystem::path base_dir; + const boost::filesystem::path base_dir_; }; /** @@ -373,11 +374,11 @@ class SocketHandler { SocketHandler(boost::asio::io_context& io_context, boost::asio::local::stream_protocol::endpoint endpoint, bool listen) - : endpoint(endpoint), socket(io_context) { + : endpoint_(endpoint), socket_(io_context) { if (listen) { boost::filesystem::create_directories( boost::filesystem::path(endpoint.path()).parent_path()); - acceptor.emplace(io_context, endpoint); + acceptor_.emplace(io_context, endpoint); } } @@ -387,10 +388,10 @@ class SocketHandler { * side or connect to the sockets on the Wine side. */ void connect() { - if (acceptor) { - acceptor->accept(socket); + if (acceptor_) { + acceptor_->accept(socket_); } else { - socket.connect(endpoint); + socket_.connect(endpoint_); } } @@ -401,9 +402,9 @@ class SocketHandler { void close() { // The shutdown can fail when the socket is already closed boost::system::error_code err; - socket.shutdown( + socket_.shutdown( boost::asio::local::stream_protocol::socket::shutdown_both, err); - socket.close(); + socket_.close(); } /** @@ -427,7 +428,7 @@ class SocketHandler { */ template inline void send(const T& object, SerializationBufferBase& buffer) { - write_object(socket, object, buffer); + write_object(socket_, object, buffer); } /** @@ -437,7 +438,7 @@ class SocketHandler { */ template inline void send(const T& object) { - write_object(socket, object); + write_object(socket_, object); } /** @@ -471,7 +472,7 @@ class SocketHandler { */ template inline T& receive_single(T& object, SerializationBufferBase& buffer) { - return read_object(socket, object, buffer); + return read_object(socket_, object, buffer); } /** @@ -482,7 +483,7 @@ class SocketHandler { */ template inline T receive_single() { - return read_object(socket); + return read_object(socket_); } /** @@ -521,14 +522,14 @@ class SocketHandler { } private: - boost::asio::local::stream_protocol::endpoint endpoint; - boost::asio::local::stream_protocol::socket socket; + boost::asio::local::stream_protocol::endpoint endpoint_; + boost::asio::local::stream_protocol::socket socket_; /** * Will be used in `connect()` on the listening side to establish the * connection. */ - std::optional acceptor; + std::optional acceptor_; }; /** @@ -574,11 +575,11 @@ class AdHocSocketHandler { AdHocSocketHandler(boost::asio::io_context& io_context, boost::asio::local::stream_protocol::endpoint endpoint, bool listen) - : io_context(io_context), endpoint(endpoint), socket(io_context) { + : io_context_(io_context), endpoint_(endpoint), socket_(io_context) { if (listen) { boost::filesystem::create_directories( boost::filesystem::path(endpoint.path()).parent_path()); - acceptor.emplace(io_context, endpoint); + acceptor_.emplace(io_context, endpoint); } } @@ -589,17 +590,17 @@ class AdHocSocketHandler { * side or connect to the sockets on the Wine side */ void connect() { - if (acceptor) { - acceptor->accept(socket); + if (acceptor_) { + acceptor_->accept(socket_); // As mentioned in `acceptor's` docstring, this acceptor will be // recreated in `receive_multi()` on another context, and // potentially on the other side of the connection in the case - // where we're handling `vst_host_callback` VST2 events - acceptor.reset(); - boost::filesystem::remove(endpoint.path()); + // where we're handling `vst_host_callback_` VST2 events + acceptor_.reset(); + boost::filesystem::remove(endpoint_.path()); } else { - socket.connect(endpoint); + socket_.connect(endpoint_); } } @@ -610,11 +611,11 @@ class AdHocSocketHandler { void close() { // The shutdown can fail when the socket is already closed boost::system::error_code err; - socket.shutdown( + socket_.shutdown( boost::asio::local::stream_protocol::socket::shutdown_both, err); - socket.close(); + socket_.close(); - while (currently_listening) { + while (currently_listening_) { // If another thread is currently calling `receive_multi()`, we'll // spinlock until that function has exited. We would otherwise get a // use-after-free when this object is destroyed from another thread. @@ -650,25 +651,25 @@ class AdHocSocketHandler { // ad hoc socket spawning mechanism gets used. If some hosts // for instance consistently and repeatedly trigger this then // we might be able to do some optimizations there. - std::unique_lock lock(write_mutex, std::try_to_lock); + std::unique_lock lock(write_mutex_, std::try_to_lock); if (lock.owns_lock()) { // This was used to always block when sending the first message, // because the other side may not be listening for additional // connections yet if constexpr (returns_void) { - callback(socket); - sent_first_event = true; + callback(socket_); + sent_first_event_ = true; } else { - auto result = callback(socket); - sent_first_event = true; + auto result = callback(socket_); + sent_first_event_ = true; return result; } } else { try { boost::asio::local::stream_protocol::socket secondary_socket( - io_context); - secondary_socket.connect(endpoint); + io_context_); + secondary_socket.connect(endpoint_); return callback(secondary_socket); } catch (const boost::system::system_error&) { @@ -684,15 +685,15 @@ class AdHocSocketHandler { // `connect()`. If we get here at any other point then it // means that the plugin side is no longer listening on the // sockets, and we should thus just exit. - if (!sent_first_event) { - std::lock_guard lock(write_mutex); + if (!sent_first_event_) { + std::lock_guard lock(write_mutex_); if constexpr (returns_void) { - callback(socket); - sent_first_event = true; + callback(socket_); + sent_first_event_ = true; } else { - auto result = callback(socket); - sent_first_event = true; + auto result = callback(socket_); + sent_first_event_ = true; return result; } @@ -728,8 +729,8 @@ class AdHocSocketHandler { // We use this flag to have the `close()` function wait for the this // function to exit, to prevent use-after-frees when destroying this // object from another thread. - assert(!currently_listening); - currently_listening = true; + assert(!currently_listening_); + currently_listening_ = true; // As described above we'll handle incoming requests for `socket` on // this thread. We'll also listen for incoming connections on `endpoint` @@ -741,7 +742,7 @@ class AdHocSocketHandler { // The previous acceptor has already been shut down by // `AdHocSocketHandler::connect()` - acceptor.emplace(secondary_context, endpoint); + acceptor_.emplace(secondary_context, endpoint_); // This works the exact same was as `active_plugins` and // `next_plugin_id` in `GroupBridge` @@ -749,7 +750,7 @@ class AdHocSocketHandler { std::atomic_size_t next_request_id{}; std::mutex active_secondary_requests_mutex{}; accept_requests( - *acceptor, logger, + *acceptor_, logger, [&](boost::asio::local::stream_protocol::socket secondary_socket) { const size_t request_id = next_request_id.fetch_add(1); @@ -786,7 +787,7 @@ class AdHocSocketHandler { // socket shuts down while (true) { try { - primary_callback(socket); + primary_callback(socket_); } catch (const boost::system::system_error&) { // This happens when the sockets got closed because the plugin // is being shut down @@ -799,9 +800,9 @@ class AdHocSocketHandler { // from the IO context std::lock_guard lock(active_secondary_requests_mutex); secondary_context.stop(); - acceptor.reset(); + acceptor_.reset(); - currently_listening = false; + currently_listening_ = false; } /** @@ -861,22 +862,22 @@ class AdHocSocketHandler { * bound to this context. In `receive_multi()` we'll create a new IO context * since we want to do all listening there on a dedicated thread. */ - boost::asio::io_context& io_context; + boost::asio::io_context& io_context_; - boost::asio::local::stream_protocol::endpoint endpoint; - boost::asio::local::stream_protocol::socket socket; + boost::asio::local::stream_protocol::endpoint endpoint_; + boost::asio::local::stream_protocol::socket socket_; /** * This acceptor will be used once synchronously on the listening side * during `Sockets::connect()`. When `AdHocSocketHandler::receive_multi()` * is then called, we'll recreate the acceptor to asynchronously listen for * new incoming socket connections on `endpoint` using. This is important, - * because on the case of `Vst2Sockets`'s' `vst_host_callback` the acceptor + * because on the case of `Vst2Sockets`'s' `vst_host_callback_` the acceptor * is first accepts an initial socket on the plugin side (like all sockets), * but all additional incoming connections of course have to be listened for * on the plugin side. */ - std::optional acceptor; + std::optional acceptor_; /** * After the socket gets closed, we do some cleanup at the end of @@ -886,13 +887,13 @@ class AdHocSocketHandler { * near instantly, we'll just do a spinlock here instead of using condition * variables. */ - std::atomic_bool currently_listening = false; + std::atomic_bool currently_listening_ = false; /** * A mutex that locks the primary `socket`. If this is locked, then any new * events will be sent over a new socket instead. */ - std::mutex write_mutex; + std::mutex write_mutex_; /** * Indicates whether or not the remove has processed an event we sent from @@ -901,5 +902,5 @@ class AdHocSocketHandler { * sockets, we want it to always wait for the sockets to come online, but * this fallback behaviour should only happen during initialization. */ - std::atomic_bool sent_first_event = false; + std::atomic_bool sent_first_event_ = false; }; diff --git a/src/common/communication/vst2.h b/src/common/communication/vst2.h index 7cf08f75..71e752a4 100644 --- a/src/common/communication/vst2.h +++ b/src/common/communication/vst2.h @@ -225,8 +225,9 @@ class Vst2EventHandler : public AdHocSocketHandler { } /** - * Spawn a new thread to listen for extra connections to `endpoint`, and - * then start a blocking loop that handles events from the primary `socket`. + * Spawn a new thread to listen for extra connections to `endpoint_`, and + * then start a blocking loop that handles events from the primary + * `socket_`. * * The specified function will be used to create an `Vst2EventResult` from * an `Vst2Event`. This is almost always uses `passthrough_event()`, which @@ -273,7 +274,7 @@ class Vst2EventHandler : public AdHocSocketHandler { }; this->receive_multi( - logging ? std::optional(std::ref(logging->first.logger)) + logging ? std::optional(std::ref(logging->first.logger_)) : std::nullopt, [&](boost::asio::local::stream_protocol::socket& socket) { process_event(socket, true); @@ -345,41 +346,42 @@ class Vst2Sockets final : public Sockets { const boost::filesystem::path& endpoint_base_dir, bool listen) : Sockets(endpoint_base_dir), - host_vst_dispatch(io_context, - (base_dir / "host_vst_dispatch.sock").string(), - listen), - vst_host_callback(io_context, - (base_dir / "vst_host_callback.sock").string(), - listen), - host_vst_parameters(io_context, - (base_dir / "host_vst_parameters.sock").string(), - listen), - host_vst_process_replacing( + host_vst_dispatch_(io_context, + (base_dir_ / "host_vst_dispatch.sock").string(), + listen), + vst_host_callback_(io_context, + (base_dir_ / "vst_host_callback_.sock").string(), + listen), + host_vst_parameters_( io_context, - (base_dir / "host_vst_process_replacing.sock").string(), + (base_dir_ / "host_vst_parameters.sock").string(), listen), - host_vst_control(io_context, - (base_dir / "host_vst_control.sock").string(), - listen) {} + host_vst_process_replacing_( + io_context, + (base_dir_ / "host_vst_process_replacing.sock").string(), + listen), + host_vst_control_(io_context, + (base_dir_ / "host_vst_control_.sock").string(), + listen) {} ~Vst2Sockets() noexcept override { close(); } void connect() override { - host_vst_dispatch.connect(); - vst_host_callback.connect(); - host_vst_parameters.connect(); - host_vst_process_replacing.connect(); - host_vst_control.connect(); + host_vst_dispatch_.connect(); + vst_host_callback_.connect(); + host_vst_parameters_.connect(); + host_vst_process_replacing_.connect(); + host_vst_control_.connect(); } void close() override { // Manually close all sockets so we break out of any blocking operations // that may still be active - host_vst_dispatch.close(); - vst_host_callback.close(); - host_vst_parameters.close(); - host_vst_process_replacing.close(); - host_vst_control.close(); + host_vst_dispatch_.close(); + vst_host_callback_.close(); + host_vst_parameters_.close(); + host_vst_process_replacing_.close(); + host_vst_control_.close(); } // The naming convention for these sockets is `__`. For @@ -391,29 +393,29 @@ class Vst2Sockets final : public Sockets { * The socket that forwards all `dispatcher()` calls from the VST host to * the plugin. */ - Vst2EventHandler host_vst_dispatch; + Vst2EventHandler host_vst_dispatch_; /** * The socket that forwards all `audioMaster()` calls from the Windows VST * plugin to the host. */ - Vst2EventHandler vst_host_callback; + Vst2EventHandler vst_host_callback_; /** * Used for both `getParameter` and `setParameter` since they mostly * overlap. */ - SocketHandler host_vst_parameters; + SocketHandler host_vst_parameters_; /** * Used for processing audio usign the `process()`, `processReplacing()` and * `processDoubleReplacing()` functions. */ - SocketHandler host_vst_process_replacing; + SocketHandler host_vst_process_replacing_; /** * A control socket that sends data that is not suitable for the other * sockets. At the moment this is only used to, on startup, send the Windows * VST plugin's `AEffect` object to the native VST plugin, and to then send - * the configuration (from `config`) back to the Wine host. + * the configuration (from `config_`) back to the Wine host. */ - SocketHandler host_vst_control; + SocketHandler host_vst_control_; }; /** diff --git a/src/common/communication/vst3.h b/src/common/communication/vst3.h index c003d5b9..27170ff4 100644 --- a/src/common/communication/vst3.h +++ b/src/common/communication/vst3.h @@ -264,10 +264,10 @@ class Vst3MessageHandler : public AdHocSocketHandler { get_request_variant(request)); }; - this->receive_multi(logging - ? std::optional(std::ref(logging->first.logger)) - : std::nullopt, - process_message); + this->receive_multi( + logging ? std::optional(std::ref(logging->first.logger_)) + : std::nullopt, + process_message); } }; @@ -314,31 +314,31 @@ class Vst3Sockets final : public Sockets { const boost::filesystem::path& endpoint_base_dir, bool listen) : Sockets(endpoint_base_dir), - host_vst_control(io_context, - (base_dir / "host_vst_control.sock").string(), - listen), - vst_host_callback(io_context, - (base_dir / "vst_host_callback.sock").string(), + host_vst_control_(io_context, + (base_dir_ / "host_vst_control_.sock").string(), listen), - io_context(io_context) {} + vst_host_callback_(io_context, + (base_dir_ / "vst_host_callback_.sock").string(), + listen), + io_context_(io_context) {} // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall) ~Vst3Sockets() noexcept override { close(); } void connect() override { - host_vst_control.connect(); - vst_host_callback.connect(); + host_vst_control_.connect(); + vst_host_callback_.connect(); } void close() override { // Manually close all sockets so we break out of any blocking operations // that may still be active - host_vst_control.close(); - vst_host_callback.close(); + host_vst_control_.close(); + vst_host_callback_.close(); // This map should be empty at this point, but who knows - std::lock_guard lock(audio_processor_sockets_mutex); - for (auto& [instance_id, socket] : audio_processor_sockets) { + std::lock_guard lock(audio_processor_sockets_mutex_); + for (auto& [instance_id, socket] : audio_processor_sockets_) { socket.close(); } } @@ -351,15 +351,15 @@ class Vst3Sockets final : public Sockets { * @param instance_id The object instance identifier of the socket. */ void add_audio_processor_and_connect(size_t instance_id) { - std::lock_guard lock(audio_processor_sockets_mutex); - audio_processor_sockets.try_emplace( - instance_id, io_context, - (base_dir / ("host_vst_audio_processor_" + - std::to_string(instance_id) + ".sock")) + std::lock_guard lock(audio_processor_sockets_mutex_); + audio_processor_sockets_.try_emplace( + instance_id, io_context_, + (base_dir_ / ("host_vst_audio_processor_" + + std::to_string(instance_id) + ".sock")) .string(), false); - audio_processor_sockets.at(instance_id).connect(); + audio_processor_sockets_.at(instance_id).connect(); } /** @@ -385,28 +385,28 @@ class Vst3Sockets final : public Sockets { std::promise& socket_listening_latch, F&& callback) { { - std::lock_guard lock(audio_processor_sockets_mutex); - audio_processor_sockets.try_emplace( - instance_id, io_context, - (base_dir / ("host_vst_audio_processor_" + - std::to_string(instance_id) + ".sock")) + std::lock_guard lock(audio_processor_sockets_mutex_); + audio_processor_sockets_.try_emplace( + instance_id, io_context_, + (base_dir_ / ("host_vst_audio_processor_" + + std::to_string(instance_id) + ".sock")) .string(), true); } socket_listening_latch.set_value(); - audio_processor_sockets.at(instance_id).connect(); + audio_processor_sockets_.at(instance_id).connect(); // This `true` indicates that we want to reuse our serialization and // receiving buffers for all calls. This slightly reduces the amount of // allocations in the audio processing loop. - audio_processor_sockets.at(instance_id) + audio_processor_sockets_.at(instance_id) .template receive_messages(std::nullopt, std::forward(callback)); } /** - * If `instance_id` is in `audio_processor_sockets`, then close its socket + * If `instance_id` is in `audio_processor_sockets_`, then close its socket * and remove it from the map. This is called from the destructor of * `Vst3PluginProxyImpl` on the plugin side and when handling * `Vst3PluginProxy::Destruct` on the Wine plugin host side. @@ -417,10 +417,10 @@ class Vst3Sockets final : public Sockets { * wasn't in the map. */ bool remove_audio_processor(size_t instance_id) { - std::lock_guard lock(audio_processor_sockets_mutex); - if (audio_processor_sockets.contains(instance_id)) { - audio_processor_sockets.at(instance_id).close(); - audio_processor_sockets.erase(instance_id); + std::lock_guard lock(audio_processor_sockets_mutex_); + if (audio_processor_sockets_.contains(instance_id)) { + audio_processor_sockets_.at(instance_id).close(); + audio_processor_sockets_.erase(instance_id); return true; } else { @@ -485,14 +485,14 @@ class Vst3Sockets final : public Sockets { * This will be listened on by the Wine plugin host when it calls * `receive_multi()`. */ - Vst3MessageHandler host_vst_control; + Vst3MessageHandler host_vst_control_; /** * For sending callbacks from the plugin back to the host. After we have a * better idea of what our communication model looks like we'll probably * want to provide an abstraction similar to `Vst2EventHandler`. */ - Vst3MessageHandler vst_host_callback; + Vst3MessageHandler vst_host_callback_; private: /** @@ -508,12 +508,12 @@ class Vst3Sockets final : public Sockets { std::optional> logging) { thread_local SerializationBuffer<256> audio_processor_buffer{}; - return audio_processor_sockets.at(instance_id) + return audio_processor_sockets_.at(instance_id) .receive_into(object, response_object, logging, audio_processor_buffer); } - boost::asio::io_context& io_context; + boost::asio::io_context& io_context_; /** * Every `IAudioProcessor` or `IComponent` instance (which likely implements @@ -528,6 +528,6 @@ class Vst3Sockets final : public Sockets { */ std::unordered_map> - audio_processor_sockets; - std::mutex audio_processor_sockets_mutex; + audio_processor_sockets_; + std::mutex audio_processor_sockets_mutex_; }; diff --git a/src/common/logging/common.cpp b/src/common/logging/common.cpp index 76568178..b68a1db9 100644 --- a/src/common/logging/common.cpp +++ b/src/common/logging/common.cpp @@ -51,11 +51,11 @@ Logger::Logger(std::shared_ptr stream, bool editor_tracing, std::string prefix, bool prefix_timestamp) - : verbosity(verbosity_level), - editor_tracing(editor_tracing), - stream(stream), - prefix(prefix), - prefix_timestamp(prefix_timestamp) {} + : verbosity_(verbosity_level), + editor_tracing_(editor_tracing), + stream_(stream), + prefix_(prefix), + prefix_timestamp_(prefix_timestamp) {} Logger Logger::create_from_environment(std::string prefix, std::shared_ptr stream, @@ -126,7 +126,7 @@ Logger Logger::create_exception_logger() { void Logger::log(const std::string& message) { std::ostringstream formatted_message; - if (prefix_timestamp) { + if (prefix_timestamp_) { const auto current_time = std::chrono::system_clock::now(); const time_t timestamp = std::chrono::system_clock::to_time_t(current_time); @@ -140,12 +140,12 @@ void Logger::log(const std::string& message) { formatted_message << std::put_time(&tm, "%T") << " "; } - formatted_message << prefix; + formatted_message << prefix_; formatted_message << message; // Flushing a stringstream doesn't do anything, but we need to put a // linefeed in this string stream rather writing it sprightly to the output // stream to prevent two messages from being put on the same row formatted_message << std::endl; - *stream << formatted_message.str() << std::flush; + *stream_ << formatted_message.str() << std::flush; } diff --git a/src/common/logging/common.h b/src/common/logging/common.h index e6a5a928..9b2035b1 100644 --- a/src/common/logging/common.h +++ b/src/common/logging/common.h @@ -195,7 +195,7 @@ class Logger { */ template F> void log_trace(F&& fn) { - if (verbosity >= Verbosity::all_events) [[unlikely]] { + if (verbosity_ >= Verbosity::all_events) [[unlikely]] { log(fn()); } } @@ -209,7 +209,7 @@ class Logger { */ template F> void log_editor_trace(F&& fn) { - if (editor_tracing) [[unlikely]] { + if (editor_tracing_) [[unlikely]] { log(fn()); } } @@ -218,28 +218,28 @@ class Logger { * The verbosity level of this logger instance. Based on this certain * messages may or may not be shown. */ - const Verbosity verbosity; + const Verbosity verbosity_; /** * If this is set to true, then we'll print debug traces for the plugin * editor. */ - const bool editor_tracing; + const bool editor_tracing_; private: /** * The output stream to write the log messages to. Typically either STDERR * or a file stream. */ - std::shared_ptr stream; + std::shared_ptr stream_; /** * A prefix that gets prepended before every message. */ - const std::string prefix; + const std::string prefix_; /** * Whether the log messages should be prefixed with a time stamp. */ - const bool prefix_timestamp; + const bool prefix_timestamp_; }; diff --git a/src/common/logging/vst2.cpp b/src/common/logging/vst2.cpp index 5d71e6c9..98ccca7a 100644 --- a/src/common/logging/vst2.cpp +++ b/src/common/logging/vst2.cpp @@ -18,7 +18,7 @@ #include -Vst2Logger::Vst2Logger(Logger& generic_logger) : logger(generic_logger) {} +Vst2Logger::Vst2Logger(Logger& generic_logger) : logger_(generic_logger) {} std::optional opcode_to_string(bool is_dispatch, int opcode) { if (is_dispatch) { @@ -333,7 +333,7 @@ std::optional opcode_to_string(bool is_dispatch, int opcode) { } void Vst2Logger::log_get_parameter(int index) { - if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] { + if (logger_.verbosity_ >= Logger::Verbosity::most_events) [[unlikely]] { std::ostringstream message; message << ">> getParameter() " << index; @@ -342,7 +342,7 @@ void Vst2Logger::log_get_parameter(int index) { } void Vst2Logger::log_get_parameter_response(float value) { - if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] { + if (logger_.verbosity_ >= Logger::Verbosity::most_events) [[unlikely]] { std::ostringstream message; message << " getParameter() :: " << value; @@ -351,7 +351,7 @@ void Vst2Logger::log_get_parameter_response(float value) { } void Vst2Logger::log_set_parameter(int index, float value) { - if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] { + if (logger_.verbosity_ >= Logger::Verbosity::most_events) [[unlikely]] { std::ostringstream message; message << ">> setParameter() " << index << " = " << value; @@ -360,7 +360,7 @@ void Vst2Logger::log_set_parameter(int index, float value) { } void Vst2Logger::log_set_parameter_response() { - if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] { + if (logger_.verbosity_ >= Logger::Verbosity::most_events) [[unlikely]] { log(" setParameter() :: OK"); } } @@ -373,7 +373,7 @@ void Vst2Logger::log_event( const Vst2Event::Payload& payload, float option, const std::optional& value_payload) { - if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] { + if (logger_.verbosity_ >= Logger::Verbosity::most_events) [[unlikely]] { if (should_filter_event(is_dispatch, opcode)) { return; } @@ -402,7 +402,7 @@ void Vst2Logger::log_event( overload{ [](const auto&) {}, [&](const DynamicSpeakerArrangement& speaker_arrangement) { - message << "<" << speaker_arrangement.speakers.size() + message << "<" << speaker_arrangement.speakers_.size() << " input_speakers>, "; }}, *value_payload); @@ -428,16 +428,16 @@ void Vst2Logger::log_event( }, [&](const AEffect&) { message << "nullptr"; }, [&](const DynamicVstEvents& events) { - message << "<" << events.events.size() << " midi_events"; - if (!events.sysex_data.empty()) { - message << ", including " << events.sysex_data.size() + message << "<" << events.events_.size() << " midi_events"; + if (!events.sysex_data_.empty()) { + message << ", including " << events.sysex_data_.size() << " sysex_events>"; } else { message << ">"; } }, [&](const DynamicSpeakerArrangement& speaker_arrangement) { - message << "<" << speaker_arrangement.speakers.size() + message << "<" << speaker_arrangement.speakers_.size() << " output_speakers>"; }, [&](const VstIOProperties&) { message << ""; }, @@ -469,7 +469,7 @@ void Vst2Logger::log_event_response( const Vst2EventResult::Payload& payload, const std::optional& value_payload, bool from_cache) { - if (logger.verbosity >= Logger::Verbosity::most_events) [[unlikely]] { + if (logger_.verbosity_ >= Logger::Verbosity::most_events) [[unlikely]] { if (should_filter_event(is_dispatch, opcode)) { return; } @@ -490,7 +490,7 @@ void Vst2Logger::log_event_response( overload{ [](const auto&) {}, [&](const DynamicSpeakerArrangement& speaker_arrangement) { - message << ", <" << speaker_arrangement.speakers.size() + message << ", <" << speaker_arrangement.speakers_.size() << " input_speakers>"; }}, *value_payload); @@ -518,7 +518,7 @@ void Vst2Logger::log_event_response( << " bytes>"; }, [&](const DynamicSpeakerArrangement& speaker_arrangement) { - message << ", <" << speaker_arrangement.speakers.size() + message << ", <" << speaker_arrangement.speakers_.size() << " output_speakers>"; }, [&](const VstIOProperties&) { message << ", "; }, @@ -550,7 +550,7 @@ void Vst2Logger::log_event_response( bool Vst2Logger::should_filter_event(bool is_dispatch, int opcode) const noexcept { - if (logger.verbosity >= Logger::Verbosity::all_events) { + if (logger_.verbosity_ >= Logger::Verbosity::all_events) { return false; } diff --git a/src/common/logging/vst2.h b/src/common/logging/vst2.h index 29fac12a..f82aeb65 100644 --- a/src/common/logging/vst2.h +++ b/src/common/logging/vst2.h @@ -44,7 +44,7 @@ class Vst2Logger { /** * @see Logger::log */ - inline void log(const std::string& message) { logger.log(message); } + inline void log(const std::string& message) { logger_.log(message); } // The following functions are for logging specific events, they are only // enabled for verbosity levels higher than 1 (i.e. `Verbosity::events`) @@ -75,13 +75,13 @@ class Vst2Logger { */ template F> inline void log_trace(F&& fn) { - logger.log_trace(std::forward(fn)); + logger_.log_trace(std::forward(fn)); } /** * The underlying logger instance we're wrapping. */ - Logger& logger; + Logger& logger_; private: /** diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index 987bf09a..556f7e77 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -29,10 +29,10 @@ std::string format_bstream(const YaBStream& stream) { std::ostringstream formatted; formatted << "keys_and_types()) { + const auto& key_type : stream.attributes_->keys_and_types()) { if (!first) { formatted << ", "; } @@ -42,27 +42,27 @@ std::string format_bstream(const YaBStream& stream) { } formatted << "] "; } - if (stream.file_name) { - formatted << "for \"" << VST3::StringConvert::convert(*stream.file_name) - << "\" "; + if (stream.file_name_) { + formatted << "for \"" + << VST3::StringConvert::convert(*stream.file_name_) << "\" "; } formatted << "containing " << stream.size() << " bytes>"; return formatted.str(); } -Vst3Logger::Vst3Logger(Logger& generic_logger) : logger(generic_logger) {} +Vst3Logger::Vst3Logger(Logger& generic_logger) : logger_(generic_logger) {} void Vst3Logger::log_query_interface( const char* where, tresult result, const std::optional& uid) { - if (logger.verbosity >= Logger::Verbosity::all_events) [[unlikely]] { + if (logger_.verbosity_ >= Logger::Verbosity::all_events) [[unlikely]] { std::ostringstream message; std::string uid_string = uid ? format_uid(*uid) : ""; if (result == Steinberg::kResultOk) { - if (logger.verbosity >= Logger::Verbosity::most_events) { + if (logger_.verbosity_ >= Logger::Verbosity::most_events) { message << "[query interface] " << where << ": " << uid_string; log(message.str()); } @@ -518,7 +518,7 @@ bool Vst3Logger::log_request( "busIndex = " << request.bus_index << ", channel = " << request.channel << ", list = "; - for (bool first = true; const auto& mapping : request.list.maps) { + for (bool first = true; const auto& mapping : request.list.maps_) { if (!first) { message << ", "; } @@ -1012,7 +1012,7 @@ bool Vst3Logger::log_request( std::ostringstream num_input_channels; num_input_channels << "["; for (bool is_first = true; - const auto& buffers : request.data.inputs) { + const auto& buffers : request.data.inputs_) { num_input_channels << (is_first ? "" : ", ") << buffers.numChannels; if (buffers.silenceFlags > 0 && @@ -1029,7 +1029,7 @@ bool Vst3Logger::log_request( std::ostringstream num_output_channels; num_output_channels << "["; for (bool is_first = true; - const auto& buffers : request.data.outputs) { + const auto& buffers : request.data.outputs_) { num_output_channels << (is_first ? "" : ", ") << buffers.numChannels; if (buffers.silenceFlags > 0 && @@ -1048,30 +1048,30 @@ bool Vst3Logger::log_request( "input_channels = " << num_input_channels.str() << ", output_channels = " << num_output_channels.str() - << ", num_samples = " << request.data.num_samples + << ", num_samples = " << request.data.num_samples_ << ", input_parameter_changes = , output_parameter_changes = " - << (request.data.output_parameter_changes + << (request.data.output_parameter_changes_ ? "" : "nullptr") << ", input_events = "; - if (request.data.input_events) { + if (request.data.input_events_) { message << "num_events() + << request.data.input_events_->num_events() << " events>"; } else { message << ""; } message << ", output_events = " - << (request.data.output_events ? "" - : "") + << (request.data.output_events_ ? "" + : "") << ", process_context = " - << (request.data.process_context ? "" - : "") - << ", process_mode = " << request.data.process_mode + << (request.data.process_context_ ? "" + : "") + << ", process_mode = " << request.data.process_mode_ << ", symbolic_sample_size = " - << request.data.symbolic_sample_size << ">)"; + << request.data.symbolic_sample_size_ << ">)"; }); } @@ -1607,7 +1607,7 @@ void Vst3Logger::log_response( message << response.result.string(); if (response.result == Steinberg::kResultOk) { message << ", ["; - for (bool first = true; const auto& mapping : response.list.maps) { + for (bool first = true; const auto& mapping : response.list.maps_) { if (!first) { message << ", "; } diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index 20f62bb6..2df3095e 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -35,7 +35,7 @@ class Vst3Logger { /** * @see Logger::log */ - inline void log(const std::string& message) { logger.log(message); } + inline void log(const std::string& message) { logger_.log(message); } /** * Log calls to `FUnknown::queryInterface`. This will separately log about @@ -350,10 +350,10 @@ class Vst3Logger { */ template F> inline void log_trace(F&& fn) { - logger.log_trace(std::forward(fn)); + logger_.log_trace(std::forward(fn)); } - Logger& logger; + Logger& logger_; private: /** @@ -367,7 +367,7 @@ class Vst3Logger { bool log_request_base(bool is_host_vst, Logger::Verbosity min_verbosity, F callback) { - if (logger.verbosity >= min_verbosity) [[unlikely]] { + if (logger_.verbosity_ >= min_verbosity) [[unlikely]] { std::ostringstream message; if (is_host_vst) { message << "[host -> vst] >> "; diff --git a/src/common/mutual-recursion.h b/src/common/mutual-recursion.h index f9532b4a..13af9fab 100644 --- a/src/common/mutual-recursion.h +++ b/src/common/mutual-recursion.h @@ -86,8 +86,8 @@ class MutualRecursionHelper { std::shared_ptr current_io_context = std::make_shared(); { - std::unique_lock lock(mutual_recursion_contexts_mutex); - mutual_recursion_contexts.push_back(current_io_context); + std::unique_lock lock(mutual_recursion_contexts_mutex_); + mutual_recursion_contexts_.push_back(current_io_context); } // Instead of directly stopping the IO context, we'll reset this work @@ -106,11 +106,11 @@ class MutualRecursionHelper { // the other side). By resetting the work guard we do not cancel any // pending tasks, but `current_io_context->run()` will stop blocking // eventually. - std::lock_guard lock(mutual_recursion_contexts_mutex); + std::lock_guard lock(mutual_recursion_contexts_mutex_); work_guard.reset(); - mutual_recursion_contexts.erase( - std::find(mutual_recursion_contexts.begin(), - mutual_recursion_contexts.end(), current_io_context)); + mutual_recursion_contexts_.erase(std::find( + mutual_recursion_contexts_.begin(), + mutual_recursion_contexts_.end(), current_io_context)); response_promise.set_value(response); }); @@ -158,8 +158,9 @@ class MutualRecursionHelper { std::optional> maybe_handle(F&& fn) { using Result = std::invoke_result_t; - std::unique_lock mutual_recursion_lock(mutual_recursion_contexts_mutex); - if (mutual_recursion_contexts.empty()) { + std::unique_lock mutual_recursion_lock( + mutual_recursion_contexts_mutex_); + if (mutual_recursion_contexts_.empty()) { return std::nullopt; } @@ -167,7 +168,7 @@ class MutualRecursionHelper { // pretend that we're not doing any async things here std::packaged_task do_call(std::forward(fn)); std::future do_call_response = do_call.get_future(); - boost::asio::dispatch(*mutual_recursion_contexts.back(), + boost::asio::dispatch(*mutual_recursion_contexts_.back(), std::move(do_call)); mutual_recursion_lock.unlock(); @@ -186,6 +187,6 @@ class MutualRecursionHelper { * recursion going on. */ std::vector> - mutual_recursion_contexts; - std::mutex mutual_recursion_contexts_mutex; + mutual_recursion_contexts_; + std::mutex mutual_recursion_contexts_mutex_; }; diff --git a/src/common/plugins.h b/src/common/plugins.h index 4aeed74e..c22bd047 100644 --- a/src/common/plugins.h +++ b/src/common/plugins.h @@ -31,7 +31,7 @@ enum class LibArchitecture { dll_32, dll_64 }; /** * A tag to differentiate between different plugin types. - * `plugin_tyep_to_string()` and `plugin_type_from_string()` can be used to + * `plugin_type_to_string()` and `plugin_type_from_string()` can be used to * convert these values to and from strings. The string form is used as a * command line argument for the individual Wine host applications, and the enum * form is passed directly in `HostRequest`. diff --git a/src/common/serialization/common.h b/src/common/serialization/common.h index 3df3b150..138c12cd 100644 --- a/src/common/serialization/common.h +++ b/src/common/serialization/common.h @@ -115,12 +115,12 @@ class MessageReference { * `0x1337420` so it's at least obvious where it's coming from if we get a * segfault caused by a read to that address. */ - MessageReference() noexcept : object(reinterpret_cast(0x1337420)) {} + MessageReference() noexcept : object_(reinterpret_cast(0x1337420)) {} /** * Store a reference in this object. */ - MessageReference(T& object) noexcept : object(&object) {} + MessageReference(T& object) noexcept : object_(&object) {} using Response = typename T::Response; @@ -128,12 +128,12 @@ class MessageReference { * Get the reference to the object. This is the same interface as * `std::reference_wrapper`. */ - T& get() const noexcept { return *object; } - constexpr operator T&() const noexcept { return *object; } + T& get() const noexcept { return *object_; } + constexpr operator T&() const noexcept { return *object_; } // You cannot serialize a reference directly, use the Bitsery extension // mentioned above instead private: - T* object; + T* object_; }; diff --git a/src/common/serialization/vst2.cpp b/src/common/serialization/vst2.cpp index 85b84a95..6b33de10 100644 --- a/src/common/serialization/vst2.cpp +++ b/src/common/serialization/vst2.cpp @@ -37,17 +37,17 @@ AEffect& update_aeffect(AEffect& plugin, DynamicVstEvents::DynamicVstEvents() noexcept {} DynamicVstEvents::DynamicVstEvents(const VstEvents& c_events) - : events(c_events.numEvents) { + : events_(c_events.numEvents) { // Copy from the C-style array into a vector for serialization for (int i = 0; i < c_events.numEvents; i++) { - events[i] = *c_events.events[i]; + events_[i] = *c_events.events[i]; // If we encounter a SysEx event, also store the payload data in an // associative list (so we can potentially still avoid allocations) const auto sysex_event = reinterpret_cast(c_events.events[i]); if (sysex_event->type == kVstSysExType) { - sysex_data.emplace_back( + sysex_data_.emplace_back( i, std::string(sysex_event->sysexDump, sysex_event->byteSize)); } } @@ -58,9 +58,9 @@ VstEvents& DynamicVstEvents::as_c_events() { // `VstEvents` struct by hand on the heap since it's actually a dynamically // sized object. If we encountered any SysEx events, then we'll need to // update the pointers in `events` to point to the correct data location. - for (const auto& [event_idx, data] : sysex_data) { + for (const auto& [event_idx, data] : sysex_data_) { auto& sysex_event = - reinterpret_cast(events[event_idx]); + reinterpret_cast(events_[event_idx]); sysex_event.sysexDump = const_cast(data.data()); } @@ -72,16 +72,16 @@ VstEvents& DynamicVstEvents::as_c_events() { static_assert(std::extent_v == 1); const size_t buffer_size = sizeof(VstEvents) + - ((events.size() - 1) * + ((events_.size() - 1) * sizeof(VstEvent*)); // NOLINT(bugprone-sizeof-expression) - vst_events_buffer.resize(buffer_size); + vst_events_buffer_.resize(buffer_size); // Now we can populate the VLA with pointers to the objects in the `events` // vector VstEvents* vst_events = - reinterpret_cast(vst_events_buffer.data()); - vst_events->numEvents = static_cast(events.size()); - std::transform(events.begin(), events.end(), vst_events->events, + reinterpret_cast(vst_events_buffer_.data()); + vst_events->numEvents = static_cast(events_.size()); + std::transform(events_.begin(), events_.end(), vst_events->events, [](VstEvent& event) -> VstEvent* { return &event; }); return *vst_events; @@ -91,10 +91,10 @@ DynamicSpeakerArrangement::DynamicSpeakerArrangement() noexcept {} DynamicSpeakerArrangement::DynamicSpeakerArrangement( const VstSpeakerArrangement& speaker_arrangement) - : flags(speaker_arrangement.flags), - speakers(speaker_arrangement.num_speakers) { + : flags_(speaker_arrangement.flags), + speakers_(speaker_arrangement.num_speakers) { // Copy from the C-style array into a vector for serialization - speakers.assign( + speakers_.assign( &speaker_arrangement.speakers[0], &speaker_arrangement.speakers[speaker_arrangement.num_speakers]); } @@ -106,17 +106,18 @@ VstSpeakerArrangement& DynamicSpeakerArrangement::as_c_speaker_arrangement() { static_assert(std::extent_v == 2); const size_t buffer_size = sizeof(VstSpeakerArrangement) + - ((speakers.size() - 2) * sizeof(VstSpeaker)); - speaker_arrangement_buffer.resize(buffer_size); + ((speakers_.size() - 2) * sizeof(VstSpeaker)); + speaker_arrangement_buffer_.resize(buffer_size); // Now we'll just copy over the elements from our vector to the VLA in this // struct VstSpeakerArrangement* speaker_arrangement = reinterpret_cast( - speaker_arrangement_buffer.data()); - speaker_arrangement->flags = flags; - speaker_arrangement->num_speakers = static_cast(speakers.size()); - std::copy(speakers.begin(), speakers.end(), speaker_arrangement->speakers); + speaker_arrangement_buffer_.data()); + speaker_arrangement->flags = flags_; + speaker_arrangement->num_speakers = static_cast(speakers_.size()); + std::copy(speakers_.begin(), speakers_.end(), + speaker_arrangement->speakers); return *speaker_arrangement; } @@ -125,5 +126,5 @@ std::vector& DynamicSpeakerArrangement::as_raw_data() { // This will populate the buffer for us with the struct data as_c_speaker_arrangement(); - return speaker_arrangement_buffer; + return speaker_arrangement_buffer_; } diff --git a/src/common/serialization/vst2.h b/src/common/serialization/vst2.h index 4d00261d..229889cf 100644 --- a/src/common/serialization/vst2.h +++ b/src/common/serialization/vst2.h @@ -120,9 +120,10 @@ class alignas(16) DynamicVstEvents { * host can call `effProcessEvents()` multiple times, but in practice this * of course doesn't happen. In case the host or plugin sent SysEx data, we * will need to update the `dumpBytes` field to point to the data stored in - * the `sysex_data` field before dumping everything to `vst_events_buffer`. + * the `sysex_data_` field before dumping everything to + * `vst_events_buffer_`. */ - boost::container::small_vector events; + boost::container::small_vector events_; /** * If the host or a plugin sends SysEx data, then we will store that data @@ -133,13 +134,13 @@ class alignas(16) DynamicVstEvents { * Boost.Container, so this will have to do. */ boost::container::small_vector, 8> - sysex_data; + sysex_data_; template void serialize(S& s) { - s.container(events, max_midi_events, + s.container(events_, max_midi_events, [](S& s, VstEvent& event) { s.container1b(event.dump); }); - s.container(sysex_data, max_midi_events, + s.container(sysex_data_, max_midi_events, [](S& s, std::pair& pair) { s.value8b(pair.first); s.text1b(pair.second, max_buffer_size); @@ -165,7 +166,7 @@ class alignas(16) DynamicVstEvents { sizeof(VstEvents) + ((64 - 1) * sizeof(VstEvent*))> // NOLINT(bugprone-sizeof-expression) - vst_events_buffer; + vst_events_buffer_; }; /** @@ -204,19 +205,19 @@ class alignas(16) DynamicSpeakerArrangement { /** * The flags field from `VstSpeakerArrangement` */ - int flags; + int flags_; /** * Information about the speakers in a particular input or output * configuration. */ - std::vector speakers; + std::vector speakers_; template void serialize(S& s) { - s.value4b(flags); + s.value4b(flags_); s.container( - speakers, max_audio_channels, + speakers_, max_audio_channels, [](S& s, VstSpeaker& speaker) { s.container1b(speaker.data); }); } @@ -230,7 +231,7 @@ class alignas(16) DynamicSpeakerArrangement { * We build this object in a byte sized vector to make allocating enough * heap space easy and safe. */ - std::vector speaker_arrangement_buffer; + std::vector speaker_arrangement_buffer_; }; /** diff --git a/src/common/serialization/vst3/attribute-list.cpp b/src/common/serialization/vst3/attribute-list.cpp index 2e8555cb..a2ba0605 100644 --- a/src/common/serialization/vst3/attribute-list.cpp +++ b/src/common/serialization/vst3/attribute-list.cpp @@ -91,16 +91,16 @@ IMPLEMENT_FUNKNOWN_METHODS(YaAttributeList, std::vector YaAttributeList::keys_and_types() const { std::vector result{}; - for (const auto& [key, value] : attrs_int) { + for (const auto& [key, value] : attrs_int_) { result.push_back("\"" + key + "\" (int)"); } - for (const auto& [key, value] : attrs_float) { + for (const auto& [key, value] : attrs_float_) { result.push_back("\"" + key + "\" (float)"); } - for (const auto& [key, value] : attrs_string) { + for (const auto& [key, value] : attrs_string_) { result.push_back("\"" + key + "\" (string)"); } - for (const auto& [key, value] : attrs_binary) { + for (const auto& [key, value] : attrs_binary_) { result.push_back("\"" + key + "\" (binary)"); } @@ -113,16 +113,16 @@ tresult YaAttributeList::write_back( return Steinberg::kInvalidArgument; } - for (const auto& [key, value] : attrs_int) { + for (const auto& [key, value] : attrs_int_) { stream->setInt(key.c_str(), value); } - for (const auto& [key, value] : attrs_float) { + for (const auto& [key, value] : attrs_float_) { stream->setFloat(key.c_str(), value); } - for (const auto& [key, value] : attrs_string) { + for (const auto& [key, value] : attrs_string_) { stream->setString(key.c_str(), u16string_to_tchar_pointer(value)); } - for (const auto& [key, value] : attrs_binary) { + for (const auto& [key, value] : attrs_binary_) { stream->setBinary(key.c_str(), value.data(), value.size()); } @@ -180,12 +180,12 @@ YaAttributeList YaAttributeList::read_stream_attributes( } tresult PLUGIN_API YaAttributeList::setInt(AttrID id, int64 value) { - attrs_int[id] = value; + attrs_int_[id] = value; return Steinberg::kResultOk; } tresult PLUGIN_API YaAttributeList::getInt(AttrID id, int64& value) { - if (const auto it = attrs_int.find(id); it != attrs_int.end()) { + if (const auto it = attrs_int_.find(id); it != attrs_int_.end()) { value = it->second; return Steinberg::kResultOk; } else { @@ -194,12 +194,12 @@ tresult PLUGIN_API YaAttributeList::getInt(AttrID id, int64& value) { } tresult PLUGIN_API YaAttributeList::setFloat(AttrID id, double value) { - attrs_float[id] = value; + attrs_float_[id] = value; return Steinberg::kResultOk; } tresult PLUGIN_API YaAttributeList::getFloat(AttrID id, double& value) { - if (const auto it = attrs_float.find(id); it != attrs_float.end()) { + if (const auto it = attrs_float_.find(id); it != attrs_float_.end()) { value = it->second; return Steinberg::kResultOk; } else { @@ -213,7 +213,7 @@ YaAttributeList::setString(AttrID id, const Steinberg::Vst::TChar* string) { return Steinberg::kInvalidArgument; } - attrs_string[id] = tchar_pointer_to_u16string(string); + attrs_string_[id] = tchar_pointer_to_u16string(string); return Steinberg::kResultOk; } @@ -224,7 +224,7 @@ tresult PLUGIN_API YaAttributeList::getString(AttrID id, return Steinberg::kInvalidArgument; } - if (const auto it = attrs_string.find(id); it != attrs_string.end()) { + if (const auto it = attrs_string_.find(id); it != attrs_string_.end()) { // We may only copy `sizeInBytes / 2` UTF-16 characters to `string`, // We'll also have to make sure it's null terminated, so we'll reserve // another byte for that. @@ -249,13 +249,13 @@ tresult PLUGIN_API YaAttributeList::setBinary(AttrID id, } const uint8_t* data_bytes = static_cast(data); - attrs_binary[id].assign(data_bytes, data_bytes + sizeInBytes); + attrs_binary_[id].assign(data_bytes, data_bytes + sizeInBytes); return Steinberg::kResultOk; } tresult PLUGIN_API YaAttributeList::getBinary(AttrID id, const void*& data, uint32& sizeInBytes) { - if (const auto it = attrs_binary.find(id); it != attrs_binary.end()) { + if (const auto it = attrs_binary_.find(id); it != attrs_binary_.end()) { data = it->second.data(); sizeInBytes = it->second.size(); return Steinberg::kResultOk; diff --git a/src/common/serialization/vst3/attribute-list.h b/src/common/serialization/vst3/attribute-list.h index 4282cdfb..0691e9db 100644 --- a/src/common/serialization/vst3/attribute-list.h +++ b/src/common/serialization/vst3/attribute-list.h @@ -92,22 +92,22 @@ class YaAttributeList : public Steinberg::Vst::IAttributeList { template void serialize(S& s) { - s.ext(attrs_int, bitsery::ext::StdMap{1 << 20}, + s.ext(attrs_int_, bitsery::ext::StdMap{1 << 20}, [](S& s, std::string& key, int64& value) { s.text1b(key, 1024); s.value8b(value); }); - s.ext(attrs_float, bitsery::ext::StdMap{1 << 20}, + s.ext(attrs_float_, bitsery::ext::StdMap{1 << 20}, [](S& s, std::string& key, double& value) { s.text1b(key, 1024); s.value8b(value); }); - s.ext(attrs_string, bitsery::ext::StdMap{1 << 20}, + s.ext(attrs_string_, bitsery::ext::StdMap{1 << 20}, [](S& s, std::string& key, std::u16string& value) { s.text1b(key, 1024); s.text2b(value, 1 << 20); }); - s.ext(attrs_binary, bitsery::ext::StdMap{1 << 20}, + s.ext(attrs_binary_, bitsery::ext::StdMap{1 << 20}, [](S& s, std::string& key, std::vector& value) { s.text1b(key, 1024); s.container1b(value, 1 << 20); @@ -115,10 +115,10 @@ class YaAttributeList : public Steinberg::Vst::IAttributeList { } private: - std::unordered_map attrs_int; - std::unordered_map attrs_float; - std::unordered_map attrs_string; - std::unordered_map> attrs_binary; + std::unordered_map attrs_int_; + std::unordered_map attrs_float_; + std::unordered_map attrs_string_; + std::unordered_map> attrs_binary_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/base.cpp b/src/common/serialization/vst3/base.cpp index e4af6079..c453f762 100644 --- a/src/common/serialization/vst3/base.cpp +++ b/src/common/serialization/vst3/base.cpp @@ -68,60 +68,60 @@ const Steinberg::Vst::TChar* u16string_to_tchar_pointer( WineUID::WineUID() noexcept {} WineUID::WineUID(const Steinberg::TUID& tuid) noexcept - : uid(std::to_array(tuid)) {} + : uid_(std::to_array(tuid)) {} ArrayUID WineUID::get_native_uid() const noexcept { // We need to shuffle the first 8 bytes around to convert between the // COM-compatible and non COM-compatible formats described by the // `INLINE_UID` macro. See that macro as a reference for the transformations // we're applying here. - ArrayUID converted_uid = uid; + ArrayUID converted_uid = uid_; - converted_uid[0] = uid[3]; - converted_uid[1] = uid[2]; - converted_uid[2] = uid[1]; - converted_uid[3] = uid[0]; + converted_uid[0] = uid_[3]; + converted_uid[1] = uid_[2]; + converted_uid[2] = uid_[1]; + converted_uid[3] = uid_[0]; - converted_uid[4] = uid[5]; - converted_uid[5] = uid[4]; - converted_uid[6] = uid[7]; - converted_uid[7] = uid[6]; + converted_uid[4] = uid_[5]; + converted_uid[5] = uid_[4]; + converted_uid[6] = uid_[7]; + converted_uid[7] = uid_[6]; return converted_uid; } NativeUID::NativeUID() noexcept {} NativeUID::NativeUID(const Steinberg::TUID& tuid) noexcept - : uid(std::to_array(tuid)) {} + : uid_(std::to_array(tuid)) {} ArrayUID NativeUID::get_wine_uid() const noexcept { // This transformation is actually the same as the one in // `WineUID::get_native_uid()`, but we'll spell it out here in full for // understandability's sake. - ArrayUID converted_uid = uid; + ArrayUID converted_uid = uid_; - converted_uid[0] = uid[3]; - converted_uid[1] = uid[2]; - converted_uid[2] = uid[1]; - converted_uid[3] = uid[0]; + converted_uid[0] = uid_[3]; + converted_uid[1] = uid_[2]; + converted_uid[2] = uid_[1]; + converted_uid[3] = uid_[0]; - converted_uid[4] = uid[5]; - converted_uid[5] = uid[4]; - converted_uid[6] = uid[7]; - converted_uid[7] = uid[6]; + converted_uid[4] = uid_[5]; + converted_uid[5] = uid_[4]; + converted_uid[6] = uid_[7]; + converted_uid[7] = uid_[6]; return converted_uid; } UniversalTResult::UniversalTResult() noexcept - : universal_result(Value::kResultFalse) {} + : universal_result_(Value::kResultFalse) {} UniversalTResult::UniversalTResult(tresult native_result) noexcept - : universal_result(to_universal_result(native_result)) {} + : universal_result_(to_universal_result(native_result)) {} UniversalTResult::operator tresult() const noexcept { static_assert(Steinberg::kResultOk == Steinberg::kResultTrue); - switch (universal_result) { + switch (universal_result_) { case Value::kNoInterface: return Steinberg::kNoInterface; break; @@ -155,7 +155,7 @@ UniversalTResult::operator tresult() const noexcept { std::string UniversalTResult::string() const { static_assert(Steinberg::kResultOk == Steinberg::kResultTrue); - switch (universal_result) { + switch (universal_result_) { case Value::kNoInterface: return "kNoInterface"; break; diff --git a/src/common/serialization/vst3/base.h b/src/common/serialization/vst3/base.h index 0db2d451..4fe30a33 100644 --- a/src/common/serialization/vst3/base.h +++ b/src/common/serialization/vst3/base.h @@ -98,11 +98,11 @@ class WineUID { template void serialize(S& s) { - s.container1b(uid); + s.container1b(uid_); } protected: - ArrayUID uid; + ArrayUID uid_; }; /** @@ -131,15 +131,15 @@ class NativeUID { /** * Get a reference to the proper native UID. */ - inline const ArrayUID& native_uid() const noexcept { return uid; }; + inline const ArrayUID& native_uid() const noexcept { return uid_; }; template void serialize(S& s) { - s.container1b(uid); + s.container1b(uid_); } protected: - ArrayUID uid; + ArrayUID uid_; }; /** @@ -151,17 +151,17 @@ template class PrimitiveWrapper { public: PrimitiveWrapper() noexcept {} - PrimitiveWrapper(T value) noexcept : value(value) {} + PrimitiveWrapper(T value) noexcept : value_(value) {} - operator T() const noexcept { return value; } + operator T() const noexcept { return value_; } template void serialize(S& s) { - s.template value(value); + s.template value(value_); } private: - T value; + T value_; }; /** @@ -195,7 +195,7 @@ class UniversalTResult { template void serialize(S& s) { - s.value4b(universal_result); + s.value4b(universal_result_); } private: @@ -218,5 +218,5 @@ class UniversalTResult { static Value to_universal_result(tresult native_result) noexcept; - Value universal_result; + Value universal_result_; }; diff --git a/src/common/serialization/vst3/bstream.cpp b/src/common/serialization/vst3/bstream.cpp index e0f8d32a..93e43110 100644 --- a/src/common/serialization/vst3/bstream.cpp +++ b/src/common/serialization/vst3/bstream.cpp @@ -44,10 +44,10 @@ YaBStream::YaBStream(Steinberg::IBStream* stream) { if (size > 0) { int32 num_bytes_read = 0; - buffer.resize(size); + buffer_.resize(size); stream->seek(old_position, Steinberg::IBStream::IStreamSeekMode::kIBSeekSet); - stream->read(buffer.data(), static_cast(size), + stream->read(buffer_.data(), static_cast(size), &num_bytes_read); assert(num_bytes_read == 0 || num_bytes_read == size); } @@ -62,20 +62,20 @@ YaBStream::YaBStream(Steinberg::IBStream* stream) { // based meta data if (Steinberg::FUnknownPtr stream_attributes = stream) { - supports_stream_attributes = true; + supports_stream_attributes_ = true; Steinberg::Vst::String128 vst_string{0}; if (stream_attributes->getFileName(vst_string) == Steinberg::kResultOk) { - file_name.emplace(tchar_pointer_to_u16string(vst_string)); + file_name_.emplace(tchar_pointer_to_u16string(vst_string)); } if (Steinberg::IPtr stream_attributes_list = stream_attributes->getAttributes()) { - attributes.emplace(YaAttributeList::read_stream_attributes( + attributes_.emplace(YaAttributeList::read_stream_attributes( stream_attributes_list)); } else { - attributes.emplace(); + attributes_.emplace(); } } } @@ -97,7 +97,7 @@ tresult PLUGIN_API YaBStream::queryInterface(Steinberg::FIDString _iid, Steinberg::ISizeableStream) // TODO: We don't have any logging for this - if (supports_stream_attributes) { + if (supports_stream_attributes_) { QUERY_INTERFACE(_iid, obj, Steinberg::Vst::IStreamAttributes::iid, Steinberg::Vst::IStreamAttributes) } @@ -114,24 +114,24 @@ tresult YaBStream::write_back(Steinberg::IBStream* stream) const { // A `stream->seek(0, kIBSeekSet)` breaks restoring states in Bitwig. Not // sure if Bitwig is prepending a header or if this is expected behaviour. int32 num_bytes_written = 0; - if (stream->write(const_cast(buffer.data()), - static_cast(buffer.size()), + if (stream->write(const_cast(buffer_.data()), + static_cast(buffer_.size()), &num_bytes_written) == Steinberg::kResultOk) { // Some implementations will return `kResultFalse` when writing 0 bytes assert(num_bytes_written == 0 || - static_cast(num_bytes_written) == buffer.size()); + static_cast(num_bytes_written) == buffer_.size()); } // Write back any attributes written by the plugin if the host supports // preset meta data if (Steinberg::FUnknownPtr stream_attributes = stream; - stream_attributes && attributes) { + stream_attributes && attributes_) { if (Steinberg::IPtr stream_attributes_list = stream_attributes->getAttributes()) { // XXX: If the host somehow preset some attributes, then we're also // writing those back. This should not cause any issues though. - attributes->write_back(stream_attributes_list); + attributes_->write_back(stream_attributes_list); } } @@ -139,7 +139,7 @@ tresult YaBStream::write_back(Steinberg::IBStream* stream) const { } size_t YaBStream::size() const noexcept { - return buffer.size(); + return buffer_.size(); } tresult PLUGIN_API YaBStream::read(void* buffer, @@ -151,12 +151,12 @@ tresult PLUGIN_API YaBStream::read(void* buffer, const int64_t bytes_to_read = std::min(static_cast(numBytes), - static_cast(this->buffer.size()) - seek_position); + static_cast(buffer_.size()) - seek_position_); if (bytes_to_read > 0) { - std::copy_n(&this->buffer[seek_position], bytes_to_read, + std::copy_n(&buffer_[seek_position_], bytes_to_read, reinterpret_cast(buffer)); - seek_position += bytes_to_read; + seek_position_ += bytes_to_read; } if (numBytesRead) { @@ -173,14 +173,14 @@ tresult PLUGIN_API YaBStream::write(void* buffer, return Steinberg::kInvalidArgument; } - if (seek_position + numBytes > static_cast(this->buffer.size())) { - this->buffer.resize(seek_position + numBytes); + if (seek_position_ + numBytes > static_cast(buffer_.size())) { + buffer_.resize(seek_position_ + numBytes); } std::copy_n(reinterpret_cast(buffer), numBytes, - &this->buffer[seek_position]); + &buffer_[seek_position_]); - seek_position += numBytes; + seek_position_ += numBytes; if (numBytesWritten) { *numBytesWritten = numBytes; } @@ -192,23 +192,23 @@ tresult PLUGIN_API YaBStream::write(void* buffer, tresult PLUGIN_API YaBStream::seek(int64 pos, int32 mode, int64* result) { switch (mode) { case kIBSeekSet: - seek_position = pos; + seek_position_ = pos; break; case kIBSeekCur: - seek_position += pos; + seek_position_ += pos; break; case kIBSeekEnd: - seek_position = static_cast(buffer.size()) + pos; + seek_position_ = static_cast(buffer_.size()) + pos; break; default: return Steinberg::kInvalidArgument; break; } - seek_position = std::clamp(seek_position, static_cast(0), - static_cast(buffer.size())); + seek_position_ = std::clamp(seek_position_, static_cast(0), + static_cast(buffer_.size())); if (result) { - *result = static_cast(seek_position); + *result = static_cast(seek_position_); } return Steinberg::kResultOk; @@ -216,7 +216,7 @@ tresult PLUGIN_API YaBStream::seek(int64 pos, int32 mode, int64* result) { tresult PLUGIN_API YaBStream::tell(int64* pos) { if (pos) { - *pos = seek_position; + *pos = seek_position_; return Steinberg::kResultOk; } else { return Steinberg::kInvalidArgument; @@ -224,19 +224,19 @@ tresult PLUGIN_API YaBStream::tell(int64* pos) { } tresult PLUGIN_API YaBStream::getStreamSize(int64& size) { - size = static_cast(buffer.size()); + size = static_cast(buffer_.size()); return Steinberg::kResultOk; } tresult PLUGIN_API YaBStream::setStreamSize(int64 size) { - buffer.resize(size); + buffer_.resize(size); return Steinberg::kResultOk; } tresult PLUGIN_API YaBStream::getFileName(Steinberg::Vst::String128 name) { - if (name && file_name) { - std::copy(file_name->begin(), file_name->end(), name); - name[file_name->size()] = 0; + if (name && file_name_) { + std::copy(file_name_->begin(), file_name_->end(), name); + name[file_name_->size()] = 0; return Steinberg::kResultOk; } else { @@ -245,8 +245,8 @@ tresult PLUGIN_API YaBStream::getFileName(Steinberg::Vst::String128 name) { } Steinberg::Vst::IAttributeList* PLUGIN_API YaBStream::getAttributes() { - if (attributes) { - return &*attributes; + if (attributes_) { + return &*attributes_; } else { return nullptr; } diff --git a/src/common/serialization/vst3/bstream.h b/src/common/serialization/vst3/bstream.h index 94e2872d..8f4ff3b8 100644 --- a/src/common/serialization/vst3/bstream.h +++ b/src/common/serialization/vst3/bstream.h @@ -90,37 +90,37 @@ class YaBStream : public Steinberg::IBStream, template void serialize(S& s) { - s.container1b(buffer, max_vector_stream_size); + s.container1b(buffer_, max_vector_stream_size); // The seek position should always be initialized at 0 - s.value1b(supports_stream_attributes); - s.ext(file_name, bitsery::ext::InPlaceOptional{}, + s.value1b(supports_stream_attributes_); + s.ext(file_name_, bitsery::ext::InPlaceOptional{}, [](S& s, std::u16string& name) { s.text2b(name, std::extent_v); }); - s.ext(attributes, bitsery::ext::InPlaceOptional{}); + s.ext(attributes_, bitsery::ext::InPlaceOptional{}); } /** * Whether this stream supports `IStreamAttributes`. This will be true if we * copied a stream provided by the host that also supported meta data. */ - bool supports_stream_attributes = false; + bool supports_stream_attributes_ = false; /** * The stream's name, if this stream supports stream attributes. */ - std::optional file_name; + std::optional file_name_; /** * The stream's meta data if we've copied from a stream that supports meta * data. */ - std::optional attributes; + std::optional attributes_; private: - std::vector buffer; - int64_t seek_position = 0; + std::vector buffer_; + int64_t seek_position_ = 0; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/component-handler-proxy.cpp b/src/common/serialization/vst3/component-handler-proxy.cpp index 8b285751..80284698 100644 --- a/src/common/serialization/vst3/component-handler-proxy.cpp +++ b/src/common/serialization/vst3/component-handler-proxy.cpp @@ -40,7 +40,7 @@ Vst3ComponentHandlerProxy::Vst3ComponentHandlerProxy( YaProgress(std::move(args.progress_args)), YaUnitHandler(std::move(args.unit_handler_args)), YaUnitHandler2(std::move(args.unit_handler_2_args)), - arguments(std::move(args)){FUNKNOWN_CTOR} + arguments_(std::move(args)){FUNKNOWN_CTOR} Vst3ComponentHandlerProxy::~Vst3ComponentHandlerProxy() noexcept { FUNKNOWN_DTOR diff --git a/src/common/serialization/vst3/component-handler-proxy.h b/src/common/serialization/vst3/component-handler-proxy.h index a1dab26f..347b532a 100644 --- a/src/common/serialization/vst3/component-handler-proxy.h +++ b/src/common/serialization/vst3/component-handler-proxy.h @@ -114,11 +114,11 @@ class Vst3ComponentHandlerProxy : public YaComponentHandler, * Get the instance ID of the owner of this object. */ inline size_t owner_instance_id() const noexcept { - return arguments.owner_instance_id; + return arguments_.owner_instance_id; } private: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/component-handler/component-handler-2.cpp b/src/common/serialization/vst3/component-handler/component-handler-2.cpp index acf84be5..cee33da7 100644 --- a/src/common/serialization/vst3/component-handler/component-handler-2.cpp +++ b/src/common/serialization/vst3/component-handler/component-handler-2.cpp @@ -24,4 +24,4 @@ YaComponentHandler2::ConstructArgs::ConstructArgs( Steinberg::FUnknownPtr(object)) {} YaComponentHandler2::YaComponentHandler2(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/component-handler/component-handler-2.h b/src/common/serialization/vst3/component-handler/component-handler-2.h index 121f7575..35b57ef1 100644 --- a/src/common/serialization/vst3/component-handler/component-handler-2.h +++ b/src/common/serialization/vst3/component-handler/component-handler-2.h @@ -59,7 +59,7 @@ class YaComponentHandler2 : public Steinberg::Vst::IComponentHandler2 { */ YaComponentHandler2(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to `IComponentHandler2::setDirty(state)` @@ -138,7 +138,7 @@ class YaComponentHandler2 : public Steinberg::Vst::IComponentHandler2 { virtual tresult PLUGIN_API finishGroupEdit() override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/component-handler/component-handler-3.cpp b/src/common/serialization/vst3/component-handler/component-handler-3.cpp index a4f77f25..4567e982 100644 --- a/src/common/serialization/vst3/component-handler/component-handler-3.cpp +++ b/src/common/serialization/vst3/component-handler/component-handler-3.cpp @@ -24,4 +24,4 @@ YaComponentHandler3::ConstructArgs::ConstructArgs( Steinberg::FUnknownPtr(object)) {} YaComponentHandler3::YaComponentHandler3(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/component-handler/component-handler-3.h b/src/common/serialization/vst3/component-handler/component-handler-3.h index 3577cc66..a1ce0a85 100644 --- a/src/common/serialization/vst3/component-handler/component-handler-3.h +++ b/src/common/serialization/vst3/component-handler/component-handler-3.h @@ -61,7 +61,7 @@ class YaComponentHandler3 : public Steinberg::Vst::IComponentHandler3 { */ YaComponentHandler3(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * The arguments needed to create a proxy object for the context menu @@ -110,7 +110,7 @@ class YaComponentHandler3 : public Steinberg::Vst::IComponentHandler3 { const Steinberg::Vst::ParamID* paramID) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/component-handler/component-handler-bus-activation.cpp b/src/common/serialization/vst3/component-handler/component-handler-bus-activation.cpp index 4d91974f..ddde8b83 100644 --- a/src/common/serialization/vst3/component-handler/component-handler-bus-activation.cpp +++ b/src/common/serialization/vst3/component-handler/component-handler-bus-activation.cpp @@ -25,4 +25,4 @@ YaComponentHandlerBusActivation::ConstructArgs::ConstructArgs( YaComponentHandlerBusActivation::YaComponentHandlerBusActivation( ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/component-handler/component-handler-bus-activation.h b/src/common/serialization/vst3/component-handler/component-handler-bus-activation.h index ab0b7c15..de5050d8 100644 --- a/src/common/serialization/vst3/component-handler/component-handler-bus-activation.h +++ b/src/common/serialization/vst3/component-handler/component-handler-bus-activation.h @@ -62,7 +62,7 @@ class YaComponentHandlerBusActivation */ YaComponentHandlerBusActivation(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -96,7 +96,7 @@ class YaComponentHandlerBusActivation TBool state) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/component-handler/progress.cpp b/src/common/serialization/vst3/component-handler/progress.cpp index 7e6b2214..862fc498 100644 --- a/src/common/serialization/vst3/component-handler/progress.cpp +++ b/src/common/serialization/vst3/component-handler/progress.cpp @@ -23,4 +23,4 @@ YaProgress::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaProgress::YaProgress(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/component-handler/progress.h b/src/common/serialization/vst3/component-handler/progress.h index a19bda82..265b082c 100644 --- a/src/common/serialization/vst3/component-handler/progress.h +++ b/src/common/serialization/vst3/component-handler/progress.h @@ -60,7 +60,7 @@ class YaProgress : public Steinberg::Vst::IProgress { */ YaProgress(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * The response code and returned ID for a call to `IProgress::start(type, @@ -154,7 +154,7 @@ class YaProgress : public Steinberg::Vst::IProgress { virtual tresult PLUGIN_API finish(ID id) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/component-handler/unit-handler-2.cpp b/src/common/serialization/vst3/component-handler/unit-handler-2.cpp index abd0f6ae..061ac48c 100644 --- a/src/common/serialization/vst3/component-handler/unit-handler-2.cpp +++ b/src/common/serialization/vst3/component-handler/unit-handler-2.cpp @@ -24,4 +24,4 @@ YaUnitHandler2::ConstructArgs::ConstructArgs( } YaUnitHandler2::YaUnitHandler2(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/component-handler/unit-handler-2.h b/src/common/serialization/vst3/component-handler/unit-handler-2.h index 89fac2d3..b208535d 100644 --- a/src/common/serialization/vst3/component-handler/unit-handler-2.h +++ b/src/common/serialization/vst3/component-handler/unit-handler-2.h @@ -59,7 +59,7 @@ class YaUnitHandler2 : public Steinberg::Vst::IUnitHandler2 { */ YaUnitHandler2(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -80,7 +80,7 @@ class YaUnitHandler2 : public Steinberg::Vst::IUnitHandler2 { virtual tresult PLUGIN_API notifyUnitByBusChange() override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/component-handler/unit-handler.cpp b/src/common/serialization/vst3/component-handler/unit-handler.cpp index 5f1ea1bc..8400ca69 100644 --- a/src/common/serialization/vst3/component-handler/unit-handler.cpp +++ b/src/common/serialization/vst3/component-handler/unit-handler.cpp @@ -23,4 +23,4 @@ YaUnitHandler::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaUnitHandler::YaUnitHandler(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/component-handler/unit-handler.h b/src/common/serialization/vst3/component-handler/unit-handler.h index faa91e9f..2113ae25 100644 --- a/src/common/serialization/vst3/component-handler/unit-handler.h +++ b/src/common/serialization/vst3/component-handler/unit-handler.h @@ -59,7 +59,7 @@ class YaUnitHandler : public Steinberg::Vst::IUnitHandler { */ YaUnitHandler(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -109,7 +109,7 @@ class YaUnitHandler : public Steinberg::Vst::IUnitHandler { int32 programIndex) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/connection-point-proxy.cpp b/src/common/serialization/vst3/connection-point-proxy.cpp index 640e8d80..ba6f552f 100644 --- a/src/common/serialization/vst3/connection-point-proxy.cpp +++ b/src/common/serialization/vst3/connection-point-proxy.cpp @@ -19,7 +19,7 @@ Vst3ConnectionPointProxy::Vst3ConnectionPointProxy( ConstructArgs&& args) noexcept : YaConnectionPoint(std::move(args.connection_point_args)), - arguments(std::move(args)){FUNKNOWN_CTOR} + arguments_(std::move(args)){FUNKNOWN_CTOR} Vst3ConnectionPointProxy::~Vst3ConnectionPointProxy() noexcept { FUNKNOWN_DTOR diff --git a/src/common/serialization/vst3/connection-point-proxy.h b/src/common/serialization/vst3/connection-point-proxy.h index bc6b832f..48720228 100644 --- a/src/common/serialization/vst3/connection-point-proxy.h +++ b/src/common/serialization/vst3/connection-point-proxy.h @@ -64,11 +64,11 @@ class Vst3ConnectionPointProxy : public YaConnectionPoint { * Get the instance ID of the owner of this object. */ inline size_t owner_instance_id() const noexcept { - return arguments.owner_instance_id; + return arguments_.owner_instance_id; } private: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/context-menu-proxy.cpp b/src/common/serialization/vst3/context-menu-proxy.cpp index bd8b96ba..74cd5b48 100644 --- a/src/common/serialization/vst3/context-menu-proxy.cpp +++ b/src/common/serialization/vst3/context-menu-proxy.cpp @@ -28,7 +28,7 @@ Vst3ContextMenuProxy::ConstructArgs::ConstructArgs( Vst3ContextMenuProxy::Vst3ContextMenuProxy(ConstructArgs&& args) noexcept : YaContextMenu(std::move(args.context_menu_args)), - arguments(std::move(args)){FUNKNOWN_CTOR} + arguments_(std::move(args)){FUNKNOWN_CTOR} Vst3ContextMenuProxy::~Vst3ContextMenuProxy() noexcept { FUNKNOWN_DTOR diff --git a/src/common/serialization/vst3/context-menu-proxy.h b/src/common/serialization/vst3/context-menu-proxy.h index 0f2cb3e9..4b35435b 100644 --- a/src/common/serialization/vst3/context-menu-proxy.h +++ b/src/common/serialization/vst3/context-menu-proxy.h @@ -123,18 +123,18 @@ class Vst3ContextMenuProxy : public YaContextMenu { * Get the instance ID of the owner of this object. */ inline size_t owner_instance_id() const noexcept { - return arguments.owner_instance_id; + return arguments_.owner_instance_id; } /** * Get the unique ID for this context menu. */ inline size_t context_menu_id() const noexcept { - return arguments.context_menu_id; + return arguments_.context_menu_id; } private: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/context-menu-target.cpp b/src/common/serialization/vst3/context-menu-target.cpp index a0874238..527e7e92 100644 --- a/src/common/serialization/vst3/context-menu-target.cpp +++ b/src/common/serialization/vst3/context-menu-target.cpp @@ -27,7 +27,7 @@ YaContextMenuTarget::ConstructArgs::ConstructArgs( tag(tag) {} YaContextMenuTarget::YaContextMenuTarget(ConstructArgs&& args) noexcept - : arguments(std::move(args)){FUNKNOWN_CTOR} + : arguments_(std::move(args)){FUNKNOWN_CTOR} YaContextMenuTarget::~YaContextMenuTarget() noexcept { FUNKNOWN_DTOR diff --git a/src/common/serialization/vst3/context-menu-target.h b/src/common/serialization/vst3/context-menu-target.h index 39e992ae..057d699a 100644 --- a/src/common/serialization/vst3/context-menu-target.h +++ b/src/common/serialization/vst3/context-menu-target.h @@ -79,18 +79,18 @@ class YaContextMenuTarget : public Steinberg::Vst::IContextMenuTarget { * Get the instance ID of the owner of this object. */ inline size_t owner_instance_id() const noexcept { - return arguments.owner_instance_id; + return arguments_.owner_instance_id; } /** * Get the unique ID for the context menu this target belongs to. */ - inline size_t context_menu_id() const { return arguments.context_menu_id; } + inline size_t context_menu_id() const { return arguments_.context_menu_id; } /** * Get the tag of the menu item this target was passed to. */ - inline int32 target_tag() const { return arguments.tag; } + inline int32 target_tag() const { return arguments_.tag; } /* * Message to pass through a call to @@ -122,7 +122,7 @@ class YaContextMenuTarget : public Steinberg::Vst::IContextMenuTarget { virtual tresult PLUGIN_API executeMenuItem(int32 tag) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/context-menu/context-menu.cpp b/src/common/serialization/vst3/context-menu/context-menu.cpp index 97756c6a..f016172e 100644 --- a/src/common/serialization/vst3/context-menu/context-menu.cpp +++ b/src/common/serialization/vst3/context-menu/context-menu.cpp @@ -23,4 +23,4 @@ YaContextMenu::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaContextMenu::YaContextMenu(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/context-menu/context-menu.h b/src/common/serialization/vst3/context-menu/context-menu.h index 0aaf31b2..b40e37d0 100644 --- a/src/common/serialization/vst3/context-menu/context-menu.h +++ b/src/common/serialization/vst3/context-menu/context-menu.h @@ -61,7 +61,7 @@ class YaContextMenu : public Steinberg::Vst::IContextMenu { */ YaContextMenu(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to `IContextMenu::getItemCount()` to the @@ -179,7 +179,7 @@ class YaContextMenu : public Steinberg::Vst::IContextMenu { Steinberg::UCoord y) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/event-list.cpp b/src/common/serialization/vst3/event-list.cpp index 06af72d7..0651e7b1 100644 --- a/src/common/serialization/vst3/event-list.cpp +++ b/src/common/serialization/vst3/event-list.cpp @@ -183,31 +183,31 @@ YaEventList::YaEventList() noexcept { } void YaEventList::clear() noexcept { - events.clear(); + events_.clear(); } void YaEventList::repopulate(Steinberg::Vst::IEventList& event_list) { // Copy over all events. Everything gets converted to `YaEvent`s. We sadly // can't construct these in place because we don't know the event type yet. - events.clear(); - events.reserve(event_list.getEventCount()); + events_.clear(); + events_.reserve(event_list.getEventCount()); for (int i = 0; i < event_list.getEventCount(); i++) { // We're skipping the `kResultOk` assertions here Steinberg::Vst::Event event; event_list.getEvent(i, event); - events.emplace_back(event); + events_.emplace_back(event); } } YaEventList::~YaEventList() noexcept {FUNKNOWN_DTOR} size_t YaEventList::num_events() const noexcept { - return events.size(); + return events_.size(); } void YaEventList::write_back_outputs( Steinberg::Vst::IEventList& output_events) const { - for (auto& event : events) { + for (auto& event : events_) { Steinberg::Vst::Event reconstructed_event = event.get(); output_events.addEvent(reconstructed_event); } @@ -221,25 +221,25 @@ IMPLEMENT_FUNKNOWN_METHODS(YaEventList, #pragma GCC diagnostic pop int32 PLUGIN_API YaEventList::getEventCount() { - return static_cast(events.size()); + return static_cast(events_.size()); } tresult PLUGIN_API YaEventList::getEvent(int32 index, Steinberg::Vst::Event& e /*out*/) { - if (index < 0 || index >= static_cast(events.size())) { + if (index < 0 || index >= static_cast(events_.size())) { return Steinberg::kInvalidArgument; } // Reconstructing an event is cheap, but some events may contain pointers to // heap data stored within the `events` vector so this event will still have // the same lifetime as this class - e = events[index].get(); + e = events_[index].get(); return Steinberg::kResultOk; } tresult PLUGIN_API YaEventList::addEvent(Steinberg::Vst::Event& e /*in*/) { - events.push_back(e); + events_.push_back(e); return Steinberg::kResultOk; } diff --git a/src/common/serialization/vst3/event-list.h b/src/common/serialization/vst3/event-list.h index e28be9a2..1b344e39 100644 --- a/src/common/serialization/vst3/event-list.h +++ b/src/common/serialization/vst3/event-list.h @@ -266,11 +266,11 @@ class YaEventList : public Steinberg::Vst::IEventList { template void serialize(S& s) { - s.container(events, 1 << 16); + s.container(events_, 1 << 16); } private: - boost::container::small_vector events; + boost::container::small_vector events_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/host-context-proxy.cpp b/src/common/serialization/vst3/host-context-proxy.cpp index 55eb1807..1a428d32 100644 --- a/src/common/serialization/vst3/host-context-proxy.cpp +++ b/src/common/serialization/vst3/host-context-proxy.cpp @@ -28,7 +28,7 @@ Vst3HostContextProxy::ConstructArgs::ConstructArgs( Vst3HostContextProxy::Vst3HostContextProxy(ConstructArgs&& args) noexcept : YaHostApplication(std::move(args.host_application_args)), YaPlugInterfaceSupport(std::move(args.plug_interface_support_args)), - arguments(std::move(args)){FUNKNOWN_CTOR} + arguments_(std::move(args)){FUNKNOWN_CTOR} Vst3HostContextProxy::~Vst3HostContextProxy() noexcept { FUNKNOWN_DTOR diff --git a/src/common/serialization/vst3/host-context-proxy.h b/src/common/serialization/vst3/host-context-proxy.h index 93fe0072..7f862adf 100644 --- a/src/common/serialization/vst3/host-context-proxy.h +++ b/src/common/serialization/vst3/host-context-proxy.h @@ -98,11 +98,11 @@ class Vst3HostContextProxy : public YaHostApplication, * global host context passed to the module's plugin factory. */ inline std::optional owner_instance_id() const noexcept { - return arguments.owner_instance_id; + return arguments_.owner_instance_id; } private: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/host-context/host-application.cpp b/src/common/serialization/vst3/host-context/host-application.cpp index 990852e7..bb4f79c1 100644 --- a/src/common/serialization/vst3/host-context/host-application.cpp +++ b/src/common/serialization/vst3/host-context/host-application.cpp @@ -24,4 +24,4 @@ YaHostApplication::ConstructArgs::ConstructArgs( Steinberg::FUnknownPtr(object)) {} YaHostApplication::YaHostApplication(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/host-context/host-application.h b/src/common/serialization/vst3/host-context/host-application.h index 61c97711..ad18547e 100644 --- a/src/common/serialization/vst3/host-context/host-application.h +++ b/src/common/serialization/vst3/host-context/host-application.h @@ -63,7 +63,7 @@ class YaHostApplication : public Steinberg::Vst::IHostApplication { */ YaHostApplication(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * The response code and resulting value for a call to @@ -114,7 +114,7 @@ class YaHostApplication : public Steinberg::Vst::IHostApplication { void** obj) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/host-context/plug-interface-support.cpp b/src/common/serialization/vst3/host-context/plug-interface-support.cpp index 7900e406..b992e99b 100644 --- a/src/common/serialization/vst3/host-context/plug-interface-support.cpp +++ b/src/common/serialization/vst3/host-context/plug-interface-support.cpp @@ -23,6 +23,5 @@ YaPlugInterfaceSupport::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr( object)) {} -YaPlugInterfaceSupport::YaPlugInterfaceSupport( - ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} +YaPlugInterfaceSupport::YaPlugInterfaceSupport(ConstructArgs&& args) noexcept + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/host-context/plug-interface-support.h b/src/common/serialization/vst3/host-context/plug-interface-support.h index b7aecf8d..be9c7361 100644 --- a/src/common/serialization/vst3/host-context/plug-interface-support.h +++ b/src/common/serialization/vst3/host-context/plug-interface-support.h @@ -60,7 +60,7 @@ class YaPlugInterfaceSupport : public Steinberg::Vst::IPlugInterfaceSupport { */ YaPlugInterfaceSupport(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -96,7 +96,7 @@ class YaPlugInterfaceSupport : public Steinberg::Vst::IPlugInterfaceSupport { isPlugInterfaceSupported(const Steinberg::TUID _iid) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/message.cpp b/src/common/serialization/vst3/message.cpp index 3b92365b..1e8ceabb 100644 --- a/src/common/serialization/vst3/message.cpp +++ b/src/common/serialization/vst3/message.cpp @@ -19,10 +19,10 @@ YaMessagePtr::YaMessagePtr() noexcept {FUNKNOWN_CTOR} YaMessagePtr::YaMessagePtr(IMessage& message) - : message_id(message.getMessageID() - ? std::make_optional(message.getMessageID()) - : std::nullopt), - original_message_ptr(static_cast( + : message_id_(message.getMessageID() + ? std::make_optional(message.getMessageID()) + : std::nullopt), + original_message_ptr_(static_cast( reinterpret_cast(&message))){FUNKNOWN_CTOR} YaMessagePtr::~YaMessagePtr() noexcept { @@ -39,12 +39,12 @@ IMPLEMENT_FUNKNOWN_METHODS(YaMessagePtr, Steinberg::Vst::IMessage* YaMessagePtr::get_original() const noexcept { // See the docstrings on `YaMessage` and `YaMessagePtr` return reinterpret_cast( - static_cast(original_message_ptr)); + static_cast(original_message_ptr_)); } Steinberg::FIDString PLUGIN_API YaMessagePtr::getMessageID() { - if (message_id) { - return message_id->c_str(); + if (message_id_) { + return message_id_->c_str(); } else { return nullptr; } @@ -52,14 +52,14 @@ Steinberg::FIDString PLUGIN_API YaMessagePtr::getMessageID() { void PLUGIN_API YaMessagePtr::setMessageID(Steinberg::FIDString id /*in*/) { if (id) { - message_id = id; + message_id_ = id; } else { - message_id.reset(); + message_id_.reset(); } } Steinberg::Vst::IAttributeList* PLUGIN_API YaMessagePtr::getAttributes() { - return &attribute_list; + return &attribute_list_; } YaMessage::YaMessage() noexcept {FUNKNOWN_CTOR} @@ -76,8 +76,8 @@ IMPLEMENT_FUNKNOWN_METHODS(YaMessage, #pragma GCC diagnostic pop Steinberg::FIDString PLUGIN_API YaMessage::getMessageID() { - if (message_id) { - return message_id->c_str(); + if (message_id_) { + return message_id_->c_str(); } else { return nullptr; } @@ -85,12 +85,12 @@ Steinberg::FIDString PLUGIN_API YaMessage::getMessageID() { void PLUGIN_API YaMessage::setMessageID(Steinberg::FIDString id /*in*/) { if (id) { - message_id = id; + message_id_ = id; } else { - message_id.reset(); + message_id_.reset(); } } Steinberg::Vst::IAttributeList* PLUGIN_API YaMessage::getAttributes() { - return &attribute_list; + return &attribute_list_; } diff --git a/src/common/serialization/vst3/message.h b/src/common/serialization/vst3/message.h index e0870435..152bdba7 100644 --- a/src/common/serialization/vst3/message.h +++ b/src/common/serialization/vst3/message.h @@ -72,9 +72,9 @@ class YaMessagePtr : public Steinberg::Vst::IMessage { template void serialize(S& s) { - s.ext(message_id, bitsery::ext::InPlaceOptional{}, + s.ext(message_id_, bitsery::ext::InPlaceOptional{}, [](S& s, std::string& id) { s.text1b(id, 1024); }); - s.value8b(original_message_ptr); + s.value8b(original_message_ptr_); } private: @@ -82,19 +82,19 @@ class YaMessagePtr : public Steinberg::Vst::IMessage { * The implementation that comes with the SDK returns a null pointer when * the ID has not yet been set, so we'll do the same thing. */ - std::optional message_id; + std::optional message_id_; /** * The pointer to the message passed during the constructor, as a 64-bit * unsigned integer. This way we can retrieve the original object after a * round trip. */ - native_size_t original_message_ptr = 0; + native_size_t original_message_ptr_ = 0; /** * An empty attribute list, in case the host checks this for some reason. */ - YaAttributeList attribute_list; + YaAttributeList attribute_list_; }; /** @@ -138,7 +138,7 @@ class YaMessage : public Steinberg::Vst::IMessage { * The implementation that comes with the SDK returns a null pointer when * the ID has not yet been set, so we'll do the same thing. */ - std::optional message_id; + std::optional message_id_; - YaAttributeList attribute_list; + YaAttributeList attribute_list_; }; diff --git a/src/common/serialization/vst3/param-value-queue.cpp b/src/common/serialization/vst3/param-value-queue.cpp index 25b5259b..b22ea655 100644 --- a/src/common/serialization/vst3/param-value-queue.cpp +++ b/src/common/serialization/vst3/param-value-queue.cpp @@ -24,20 +24,20 @@ YaParamValueQueue::~YaParamValueQueue() noexcept { void YaParamValueQueue::clear_for_parameter( Steinberg::Vst::ParamID parameter_id) noexcept { - this->parameter_id = parameter_id; - queue.clear(); + parameter_id_ = parameter_id; + queue_.clear(); } void YaParamValueQueue::repopulate( Steinberg::Vst::IParamValueQueue& original_queue) { - parameter_id = original_queue.getParameterId(); + parameter_id_ = original_queue.getParameterId(); // Copy over all points to our vector - queue.resize(original_queue.getPointCount()); + queue_.resize(original_queue.getPointCount()); for (int i = 0; i < original_queue.getPointCount(); i++) { // We're skipping the assertions here and just assume that the function // returns `kResultOk` - original_queue.getPoint(i, queue[i].first, queue[i].second); + original_queue.getPoint(i, queue_[i].first, queue_[i].second); } } @@ -52,27 +52,27 @@ void YaParamValueQueue::write_back_outputs( Steinberg::Vst::IParamValueQueue& output_queue) const { // We don't need this value int32 index; - for (const auto& [sample_offset, value] : queue) { + for (const auto& [sample_offset, value] : queue_) { // We don't check for `kResultOk` here output_queue.addPoint(sample_offset, value, index); } } Steinberg::Vst::ParamID PLUGIN_API YaParamValueQueue::getParameterId() { - return parameter_id; + return parameter_id_; } int32 PLUGIN_API YaParamValueQueue::getPointCount() { - return static_cast(queue.size()); + return static_cast(queue_.size()); } tresult PLUGIN_API YaParamValueQueue::getPoint(int32 index, int32& sampleOffset /*out*/, Steinberg::Vst::ParamValue& value /*out*/) { - if (index < static_cast(queue.size())) { - sampleOffset = queue[index].first; - value = queue[index].second; + if (index < static_cast(queue_.size())) { + sampleOffset = queue_[index].first; + value = queue_[index].second; return Steinberg::kResultOk; } else { @@ -82,8 +82,8 @@ YaParamValueQueue::getPoint(int32 index, tresult PLUGIN_API YaParamValueQueue::addPoint(int32 sampleOffset, Steinberg::Vst::ParamValue value, int32& index /*out*/) { - index = static_cast(queue.size()); - queue.push_back({sampleOffset, value}); + index = static_cast(queue_.size()); + queue_.push_back({sampleOffset, value}); return Steinberg::kResultOk; } diff --git a/src/common/serialization/vst3/param-value-queue.h b/src/common/serialization/vst3/param-value-queue.h index 38284105..db1e8b5f 100644 --- a/src/common/serialization/vst3/param-value-queue.h +++ b/src/common/serialization/vst3/param-value-queue.h @@ -80,9 +80,9 @@ class alignas(16) YaParamValueQueue : public Steinberg::Vst::IParamValueQueue { template void serialize(S& s) { - s.value4b(parameter_id); + s.value4b(parameter_id_); // TODO: Does bitsery have a built in way to serialize pairs? - s.container(queue, 1 << 16, [](S& s, std::pair& pair) { + s.container(queue_, 1 << 16, [](S& s, std::pair& pair) { s.value4b(pair.first); s.value8b(pair.second); }); @@ -91,7 +91,7 @@ class alignas(16) YaParamValueQueue : public Steinberg::Vst::IParamValueQueue { /** * For `IParamValueQueue::getParameterId`. */ - Steinberg::Vst::ParamID parameter_id; + Steinberg::Vst::ParamID parameter_id_; private: /** @@ -104,7 +104,7 @@ class alignas(16) YaParamValueQueue : public Steinberg::Vst::IParamValueQueue { */ boost::container::small_vector, 16> - queue; + queue_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/parameter-changes.cpp b/src/common/serialization/vst3/parameter-changes.cpp index d9a953ac..fd2e31c1 100644 --- a/src/common/serialization/vst3/parameter-changes.cpp +++ b/src/common/serialization/vst3/parameter-changes.cpp @@ -23,15 +23,15 @@ YaParameterChanges::~YaParameterChanges() noexcept { } void YaParameterChanges::clear() noexcept { - queues.clear(); + queues_.clear(); } void YaParameterChanges::repopulate( Steinberg::Vst::IParameterChanges& original_queues) { // Copy over all parameter changne queues - queues.resize(original_queues.getParameterCount()); + queues_.resize(original_queues.getParameterCount()); for (int i = 0; i < original_queues.getParameterCount(); i++) { - queues[i].repopulate(*original_queues.getParameterData(i)); + queues_[i].repopulate(*original_queues.getParameterData(i)); } } @@ -43,16 +43,16 @@ IMPLEMENT_FUNKNOWN_METHODS(YaParameterChanges, #pragma GCC diagnostic pop size_t YaParameterChanges::num_parameters() const { - return queues.size(); + return queues_.size(); } void YaParameterChanges::write_back_outputs( Steinberg::Vst::IParameterChanges& output_queues) const { - for (auto& queue : queues) { + for (auto& queue : queues_) { // We don't need this, but the SDK requires us to need this int32 output_queue_index; if (Steinberg::Vst::IParamValueQueue* output_queue = - output_queues.addParameterData(queue.parameter_id, + output_queues.addParameterData(queue.parameter_id_, output_queue_index)) { queue.write_back_outputs(*output_queue); } @@ -60,13 +60,13 @@ void YaParameterChanges::write_back_outputs( } int32 PLUGIN_API YaParameterChanges::getParameterCount() { - return static_cast(queues.size()); + return static_cast(queues_.size()); } Steinberg::Vst::IParamValueQueue* PLUGIN_API YaParameterChanges::getParameterData(int32 index) { - if (index < static_cast(queues.size())) { - return &queues[index]; + if (index < static_cast(queues_.size())) { + return &queues_[index]; } else { return nullptr; } @@ -75,12 +75,12 @@ YaParameterChanges::getParameterData(int32 index) { Steinberg::Vst::IParamValueQueue* PLUGIN_API YaParameterChanges::addParameterData(const Steinberg::Vst::ParamID& id, int32& index /*out*/) { - index = static_cast(queues.size()); + index = static_cast(queues_.size()); // Tiny hack, resizing avoids calling the constructor the second time we // resize the vector to the same size - queues.resize(queues.size() + 1); - queues[index].clear_for_parameter(id); + queues_.resize(queues_.size() + 1); + queues_[index].clear_for_parameter(id); - return &queues[index]; + return &queues_[index]; } diff --git a/src/common/serialization/vst3/parameter-changes.h b/src/common/serialization/vst3/parameter-changes.h index 8308ffdf..96bcfb55 100644 --- a/src/common/serialization/vst3/parameter-changes.h +++ b/src/common/serialization/vst3/parameter-changes.h @@ -78,14 +78,14 @@ class YaParameterChanges : public Steinberg::Vst::IParameterChanges { template void serialize(S& s) { - s.container(queues, 1 << 16); + s.container(queues_, 1 << 16); } private: /** * The parameter value changes queues. */ - boost::container::small_vector queues; + boost::container::small_vector queues_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/physical-ui-map-list.cpp b/src/common/serialization/vst3/physical-ui-map-list.cpp index dd2da907..fe94f086 100644 --- a/src/common/serialization/vst3/physical-ui-map-list.cpp +++ b/src/common/serialization/vst3/physical-ui-map-list.cpp @@ -22,21 +22,21 @@ YaPhysicalUIMapList::YaPhysicalUIMapList() noexcept {} YaPhysicalUIMapList::YaPhysicalUIMapList( const Steinberg::Vst::PhysicalUIMapList& list) noexcept - : maps(list.map, list.map + list.count) {} + : maps_(list.map, list.map + list.count) {} Steinberg::Vst::PhysicalUIMapList YaPhysicalUIMapList::get() noexcept { return Steinberg::Vst::PhysicalUIMapList{ - .count = static_cast(maps.size()), - .map = maps.data()}; + .count = static_cast(maps_.size()), + .map = maps_.data()}; } void YaPhysicalUIMapList::write_back( Steinberg::Vst::PhysicalUIMapList& list) const { - assert(list.count == maps.size()); + assert(list.count == maps_.size()); // Write the note expression IDs as updated by the plugin (if the plugin // updated them) back to the original list we've read from for (Steinberg::uint32 i = 0; i < list.count; i++) { - list.map[i].noteExpressionTypeID = maps[i].noteExpressionTypeID; + list.map[i].noteExpressionTypeID = maps_[i].noteExpressionTypeID; } } diff --git a/src/common/serialization/vst3/physical-ui-map-list.h b/src/common/serialization/vst3/physical-ui-map-list.h index 676638a0..c3336eb1 100644 --- a/src/common/serialization/vst3/physical-ui-map-list.h +++ b/src/common/serialization/vst3/physical-ui-map-list.h @@ -53,10 +53,10 @@ class YaPhysicalUIMapList { template void serialize(S& s) { - s.container(maps, 1 << 31); + s.container(maps_, 1 << 31); } - std::vector maps; + std::vector maps_; }; namespace Steinberg { diff --git a/src/common/serialization/vst3/plug-frame-proxy.cpp b/src/common/serialization/vst3/plug-frame-proxy.cpp index 130a5fc2..f8e52263 100644 --- a/src/common/serialization/vst3/plug-frame-proxy.cpp +++ b/src/common/serialization/vst3/plug-frame-proxy.cpp @@ -25,7 +25,7 @@ Vst3PlugFrameProxy::ConstructArgs::ConstructArgs( Vst3PlugFrameProxy::Vst3PlugFrameProxy(ConstructArgs&& args) noexcept : YaPlugFrame(std::move(args.plug_frame_args)), - arguments(std::move(args)){FUNKNOWN_CTOR} + arguments_(std::move(args)){FUNKNOWN_CTOR} Vst3PlugFrameProxy::~Vst3PlugFrameProxy() noexcept { FUNKNOWN_DTOR diff --git a/src/common/serialization/vst3/plug-frame-proxy.h b/src/common/serialization/vst3/plug-frame-proxy.h index 0c294a21..b74b5056 100644 --- a/src/common/serialization/vst3/plug-frame-proxy.h +++ b/src/common/serialization/vst3/plug-frame-proxy.h @@ -87,11 +87,11 @@ class Vst3PlugFrameProxy : public YaPlugFrame { * Get the instance ID of the owner of this object. */ inline size_t owner_instance_id() const noexcept { - return arguments.owner_instance_id; + return arguments_.owner_instance_id; } private: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plug-frame/plug-frame.cpp b/src/common/serialization/vst3/plug-frame/plug-frame.cpp index bc48731f..bca0e7e0 100644 --- a/src/common/serialization/vst3/plug-frame/plug-frame.cpp +++ b/src/common/serialization/vst3/plug-frame/plug-frame.cpp @@ -23,4 +23,4 @@ YaPlugFrame::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaPlugFrame::YaPlugFrame(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plug-frame/plug-frame.h b/src/common/serialization/vst3/plug-frame/plug-frame.h index 057dfb40..38b641c4 100644 --- a/src/common/serialization/vst3/plug-frame/plug-frame.h +++ b/src/common/serialization/vst3/plug-frame/plug-frame.h @@ -59,7 +59,7 @@ class YaPlugFrame : public Steinberg::IPlugFrame { */ YaPlugFrame(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to `IPlugFrame::resizeView(, @@ -88,7 +88,7 @@ class YaPlugFrame : public Steinberg::IPlugFrame { Steinberg::ViewRect* newSize) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plug-view-proxy.cpp b/src/common/serialization/vst3/plug-view-proxy.cpp index 14be9f07..5f3bc883 100644 --- a/src/common/serialization/vst3/plug-view-proxy.cpp +++ b/src/common/serialization/vst3/plug-view-proxy.cpp @@ -31,7 +31,7 @@ Vst3PlugViewProxy::Vst3PlugViewProxy(ConstructArgs&& args) noexcept YaParameterFinder(std::move(args.parameter_finder_args)), YaPlugViewContentScaleSupport( std::move(args.plug_view_content_scale_support_args)), - arguments(std::move(args)){FUNKNOWN_CTOR} + arguments_(std::move(args)){FUNKNOWN_CTOR} Vst3PlugViewProxy::~Vst3PlugViewProxy() noexcept { FUNKNOWN_DTOR diff --git a/src/common/serialization/vst3/plug-view-proxy.h b/src/common/serialization/vst3/plug-view-proxy.h index 2d4bad7a..8bb9542b 100644 --- a/src/common/serialization/vst3/plug-view-proxy.h +++ b/src/common/serialization/vst3/plug-view-proxy.h @@ -110,11 +110,11 @@ class Vst3PlugViewProxy : public YaPlugView, * Get the instance ID of the owner of this object. */ inline size_t owner_instance_id() const noexcept { - return arguments.owner_instance_id; + return arguments_.owner_instance_id; } private: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plug-view/parameter-finder.cpp b/src/common/serialization/vst3/plug-view/parameter-finder.cpp index 26095df5..8f8f2b1b 100644 --- a/src/common/serialization/vst3/plug-view/parameter-finder.cpp +++ b/src/common/serialization/vst3/plug-view/parameter-finder.cpp @@ -24,4 +24,4 @@ YaParameterFinder::ConstructArgs::ConstructArgs( Steinberg::FUnknownPtr(object)) {} YaParameterFinder::YaParameterFinder(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plug-view/parameter-finder.h b/src/common/serialization/vst3/plug-view/parameter-finder.h index 27a8e56d..0de2e18c 100644 --- a/src/common/serialization/vst3/plug-view/parameter-finder.h +++ b/src/common/serialization/vst3/plug-view/parameter-finder.h @@ -59,7 +59,7 @@ class YaParameterFinder : public Steinberg::Vst::IParameterFinder { */ YaParameterFinder(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * The response code and editor size returned by a call to @@ -102,7 +102,7 @@ class YaParameterFinder : public Steinberg::Vst::IParameterFinder { Steinberg::Vst::ParamID& resultTag /*out*/) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plug-view/plug-view-content-scale-support.cpp b/src/common/serialization/vst3/plug-view/plug-view-content-scale-support.cpp index c03db891..1fc518ef 100644 --- a/src/common/serialization/vst3/plug-view/plug-view-content-scale-support.cpp +++ b/src/common/serialization/vst3/plug-view/plug-view-content-scale-support.cpp @@ -25,4 +25,4 @@ YaPlugViewContentScaleSupport::ConstructArgs::ConstructArgs( YaPlugViewContentScaleSupport::YaPlugViewContentScaleSupport( ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plug-view/plug-view-content-scale-support.h b/src/common/serialization/vst3/plug-view/plug-view-content-scale-support.h index 62d68c86..0fbdc46f 100644 --- a/src/common/serialization/vst3/plug-view/plug-view-content-scale-support.h +++ b/src/common/serialization/vst3/plug-view/plug-view-content-scale-support.h @@ -60,7 +60,7 @@ class YaPlugViewContentScaleSupport */ YaPlugViewContentScaleSupport(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -85,7 +85,7 @@ class YaPlugViewContentScaleSupport setContentScaleFactor(ScaleFactor factor) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plug-view/plug-view.cpp b/src/common/serialization/vst3/plug-view/plug-view.cpp index 5885a668..1be2ee86 100644 --- a/src/common/serialization/vst3/plug-view/plug-view.cpp +++ b/src/common/serialization/vst3/plug-view/plug-view.cpp @@ -23,4 +23,4 @@ YaPlugView::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaPlugView::YaPlugView(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plug-view/plug-view.h b/src/common/serialization/vst3/plug-view/plug-view.h index 9d32f5ca..1301cb8c 100644 --- a/src/common/serialization/vst3/plug-view/plug-view.h +++ b/src/common/serialization/vst3/plug-view/plug-view.h @@ -61,7 +61,7 @@ class YaPlugView : public Steinberg::IPlugView { */ YaPlugView(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -365,7 +365,7 @@ class YaPlugView : public Steinberg::IPlugView { checkSizeConstraint(Steinberg::ViewRect* rect) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin-factory-proxy.cpp b/src/common/serialization/vst3/plugin-factory-proxy.cpp index a8abc50f..8319f300 100644 --- a/src/common/serialization/vst3/plugin-factory-proxy.cpp +++ b/src/common/serialization/vst3/plugin-factory-proxy.cpp @@ -24,7 +24,7 @@ Vst3PluginFactoryProxy::ConstructArgs::ConstructArgs( Vst3PluginFactoryProxy::Vst3PluginFactoryProxy(ConstructArgs&& args) noexcept : YaPluginFactory3(std::move(args.plugin_factory_args)), - arguments(std::move(args)){FUNKNOWN_CTOR} + arguments_(std::move(args)){FUNKNOWN_CTOR} // clang-format just doesn't understand these macros, I guess Vst3PluginFactoryProxy::~Vst3PluginFactoryProxy() noexcept { diff --git a/src/common/serialization/vst3/plugin-factory-proxy.h b/src/common/serialization/vst3/plugin-factory-proxy.h index 70eeb924..8a86a670 100644 --- a/src/common/serialization/vst3/plugin-factory-proxy.h +++ b/src/common/serialization/vst3/plugin-factory-proxy.h @@ -80,7 +80,7 @@ class Vst3PluginFactoryProxy : public YaPluginFactory3 { DECLARE_FUNKNOWN_METHODS private: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin-factory/plugin-factory.cpp b/src/common/serialization/vst3/plugin-factory/plugin-factory.cpp index f797de0d..b7599f85 100644 --- a/src/common/serialization/vst3/plugin-factory/plugin-factory.cpp +++ b/src/common/serialization/vst3/plugin-factory/plugin-factory.cpp @@ -100,12 +100,12 @@ YaPluginFactory3::ConstructArgs::ConstructArgs( } YaPluginFactory3::YaPluginFactory3(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} tresult PLUGIN_API YaPluginFactory3::getFactoryInfo(Steinberg::PFactoryInfo* info) { - if (info && arguments.factory_info) { - *info = *arguments.factory_info; + if (info && arguments_.factory_info) { + *info = *arguments_.factory_info; return Steinberg::kResultOk; } else { return Steinberg::kNotInitialized; @@ -113,19 +113,19 @@ YaPluginFactory3::getFactoryInfo(Steinberg::PFactoryInfo* info) { } int32 PLUGIN_API YaPluginFactory3::countClasses() { - return arguments.num_classes; + return arguments_.num_classes; } tresult PLUGIN_API YaPluginFactory3::getClassInfo(Steinberg::int32 index, Steinberg::PClassInfo* info) { - if (index >= static_cast(arguments.class_infos_1.size())) { + if (index >= static_cast(arguments_.class_infos_1.size())) { return Steinberg::kInvalidArgument; } // We will have already converted these class IDs to the native // representation in `YaPluginFactory3::ConstructArgs` - if (arguments.class_infos_1[index]) { - *info = *arguments.class_infos_1[index]; + if (arguments_.class_infos_1[index]) { + *info = *arguments_.class_infos_1[index]; return Steinberg::kResultOk; } else { return Steinberg::kResultFalse; @@ -134,14 +134,14 @@ tresult PLUGIN_API YaPluginFactory3::getClassInfo(Steinberg::int32 index, tresult PLUGIN_API YaPluginFactory3::getClassInfo2(int32 index, Steinberg::PClassInfo2* info) { - if (index >= static_cast(arguments.class_infos_2.size())) { + if (index >= static_cast(arguments_.class_infos_2.size())) { return Steinberg::kInvalidArgument; } // We will have already converted these class IDs to the native // representation in `YaPluginFactory3::ConstructArgs` - if (arguments.class_infos_2[index]) { - *info = *arguments.class_infos_2[index]; + if (arguments_.class_infos_2[index]) { + *info = *arguments_.class_infos_2[index]; return Steinberg::kResultOk; } else { return Steinberg::kResultFalse; @@ -151,14 +151,14 @@ YaPluginFactory3::getClassInfo2(int32 index, Steinberg::PClassInfo2* info) { tresult PLUGIN_API YaPluginFactory3::getClassInfoUnicode(int32 index, Steinberg::PClassInfoW* info) { - if (index >= static_cast(arguments.class_infos_unicode.size())) { + if (index >= static_cast(arguments_.class_infos_unicode.size())) { return Steinberg::kInvalidArgument; } // We will have already converted these class IDs to the native // representation in `YaPluginFactory3::ConstructArgs` - if (arguments.class_infos_unicode[index]) { - *info = *arguments.class_infos_unicode[index]; + if (arguments_.class_infos_unicode[index]) { + *info = *arguments_.class_infos_unicode[index]; return Steinberg::kResultOk; } else { return Steinberg::kResultFalse; diff --git a/src/common/serialization/vst3/plugin-factory/plugin-factory.h b/src/common/serialization/vst3/plugin-factory/plugin-factory.h index d4ea4bb6..803c27f8 100644 --- a/src/common/serialization/vst3/plugin-factory/plugin-factory.h +++ b/src/common/serialization/vst3/plugin-factory/plugin-factory.h @@ -125,15 +125,15 @@ class YaPluginFactory3 : public Steinberg::IPluginFactory3 { YaPluginFactory3(ConstructArgs&& args) noexcept; inline bool supports_plugin_factory() const noexcept { - return arguments.supports_plugin_factory; + return arguments_.supports_plugin_factory; } inline bool supports_plugin_factory_2() const noexcept { - return arguments.supports_plugin_factory_2; + return arguments_.supports_plugin_factory_2; } inline bool supports_plugin_factory_3() const noexcept { - return arguments.supports_plugin_factory_3; + return arguments_.supports_plugin_factory_3; } // All of these functiosn returning class information are fetched once on @@ -182,7 +182,7 @@ class YaPluginFactory3 : public Steinberg::IPluginFactory3 { setHostContext(Steinberg::FUnknown* context) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin-proxy.cpp b/src/common/serialization/vst3/plugin-proxy.cpp index ec72ba45..7c96721a 100644 --- a/src/common/serialization/vst3/plugin-proxy.cpp +++ b/src/common/serialization/vst3/plugin-proxy.cpp @@ -75,7 +75,7 @@ Vst3PluginProxy::Vst3PluginProxy(ConstructArgs&& args) noexcept YaUnitInfo(std::move(args.unit_info_args)), YaXmlRepresentationController( std::move(args.xml_representation_controller_args)), - arguments(std::move(args)){FUNKNOWN_CTOR} + arguments_(std::move(args)){FUNKNOWN_CTOR} Vst3PluginProxy::~Vst3PluginProxy() noexcept { FUNKNOWN_DTOR @@ -204,47 +204,47 @@ tresult PLUGIN_API Vst3PluginProxy::queryInterface(Steinberg::FIDString _iid, void Vst3PluginProxy::update_supported_interfaces( ConstructArgs&& updated_interfaces) { - assert(arguments.instance_id == updated_interfaces.instance_id); + assert(arguments_.instance_id == updated_interfaces.instance_id); // NOTE: This has to be kept in sync with `Vst3PluginProxy`'s constructor - YaAudioPresentationLatency::arguments = + YaAudioPresentationLatency::arguments_ = std::move(updated_interfaces.audio_presentation_latency_args); - YaAudioProcessor::arguments = + YaAudioProcessor::arguments_ = std::move(updated_interfaces.audio_processor_args); - YaAutomationState::arguments = + YaAutomationState::arguments_ = std::move(updated_interfaces.automation_state_args); - YaComponent::arguments = std::move(updated_interfaces.component_args); - YaConnectionPoint::arguments = + YaComponent::arguments_ = std::move(updated_interfaces.component_args); + YaConnectionPoint::arguments_ = std::move(updated_interfaces.connection_point_args); - YaEditController::arguments = + YaEditController::arguments_ = std::move(updated_interfaces.edit_controller_args); - YaEditController2::arguments = + YaEditController2::arguments_ = std::move(updated_interfaces.edit_controller_2_args); - YaEditControllerHostEditing::arguments = + YaEditControllerHostEditing::arguments_ = std::move(updated_interfaces.edit_controller_host_editing_args); - YaInfoListener::arguments = + YaInfoListener::arguments_ = std::move(updated_interfaces.info_listener_args); - YaKeyswitchController::arguments = + YaKeyswitchController::arguments_ = std::move(updated_interfaces.keyswitch_controller_args); - YaMidiLearn::arguments = std::move(updated_interfaces.midi_learn_args); - YaMidiMapping::arguments = std::move(updated_interfaces.midi_mapping_args); - YaNoteExpressionController::arguments = + YaMidiLearn::arguments_ = std::move(updated_interfaces.midi_learn_args); + YaMidiMapping::arguments_ = std::move(updated_interfaces.midi_mapping_args); + YaNoteExpressionController::arguments_ = std::move(updated_interfaces.note_expression_controller_args); - YaNoteExpressionPhysicalUIMapping::arguments = + YaNoteExpressionPhysicalUIMapping::arguments_ = std::move(updated_interfaces.note_expression_physical_ui_mapping_args); - YaParameterFunctionName::arguments = + YaParameterFunctionName::arguments_ = std::move(updated_interfaces.parameter_function_name_args); - YaPluginBase::arguments = std::move(updated_interfaces.plugin_base_args); - YaPrefetchableSupport::arguments = + YaPluginBase::arguments_ = std::move(updated_interfaces.plugin_base_args); + YaPrefetchableSupport::arguments_ = std::move(updated_interfaces.prefetchable_support_args); - YaProcessContextRequirements::arguments = + YaProcessContextRequirements::arguments_ = std::move(updated_interfaces.process_context_requirements_args); - YaProgramListData::arguments = + YaProgramListData::arguments_ = std::move(updated_interfaces.program_list_data_args); - YaUnitData::arguments = std::move(updated_interfaces.unit_data_args); - YaUnitInfo::arguments = std::move(updated_interfaces.unit_info_args); - YaXmlRepresentationController::arguments = + YaUnitData::arguments_ = std::move(updated_interfaces.unit_data_args); + YaUnitInfo::arguments_ = std::move(updated_interfaces.unit_info_args); + YaXmlRepresentationController::arguments_ = std::move(updated_interfaces.xml_representation_controller_args); - arguments = std::move(updated_interfaces); + arguments_ = std::move(updated_interfaces); } diff --git a/src/common/serialization/vst3/plugin-proxy.h b/src/common/serialization/vst3/plugin-proxy.h index faf120c3..d5a154bb 100644 --- a/src/common/serialization/vst3/plugin-proxy.h +++ b/src/common/serialization/vst3/plugin-proxy.h @@ -230,7 +230,9 @@ class Vst3PluginProxy : public YaAudioPresentationLatency, * Get this object's instance ID. Used in `IConnectionPoint` to identify and * connect specific objects. */ - inline size_t instance_id() const noexcept { return arguments.instance_id; } + inline size_t instance_id() const noexcept { + return arguments_.instance_id; + } // These have to be defined here instead of in `YaPluginBase` because we // need to reference the `ConstructArgs` @@ -343,7 +345,7 @@ class Vst3PluginProxy : public YaAudioPresentationLatency, void update_supported_interfaces(ConstructArgs&& updated_interfaces); private: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/audio-presentation-latency.cpp b/src/common/serialization/vst3/plugin/audio-presentation-latency.cpp index d7e46c31..0b6419ea 100644 --- a/src/common/serialization/vst3/plugin/audio-presentation-latency.cpp +++ b/src/common/serialization/vst3/plugin/audio-presentation-latency.cpp @@ -26,4 +26,4 @@ YaAudioPresentationLatency::ConstructArgs::ConstructArgs( YaAudioPresentationLatency::YaAudioPresentationLatency( ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/audio-presentation-latency.h b/src/common/serialization/vst3/plugin/audio-presentation-latency.h index 63f17be4..b029d59b 100644 --- a/src/common/serialization/vst3/plugin/audio-presentation-latency.h +++ b/src/common/serialization/vst3/plugin/audio-presentation-latency.h @@ -60,7 +60,7 @@ class YaAudioPresentationLatency */ YaAudioPresentationLatency(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -91,7 +91,7 @@ class YaAudioPresentationLatency uint32 latencyInSamples) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/audio-processor.cpp b/src/common/serialization/vst3/plugin/audio-processor.cpp index a1801064..566a13cc 100644 --- a/src/common/serialization/vst3/plugin/audio-processor.cpp +++ b/src/common/serialization/vst3/plugin/audio-processor.cpp @@ -24,4 +24,4 @@ YaAudioProcessor::ConstructArgs::ConstructArgs( Steinberg::FUnknownPtr(object)) {} YaAudioProcessor::YaAudioProcessor(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/audio-processor.h b/src/common/serialization/vst3/plugin/audio-processor.h index 44c2f998..67335105 100644 --- a/src/common/serialization/vst3/plugin/audio-processor.h +++ b/src/common/serialization/vst3/plugin/audio-processor.h @@ -62,7 +62,7 @@ class YaAudioProcessor : public Steinberg::Vst::IAudioProcessor { */ YaAudioProcessor(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -305,7 +305,7 @@ class YaAudioProcessor : public Steinberg::Vst::IAudioProcessor { virtual uint32 PLUGIN_API getTailSamples() override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/automation-state.cpp b/src/common/serialization/vst3/plugin/automation-state.cpp index 725b15db..c52db41c 100644 --- a/src/common/serialization/vst3/plugin/automation-state.cpp +++ b/src/common/serialization/vst3/plugin/automation-state.cpp @@ -24,4 +24,4 @@ YaAutomationState::ConstructArgs::ConstructArgs( Steinberg::FUnknownPtr(object)) {} YaAutomationState::YaAutomationState(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/automation-state.h b/src/common/serialization/vst3/plugin/automation-state.h index 5ff270b8..06534439 100644 --- a/src/common/serialization/vst3/plugin/automation-state.h +++ b/src/common/serialization/vst3/plugin/automation-state.h @@ -62,7 +62,7 @@ class YaAutomationState : public Steinberg::Vst::IAutomationState { */ YaAutomationState(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -85,7 +85,7 @@ class YaAutomationState : public Steinberg::Vst::IAutomationState { virtual tresult PLUGIN_API setAutomationState(int32 state) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/component.cpp b/src/common/serialization/vst3/plugin/component.cpp index 99c3f23f..29c6cbfd 100644 --- a/src/common/serialization/vst3/plugin/component.cpp +++ b/src/common/serialization/vst3/plugin/component.cpp @@ -23,4 +23,4 @@ YaComponent::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaComponent::YaComponent(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/component.h b/src/common/serialization/vst3/plugin/component.h index de5cb6fe..f7f19766 100644 --- a/src/common/serialization/vst3/plugin/component.h +++ b/src/common/serialization/vst3/plugin/component.h @@ -62,7 +62,7 @@ class YaComponent : public Steinberg::Vst::IComponent { */ YaComponent(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * The response code and returned CID for a call to @@ -281,7 +281,7 @@ class YaComponent : public Steinberg::Vst::IComponent { getState(Steinberg::IBStream* state) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/connection-point.cpp b/src/common/serialization/vst3/plugin/connection-point.cpp index 3afcb6e4..f3bd0912 100644 --- a/src/common/serialization/vst3/plugin/connection-point.cpp +++ b/src/common/serialization/vst3/plugin/connection-point.cpp @@ -33,4 +33,4 @@ YaConnectionPoint::Vst3ConnectionPointProxyConstructArgs:: : owner_instance_id(owner_instance_id), connection_point_args(object) {} YaConnectionPoint::YaConnectionPoint(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/connection-point.h b/src/common/serialization/vst3/plugin/connection-point.h index 6a6afb7e..02b4542b 100644 --- a/src/common/serialization/vst3/plugin/connection-point.h +++ b/src/common/serialization/vst3/plugin/connection-point.h @@ -107,7 +107,7 @@ class YaConnectionPoint : public Steinberg::Vst::IConnectionPoint { */ YaConnectionPoint(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to `IConnectionPoint::connect(other)` to @@ -204,7 +204,7 @@ class YaConnectionPoint : public Steinberg::Vst::IConnectionPoint { notify(Steinberg::Vst::IMessage* message) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/edit-controller-2.cpp b/src/common/serialization/vst3/plugin/edit-controller-2.cpp index 209fba33..7c0313f1 100644 --- a/src/common/serialization/vst3/plugin/edit-controller-2.cpp +++ b/src/common/serialization/vst3/plugin/edit-controller-2.cpp @@ -24,4 +24,4 @@ YaEditController2::ConstructArgs::ConstructArgs( Steinberg::FUnknownPtr(object)) {} YaEditController2::YaEditController2(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/edit-controller-2.h b/src/common/serialization/vst3/plugin/edit-controller-2.h index eb98aeb8..81469a37 100644 --- a/src/common/serialization/vst3/plugin/edit-controller-2.h +++ b/src/common/serialization/vst3/plugin/edit-controller-2.h @@ -59,7 +59,7 @@ class YaEditController2 : public Steinberg::Vst::IEditController2 { */ YaEditController2(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to `IEditController2::setKnobMode(mode)` @@ -123,7 +123,7 @@ class YaEditController2 : public Steinberg::Vst::IEditController2 { virtual tresult PLUGIN_API openAboutBox(TBool onlyCheck) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/edit-controller-host-editing.cpp b/src/common/serialization/vst3/plugin/edit-controller-host-editing.cpp index dd80472a..f18f8d4b 100644 --- a/src/common/serialization/vst3/plugin/edit-controller-host-editing.cpp +++ b/src/common/serialization/vst3/plugin/edit-controller-host-editing.cpp @@ -26,4 +26,4 @@ YaEditControllerHostEditing::ConstructArgs::ConstructArgs( YaEditControllerHostEditing::YaEditControllerHostEditing( ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/edit-controller-host-editing.h b/src/common/serialization/vst3/plugin/edit-controller-host-editing.h index 640d9cf9..af9dc400 100644 --- a/src/common/serialization/vst3/plugin/edit-controller-host-editing.h +++ b/src/common/serialization/vst3/plugin/edit-controller-host-editing.h @@ -60,7 +60,7 @@ class YaEditControllerHostEditing */ YaEditControllerHostEditing(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -107,7 +107,7 @@ class YaEditControllerHostEditing endEditFromHost(Steinberg::Vst::ParamID paramID) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/edit-controller.cpp b/src/common/serialization/vst3/plugin/edit-controller.cpp index 9039f3c4..27b5512f 100644 --- a/src/common/serialization/vst3/plugin/edit-controller.cpp +++ b/src/common/serialization/vst3/plugin/edit-controller.cpp @@ -24,4 +24,4 @@ YaEditController::ConstructArgs::ConstructArgs( Steinberg::FUnknownPtr(object)) {} YaEditController::YaEditController(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/edit-controller.h b/src/common/serialization/vst3/plugin/edit-controller.h index 78172e60..4ffdeb0e 100644 --- a/src/common/serialization/vst3/plugin/edit-controller.h +++ b/src/common/serialization/vst3/plugin/edit-controller.h @@ -63,7 +63,7 @@ class YaEditController : public Steinberg::Vst::IEditController { */ YaEditController(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -399,7 +399,7 @@ class YaEditController : public Steinberg::Vst::IEditController { createView(Steinberg::FIDString name) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/info-listener.cpp b/src/common/serialization/vst3/plugin/info-listener.cpp index 70e2f5ec..c793d335 100644 --- a/src/common/serialization/vst3/plugin/info-listener.cpp +++ b/src/common/serialization/vst3/plugin/info-listener.cpp @@ -25,4 +25,4 @@ YaInfoListener::ConstructArgs::ConstructArgs( object)) {} YaInfoListener::YaInfoListener(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/info-listener.h b/src/common/serialization/vst3/plugin/info-listener.h index 40f0a6a2..73571151 100644 --- a/src/common/serialization/vst3/plugin/info-listener.h +++ b/src/common/serialization/vst3/plugin/info-listener.h @@ -60,7 +60,7 @@ class YaInfoListener : public Steinberg::Vst::ChannelContext::IInfoListener { */ YaInfoListener(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -88,7 +88,7 @@ class YaInfoListener : public Steinberg::Vst::ChannelContext::IInfoListener { setChannelContextInfos(Steinberg::Vst::IAttributeList* list) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/keyswitch-controller.cpp b/src/common/serialization/vst3/plugin/keyswitch-controller.cpp index 0989664f..a724ca22 100644 --- a/src/common/serialization/vst3/plugin/keyswitch-controller.cpp +++ b/src/common/serialization/vst3/plugin/keyswitch-controller.cpp @@ -23,6 +23,5 @@ YaKeyswitchController::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr( object)) {} -YaKeyswitchController::YaKeyswitchController( - ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} +YaKeyswitchController::YaKeyswitchController(ConstructArgs&& args) noexcept + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/keyswitch-controller.h b/src/common/serialization/vst3/plugin/keyswitch-controller.h index 2aafd6fa..92a27a4f 100644 --- a/src/common/serialization/vst3/plugin/keyswitch-controller.h +++ b/src/common/serialization/vst3/plugin/keyswitch-controller.h @@ -59,7 +59,7 @@ class YaKeyswitchController : public Steinberg::Vst::IKeyswitchController { */ YaKeyswitchController(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -131,7 +131,7 @@ class YaKeyswitchController : public Steinberg::Vst::IKeyswitchController { Steinberg::Vst::KeyswitchInfo& info /*out*/) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/midi-learn.cpp b/src/common/serialization/vst3/plugin/midi-learn.cpp index c8b6952f..012ea4ea 100644 --- a/src/common/serialization/vst3/plugin/midi-learn.cpp +++ b/src/common/serialization/vst3/plugin/midi-learn.cpp @@ -23,4 +23,4 @@ YaMidiLearn::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaMidiLearn::YaMidiLearn(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/midi-learn.h b/src/common/serialization/vst3/plugin/midi-learn.h index 5e54c5b6..78697177 100644 --- a/src/common/serialization/vst3/plugin/midi-learn.h +++ b/src/common/serialization/vst3/plugin/midi-learn.h @@ -59,7 +59,7 @@ class YaMidiLearn : public Steinberg::Vst::IMidiLearn { */ YaMidiLearn(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -90,7 +90,7 @@ class YaMidiLearn : public Steinberg::Vst::IMidiLearn { Steinberg::Vst::CtrlNumber midiCC) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/midi-mapping.cpp b/src/common/serialization/vst3/plugin/midi-mapping.cpp index c9ca0615..1cb42977 100644 --- a/src/common/serialization/vst3/plugin/midi-mapping.cpp +++ b/src/common/serialization/vst3/plugin/midi-mapping.cpp @@ -23,4 +23,4 @@ YaMidiMapping::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaMidiMapping::YaMidiMapping(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/midi-mapping.h b/src/common/serialization/vst3/plugin/midi-mapping.h index 8f6c5828..af806295 100644 --- a/src/common/serialization/vst3/plugin/midi-mapping.h +++ b/src/common/serialization/vst3/plugin/midi-mapping.h @@ -59,7 +59,7 @@ class YaMidiMapping : public Steinberg::Vst::IMidiMapping { */ YaMidiMapping(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * The response code and returned parameter ID for a call to @@ -107,7 +107,7 @@ class YaMidiMapping : public Steinberg::Vst::IMidiMapping { Steinberg::Vst::ParamID& id /*out*/) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/note-expression-controller.cpp b/src/common/serialization/vst3/plugin/note-expression-controller.cpp index b36c4f9e..1270edd3 100644 --- a/src/common/serialization/vst3/plugin/note-expression-controller.cpp +++ b/src/common/serialization/vst3/plugin/note-expression-controller.cpp @@ -26,4 +26,4 @@ YaNoteExpressionController::ConstructArgs::ConstructArgs( YaNoteExpressionController::YaNoteExpressionController( ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/note-expression-controller.h b/src/common/serialization/vst3/plugin/note-expression-controller.h index e537172c..afeb61b8 100644 --- a/src/common/serialization/vst3/plugin/note-expression-controller.h +++ b/src/common/serialization/vst3/plugin/note-expression-controller.h @@ -63,7 +63,7 @@ class YaNoteExpressionController */ YaNoteExpressionController(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -232,7 +232,7 @@ class YaNoteExpressionController override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/note-expression-physical-ui-mapping.cpp b/src/common/serialization/vst3/plugin/note-expression-physical-ui-mapping.cpp index 4fd8392d..f6d4a3c6 100644 --- a/src/common/serialization/vst3/plugin/note-expression-physical-ui-mapping.cpp +++ b/src/common/serialization/vst3/plugin/note-expression-physical-ui-mapping.cpp @@ -25,4 +25,4 @@ YaNoteExpressionPhysicalUIMapping::ConstructArgs::ConstructArgs( YaNoteExpressionPhysicalUIMapping::YaNoteExpressionPhysicalUIMapping( ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/note-expression-physical-ui-mapping.h b/src/common/serialization/vst3/plugin/note-expression-physical-ui-mapping.h index d814c9a8..7595ef4e 100644 --- a/src/common/serialization/vst3/plugin/note-expression-physical-ui-mapping.h +++ b/src/common/serialization/vst3/plugin/note-expression-physical-ui-mapping.h @@ -62,7 +62,7 @@ class YaNoteExpressionPhysicalUIMapping */ YaNoteExpressionPhysicalUIMapping(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * The response code and returned info for a call to @@ -115,7 +115,7 @@ class YaNoteExpressionPhysicalUIMapping Steinberg::Vst::PhysicalUIMapList& list) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/parameter-function-name.cpp b/src/common/serialization/vst3/plugin/parameter-function-name.cpp index 2f57ae83..171a398e 100644 --- a/src/common/serialization/vst3/plugin/parameter-function-name.cpp +++ b/src/common/serialization/vst3/plugin/parameter-function-name.cpp @@ -23,6 +23,5 @@ YaParameterFunctionName::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr( object)) {} -YaParameterFunctionName::YaParameterFunctionName( - ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} +YaParameterFunctionName::YaParameterFunctionName(ConstructArgs&& args) noexcept + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/parameter-function-name.h b/src/common/serialization/vst3/plugin/parameter-function-name.h index 411ca3c4..dd2d4491 100644 --- a/src/common/serialization/vst3/plugin/parameter-function-name.h +++ b/src/common/serialization/vst3/plugin/parameter-function-name.h @@ -61,7 +61,7 @@ class YaParameterFunctionName : public Steinberg::Vst::IParameterFunctionName { */ YaParameterFunctionName(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * The response code and returned parameter ID for a call to @@ -106,7 +106,7 @@ class YaParameterFunctionName : public Steinberg::Vst::IParameterFunctionName { Steinberg::Vst::ParamID& paramID) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/plugin-base.cpp b/src/common/serialization/vst3/plugin/plugin-base.cpp index 309be308..8e2f53f5 100644 --- a/src/common/serialization/vst3/plugin/plugin-base.cpp +++ b/src/common/serialization/vst3/plugin/plugin-base.cpp @@ -23,4 +23,4 @@ YaPluginBase::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaPluginBase::YaPluginBase(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/plugin-base.h b/src/common/serialization/vst3/plugin/plugin-base.h index baacdbe4..e6d7ca0f 100644 --- a/src/common/serialization/vst3/plugin/plugin-base.h +++ b/src/common/serialization/vst3/plugin/plugin-base.h @@ -61,7 +61,7 @@ class YaPluginBase : public Steinberg::IPluginBase { */ YaPluginBase(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } // The request and response for `IPluginBase::initialize()` is defined // within `Vst3PluginProxy` because it (thanks to Waves) requires all @@ -86,7 +86,7 @@ class YaPluginBase : public Steinberg::IPluginBase { virtual tresult PLUGIN_API terminate() override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/prefetchable-support.cpp b/src/common/serialization/vst3/plugin/prefetchable-support.cpp index 8dfcf7b5..2fffdfea 100644 --- a/src/common/serialization/vst3/plugin/prefetchable-support.cpp +++ b/src/common/serialization/vst3/plugin/prefetchable-support.cpp @@ -23,6 +23,5 @@ YaPrefetchableSupport::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr( object)) {} -YaPrefetchableSupport::YaPrefetchableSupport( - ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} +YaPrefetchableSupport::YaPrefetchableSupport(ConstructArgs&& args) noexcept + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/prefetchable-support.h b/src/common/serialization/vst3/plugin/prefetchable-support.h index 4ed58773..7e84ada3 100644 --- a/src/common/serialization/vst3/plugin/prefetchable-support.h +++ b/src/common/serialization/vst3/plugin/prefetchable-support.h @@ -60,7 +60,7 @@ class YaPrefetchableSupport : public Steinberg::Vst::IPrefetchableSupport { */ YaPrefetchableSupport(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * The response code and returned bus information for a call to @@ -97,7 +97,7 @@ class YaPrefetchableSupport : public Steinberg::Vst::IPrefetchableSupport { Steinberg::Vst::PrefetchableSupport& prefetchable /*out*/) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/process-context-requirements.cpp b/src/common/serialization/vst3/plugin/process-context-requirements.cpp index 8da60cee..160ae12b 100644 --- a/src/common/serialization/vst3/plugin/process-context-requirements.cpp +++ b/src/common/serialization/vst3/plugin/process-context-requirements.cpp @@ -26,4 +26,4 @@ YaProcessContextRequirements::ConstructArgs::ConstructArgs( YaProcessContextRequirements::YaProcessContextRequirements( ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/process-context-requirements.h b/src/common/serialization/vst3/plugin/process-context-requirements.h index 9ec48a71..d812ceb2 100644 --- a/src/common/serialization/vst3/plugin/process-context-requirements.h +++ b/src/common/serialization/vst3/plugin/process-context-requirements.h @@ -62,7 +62,7 @@ class YaProcessContextRequirements */ YaProcessContextRequirements(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -83,7 +83,7 @@ class YaProcessContextRequirements virtual uint32 PLUGIN_API getProcessContextRequirements() override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/program-list-data.cpp b/src/common/serialization/vst3/plugin/program-list-data.cpp index f13fc283..6faa5ccf 100644 --- a/src/common/serialization/vst3/plugin/program-list-data.cpp +++ b/src/common/serialization/vst3/plugin/program-list-data.cpp @@ -24,4 +24,4 @@ YaProgramListData::ConstructArgs::ConstructArgs( Steinberg::FUnknownPtr(object)) {} YaProgramListData::YaProgramListData(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/program-list-data.h b/src/common/serialization/vst3/plugin/program-list-data.h index 2557d83a..cad66851 100644 --- a/src/common/serialization/vst3/plugin/program-list-data.h +++ b/src/common/serialization/vst3/plugin/program-list-data.h @@ -60,7 +60,7 @@ class YaProgramListData : public Steinberg::Vst::IProgramListData { */ YaProgramListData(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to @@ -156,7 +156,7 @@ class YaProgramListData : public Steinberg::Vst::IProgramListData { Steinberg::IBStream* data) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/unit-data.cpp b/src/common/serialization/vst3/plugin/unit-data.cpp index ba2fb5b0..d9aeffd9 100644 --- a/src/common/serialization/vst3/plugin/unit-data.cpp +++ b/src/common/serialization/vst3/plugin/unit-data.cpp @@ -23,4 +23,4 @@ YaUnitData::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaUnitData::YaUnitData(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/unit-data.h b/src/common/serialization/vst3/plugin/unit-data.h index c03e01d2..1405bdc4 100644 --- a/src/common/serialization/vst3/plugin/unit-data.h +++ b/src/common/serialization/vst3/plugin/unit-data.h @@ -60,7 +60,7 @@ class YaUnitData : public Steinberg::Vst::IUnitData { */ YaUnitData(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to `IUnitData::unitDataSupported(unit_id)` @@ -147,7 +147,7 @@ class YaUnitData : public Steinberg::Vst::IUnitData { Steinberg::IBStream* data) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/unit-info.cpp b/src/common/serialization/vst3/plugin/unit-info.cpp index 8069af0a..28333313 100644 --- a/src/common/serialization/vst3/plugin/unit-info.cpp +++ b/src/common/serialization/vst3/plugin/unit-info.cpp @@ -23,4 +23,4 @@ YaUnitInfo::ConstructArgs::ConstructArgs( : supported(Steinberg::FUnknownPtr(object)) {} YaUnitInfo::YaUnitInfo(ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/unit-info.h b/src/common/serialization/vst3/plugin/unit-info.h index 08cd0217..130c810e 100644 --- a/src/common/serialization/vst3/plugin/unit-info.h +++ b/src/common/serialization/vst3/plugin/unit-info.h @@ -60,7 +60,7 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo { */ YaUnitInfo(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * Message to pass through a call to `IUnitInfo::getUnitCount()` to the Wine @@ -438,7 +438,7 @@ class YaUnitInfo : public Steinberg::Vst::IUnitInfo { Steinberg::IBStream* data) override = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/plugin/xml-representation-controller.cpp b/src/common/serialization/vst3/plugin/xml-representation-controller.cpp index 3b668a91..91623328 100644 --- a/src/common/serialization/vst3/plugin/xml-representation-controller.cpp +++ b/src/common/serialization/vst3/plugin/xml-representation-controller.cpp @@ -26,4 +26,4 @@ YaXmlRepresentationController::ConstructArgs::ConstructArgs( YaXmlRepresentationController::YaXmlRepresentationController( ConstructArgs&& args) noexcept - : arguments(std::move(args)) {} + : arguments_(std::move(args)) {} diff --git a/src/common/serialization/vst3/plugin/xml-representation-controller.h b/src/common/serialization/vst3/plugin/xml-representation-controller.h index 3c4e9f9a..5ab22614 100644 --- a/src/common/serialization/vst3/plugin/xml-representation-controller.h +++ b/src/common/serialization/vst3/plugin/xml-representation-controller.h @@ -67,7 +67,7 @@ class YaXmlRepresentationController */ YaXmlRepresentationController(ConstructArgs&& args) noexcept; - inline bool supported() const noexcept { return arguments.supported; } + inline bool supported() const noexcept { return arguments_.supported; } /** * The response code and written state for a call to @@ -111,7 +111,7 @@ class YaXmlRepresentationController Steinberg::IBStream* stream /*out*/) = 0; protected: - ConstructArgs arguments; + ConstructArgs arguments_; }; #pragma GCC diagnostic pop diff --git a/src/common/serialization/vst3/process-data.cpp b/src/common/serialization/vst3/process-data.cpp index c1a70fe7..68edc647 100644 --- a/src/common/serialization/vst3/process-data.cpp +++ b/src/common/serialization/vst3/process-data.cpp @@ -28,12 +28,12 @@ YaProcessData::YaProcessData() noexcept // belongs to an actual process data object, because with these changes it's // no longer possible to deserialize those results into a new ad-hoc created // object. - : response_object{.outputs = &outputs, - .output_parameter_changes = &output_parameter_changes, - .output_events = &output_events}, + : response_object_{.outputs = &outputs_, + .output_parameter_changes = &output_parameter_changes_, + .output_events = &output_events_}, // This needs to be zero initialized so we can safely call // `create_response()` on the plugin side - reconstructed_process_data() {} + reconstructed_process_data_() {} void YaProcessData::repopulate(const Steinberg::Vst::ProcessData& process_data, AudioShmBuffer& shared_audio_buffers) { @@ -41,26 +41,26 @@ void YaProcessData::repopulate(const Steinberg::Vst::ProcessData& process_data, // not use `push_back`/`emplace_back` anywhere. Resizing vectors and // modifying them in place performs much better because that avoids // destroying and creating objects most of the time. - process_mode = process_data.processMode; - symbolic_sample_size = process_data.symbolicSampleSize; - num_samples = process_data.numSamples; + process_mode_ = process_data.processMode; + symbolic_sample_size_ = process_data.symbolicSampleSize; + num_samples_ = process_data.numSamples; // The actual audio is stored in an accompanying `AudioShmBuffer` object, so // these inputs and outputs objects are only used to serialize metadata // about the input and output audio bus buffers - inputs.resize(process_data.numInputs); + inputs_.resize(process_data.numInputs); for (int bus = 0; bus < process_data.numInputs; bus++) { // NOTE: The host might provide more input channels than what the plugin // asked for. Carla does this for some reason. We should just // ignore these. - inputs[bus].numChannels = std::min( + inputs_[bus].numChannels = std::min( static_cast(shared_audio_buffers.num_input_channels(bus)), process_data.inputs[bus].numChannels); - inputs[bus].silenceFlags = process_data.inputs[bus].silenceFlags; + inputs_[bus].silenceFlags = process_data.inputs[bus].silenceFlags; // We copy the actual input audio for every bus to the shared memory // object - for (int channel = 0; channel < inputs[bus].numChannels; channel++) { + for (int channel = 0; channel < inputs_[bus].numChannels; channel++) { if (process_data.symbolicSampleSize == Steinberg::Vst::kSample64) { std::copy_n(process_data.inputs[bus].channelBuffers64[channel], process_data.numSamples, @@ -75,68 +75,70 @@ void YaProcessData::repopulate(const Steinberg::Vst::ProcessData& process_data, } } - outputs.resize(process_data.numOutputs); + outputs_.resize(process_data.numOutputs); for (int bus = 0; bus < process_data.numOutputs; bus++) { // NOTE: The host might provide more output channels than what the // plugin asked for. Carla does this for some reason. We should // just ignore these. - outputs[bus].numChannels = std::min( + outputs_[bus].numChannels = std::min( static_cast(shared_audio_buffers.num_output_channels(bus)), process_data.outputs[bus].numChannels); - outputs[bus].silenceFlags = process_data.outputs[bus].silenceFlags; + outputs_[bus].silenceFlags = process_data.outputs[bus].silenceFlags; } // Even though `ProcessData::inputParamterChanges` is mandatory, the VST3 // validator will pass a null pointer here if (process_data.inputParameterChanges) { - input_parameter_changes.repopulate(*process_data.inputParameterChanges); + input_parameter_changes_.repopulate( + *process_data.inputParameterChanges); } else { - input_parameter_changes.clear(); + input_parameter_changes_.clear(); } // The existence of the output parameter changes object indicates whether or // not the host provides this for the plugin if (process_data.outputParameterChanges) { - if (!output_parameter_changes) { - output_parameter_changes.emplace(); + if (!output_parameter_changes_) { + output_parameter_changes_.emplace(); } } else { - output_parameter_changes.reset(); + output_parameter_changes_.reset(); } if (process_data.inputEvents) { - if (!input_events) { - input_events.emplace(); + if (!input_events_) { + input_events_.emplace(); } - input_events->repopulate(*process_data.inputEvents); + input_events_->repopulate(*process_data.inputEvents); } else { - input_events.reset(); + input_events_.reset(); } // Same for the output events if (process_data.outputEvents) { - if (!output_events) { - output_events.emplace(); + if (!output_events_) { + output_events_.emplace(); } } else { - output_events.reset(); + output_events_.reset(); } if (process_data.processContext) { - process_context.emplace(*process_data.processContext); + process_context_.emplace(*process_data.processContext); } else { - process_context.reset(); + process_context_.reset(); } } Steinberg::Vst::ProcessData& YaProcessData::reconstruct( std::vector>& input_pointers, std::vector>& output_pointers) { - reconstructed_process_data.processMode = process_mode; - reconstructed_process_data.symbolicSampleSize = symbolic_sample_size; - reconstructed_process_data.numSamples = num_samples; - reconstructed_process_data.numInputs = static_cast(inputs.size()); - reconstructed_process_data.numOutputs = static_cast(outputs.size()); + reconstructed_process_data_.processMode = process_mode_; + reconstructed_process_data_.symbolicSampleSize = symbolic_sample_size_; + reconstructed_process_data_.numSamples = num_samples_; + reconstructed_process_data_.numInputs = static_cast(inputs_.size()); + reconstructed_process_data_.numOutputs = + static_cast(outputs_.size()); // The actual audio data is contained within a shared memory object, and the // input and output pointers point to regions in that object. These pointers @@ -146,70 +148,71 @@ Steinberg::Vst::ProcessData& YaProcessData::reconstruct( // `channelBuffers64` to point at that buffer as long as we do the // same thing on both the native plugin side and on the Wine plugin // host - assert(inputs.size() <= input_pointers.size() && - outputs.size() <= output_pointers.size()); - for (size_t bus = 0; bus < inputs.size(); bus++) { - inputs[bus].channelBuffers32 = + assert(inputs_.size() <= input_pointers.size() && + outputs_.size() <= output_pointers.size()); + for (size_t bus = 0; bus < inputs_.size(); bus++) { + inputs_[bus].channelBuffers32 = reinterpret_cast(input_pointers[bus].data()); } - for (size_t bus = 0; bus < outputs.size(); bus++) { - outputs[bus].channelBuffers32 = + for (size_t bus = 0; bus < outputs_.size(); bus++) { + outputs_[bus].channelBuffers32 = reinterpret_cast(output_pointers[bus].data()); } - reconstructed_process_data.inputs = inputs.data(); - reconstructed_process_data.outputs = outputs.data(); + reconstructed_process_data_.inputs = inputs_.data(); + reconstructed_process_data_.outputs = outputs_.data(); - reconstructed_process_data.inputParameterChanges = &input_parameter_changes; + reconstructed_process_data_.inputParameterChanges = + &input_parameter_changes_; - if (output_parameter_changes) { - output_parameter_changes->clear(); - reconstructed_process_data.outputParameterChanges = - &*output_parameter_changes; + if (output_parameter_changes_) { + output_parameter_changes_->clear(); + reconstructed_process_data_.outputParameterChanges = + &*output_parameter_changes_; } else { - reconstructed_process_data.outputParameterChanges = nullptr; + reconstructed_process_data_.outputParameterChanges = nullptr; } - if (input_events) { - reconstructed_process_data.inputEvents = &*input_events; + if (input_events_) { + reconstructed_process_data_.inputEvents = &*input_events_; } else { - reconstructed_process_data.inputEvents = nullptr; + reconstructed_process_data_.inputEvents = nullptr; } - if (output_events) { - output_events->clear(); - reconstructed_process_data.outputEvents = &*output_events; + if (output_events_) { + output_events_->clear(); + reconstructed_process_data_.outputEvents = &*output_events_; } else { - reconstructed_process_data.outputEvents = nullptr; + reconstructed_process_data_.outputEvents = nullptr; } - if (process_context) { - reconstructed_process_data.processContext = &*process_context; + if (process_context_) { + reconstructed_process_data_.processContext = &*process_context_; } else { - reconstructed_process_data.processContext = nullptr; + reconstructed_process_data_.processContext = nullptr; } - return reconstructed_process_data; + return reconstructed_process_data_; } YaProcessData::Response& YaProcessData::create_response() noexcept { // NOTE: We return an object that only contains references to these original // fields to avoid any copies or moves - return response_object; + return response_object_; } void YaProcessData::write_back_outputs( Steinberg::Vst::ProcessData& process_data, const AudioShmBuffer& shared_audio_buffers) { - assert(static_cast(outputs.size()) == process_data.numOutputs); + assert(static_cast(outputs_.size()) == process_data.numOutputs); for (int bus = 0; bus < process_data.numOutputs; bus++) { - process_data.outputs[bus].silenceFlags = outputs[bus].silenceFlags; + process_data.outputs[bus].silenceFlags = outputs_[bus].silenceFlags; // NOTE: Some hosts, like Carla, provide more output channels than what // the plugin wants. We'll have already capped // `outputs[bus].numChannels` to the number of channels requested // by the plugin during `YaProcessData::repopulate()`. - for (int channel = 0; channel < outputs[bus].numChannels; channel++) { + for (int channel = 0; channel < outputs_[bus].numChannels; channel++) { // We copy the output audio for every bus from the shared memory // object back to the buffer provided by the host if (process_data.symbolicSampleSize == Steinberg::Vst::kSample64) { @@ -228,12 +231,12 @@ void YaProcessData::write_back_outputs( } } - if (output_parameter_changes && process_data.outputParameterChanges) { - output_parameter_changes->write_back_outputs( + if (output_parameter_changes_ && process_data.outputParameterChanges) { + output_parameter_changes_->write_back_outputs( *process_data.outputParameterChanges); } - if (output_events && process_data.outputEvents) { - output_events->write_back_outputs(*process_data.outputEvents); + if (output_events_ && process_data.outputEvents) { + output_events_->write_back_outputs(*process_data.outputEvents); } } diff --git a/src/common/serialization/vst3/process-data.h b/src/common/serialization/vst3/process-data.h index 890fe179..b19abc66 100644 --- a/src/common/serialization/vst3/process-data.h +++ b/src/common/serialization/vst3/process-data.h @@ -156,24 +156,24 @@ class YaProcessData { template void serialize(S& s) { - s.value4b(process_mode); - s.value4b(symbolic_sample_size); - s.value4b(num_samples); + s.value4b(process_mode_); + s.value4b(symbolic_sample_size_); + s.value4b(num_samples_); // Both of these fields only store metadata. The actual audio is sent // using an accompanying `AudioShmBuffer` object. - s.container(inputs, max_num_speakers); - s.container(outputs, max_num_speakers); + s.container(inputs_, max_num_speakers); + s.container(outputs_, max_num_speakers); // The output parameter changes and events will remain empty on the // plugin side, so by serializing them we merely indicate to the Wine // plugin host whether the host supports them or not - s.object(input_parameter_changes); - s.ext(output_parameter_changes, bitsery::ext::InPlaceOptional{}); - s.ext(input_events, bitsery::ext::InPlaceOptional{}); - s.ext(output_events, bitsery::ext::InPlaceOptional{}); + s.object(input_parameter_changes_); + s.ext(output_parameter_changes_, bitsery::ext::InPlaceOptional{}); + s.ext(input_events_, bitsery::ext::InPlaceOptional{}); + s.ext(output_events_, bitsery::ext::InPlaceOptional{}); - s.ext(process_context, bitsery::ext::InPlaceOptional{}); + s.ext(process_context_, bitsery::ext::InPlaceOptional{}); // We of course won't serialize the `reconstructed_process_data` and all // of the `output*` fields defined below it @@ -185,7 +185,7 @@ class YaProcessData { /** * The processing mode copied directly from the input struct. */ - int32 process_mode; + int32 process_mode_; /** * The symbolic sample size (see `Steinberg::Vst::SymbolicSampleSizes`) is @@ -193,12 +193,12 @@ class YaProcessData { * union of array of either single or double precision floating point * arrays. This field determines which of those variants should be used. */ - int32 symbolic_sample_size; + int32 symbolic_sample_size_; /** * The number of samples in each audio buffer. */ - int32 num_samples; + int32 num_samples_; /** * This contains metadata about the input buffers for every bus. During @@ -206,7 +206,7 @@ class YaProcessData { * be set to point to our shared memory surface that holds the actual audio * data. */ - boost::container::small_vector inputs; + boost::container::small_vector inputs_; /** * This contains metadata about the output buffers for every bus. During @@ -214,35 +214,35 @@ class YaProcessData { * be set to point to our shared memory surface that holds the actual audio * data. */ - boost::container::small_vector outputs; + boost::container::small_vector outputs_; /** * Incoming parameter changes. */ - YaParameterChanges input_parameter_changes; + YaParameterChanges input_parameter_changes_; /** * If the host supports it, this will allow the plugin to output parameter * changes. Otherwise we'll also pass a null pointer to the plugin. */ - std::optional output_parameter_changes; + std::optional output_parameter_changes_; /** * Incoming events. */ - std::optional input_events; + std::optional input_events_; /** * If the host supports it, this will allow the plugin to output events, * such as note events. Otherwise we'll also pass a null pointer to the * plugin. */ - std::optional output_events; + std::optional output_events_; /** * Some more information about the project and transport. */ - std::optional process_context; + std::optional process_context_; private: // These last few members are used on the Wine plugin host side to @@ -260,12 +260,12 @@ class YaProcessData { * directly receive data into this object, avoiding the need for any * allocations. */ - Response response_object; + Response response_object_; /** * The process data we reconstruct from the other fields during `get()`. */ - Steinberg::Vst::ProcessData reconstructed_process_data; + Steinberg::Vst::ProcessData reconstructed_process_data_; }; namespace Steinberg { diff --git a/src/common/utils.cpp b/src/common/utils.cpp index e5e7127e..465ecb5e 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -224,25 +224,25 @@ std::string xml_escape(std::string string) { } ScopedFlushToZero::ScopedFlushToZero() noexcept { - old_ftz_mode = _MM_GET_FLUSH_ZERO_MODE(); + old_ftz_mode_ = _MM_GET_FLUSH_ZERO_MODE(); _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); } ScopedFlushToZero::~ScopedFlushToZero() noexcept { - if (old_ftz_mode) { - _MM_SET_FLUSH_ZERO_MODE(*old_ftz_mode); + if (old_ftz_mode_) { + _MM_SET_FLUSH_ZERO_MODE(*old_ftz_mode_); } } ScopedFlushToZero::ScopedFlushToZero(ScopedFlushToZero&& o) noexcept - : old_ftz_mode(std::move(o.old_ftz_mode)) { - o.old_ftz_mode.reset(); + : old_ftz_mode_(std::move(o.old_ftz_mode_)) { + o.old_ftz_mode_.reset(); } ScopedFlushToZero& ScopedFlushToZero::operator=( ScopedFlushToZero&& o) noexcept { - old_ftz_mode = std::move(o.old_ftz_mode); - o.old_ftz_mode.reset(); + old_ftz_mode_ = std::move(o.old_ftz_mode_); + o.old_ftz_mode_.reset(); return *this; } diff --git a/src/common/utils.h b/src/common/utils.h index e524fbe7..5405026f 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -176,7 +176,7 @@ class ScopedFlushToZero { * don't accidentally end up disabling FTZ somewhere where it should be * enabled. */ - std::optional old_ftz_mode; + std::optional old_ftz_mode_; }; /** @@ -204,7 +204,7 @@ class ScopedValueCache { * Return the cached value, if we're currently caching a value. Will return * a null pointer when this is not the case. */ - const T* get() const noexcept { return value ? &*value : nullptr; } + const T* get() const noexcept { return value_ ? &*value_ : nullptr; } /** * A guard that will reset the cached value on the `ScopedValueCache` when @@ -213,29 +213,29 @@ class ScopedValueCache { class Guard { public: Guard(std::optional& cached_value) noexcept - : cached_value(cached_value) {} + : cached_value_(cached_value) {} ~Guard() noexcept { - if (is_active) { - cached_value.get().reset(); + if (is_active_) { + cached_value_.get().reset(); } } Guard(const Guard&) = delete; Guard& operator=(const Guard&) = delete; - Guard(Guard&& o) noexcept : cached_value(std::move(o.cached_value)) { - o.is_active = false; + Guard(Guard&& o) noexcept : cached_value_(std::move(o.cached_value_)) { + o.is_active_ = false; } Guard& operator=(Guard&& o) noexcept { - cached_value = std::move(o.cached_value); - o.is_active = false; + cached_value_ = std::move(o.cached_value_); + o.is_active_ = false; return *this; } private: - bool is_active = true; - std::reference_wrapper> cached_value; + bool is_active_ = true; + std::reference_wrapper> cached_value_; }; /** @@ -248,9 +248,9 @@ class ScopedValueCache { * @throw std::runtime_error When we are already caching a value. */ Guard set(T new_value) noexcept { - value = std::move(new_value); + value_ = std::move(new_value); - return Guard(value); + return Guard(value_); } private: @@ -258,7 +258,7 @@ class ScopedValueCache { * The current value, if `set()` has been called and the guard is still * active. */ - std::optional value; + std::optional value_; }; /** @@ -279,7 +279,7 @@ class TimedValueCache { */ const T* get() const noexcept { const time_t now = time(nullptr); - return now <= valid_until ? &value : nullptr; + return now <= valid_until_ ? &value_ : nullptr; } /** @@ -290,9 +290,9 @@ class TimedValueCache { */ const T* get_and_keep_alive(unsigned int lifetime_seconds) noexcept { const time_t now = time(nullptr); - if (now <= valid_until) { - valid_until = now + lifetime_seconds; - return &value; + if (now <= valid_until_) { + valid_until_ = now + lifetime_seconds; + return &value_; } else { return nullptr; } @@ -302,11 +302,11 @@ class TimedValueCache { * Set the cached value for `lifetime_seconds` seconds. */ void set(T value, unsigned int lifetime_seconds) noexcept { - this->value = value; - valid_until = time(nullptr) + lifetime_seconds; + value_ = value; + valid_until_ = time(nullptr) + lifetime_seconds; } private: - T value; - time_t valid_until = 0; + T value_; + time_t valid_until_ = 0; }; diff --git a/src/plugin/bridges/common.h b/src/plugin/bridges/common.h index 8dc7365a..98e746eb 100644 --- a/src/plugin/bridges/common.h +++ b/src/plugin/bridges/common.h @@ -79,50 +79,50 @@ class PluginBridge { PluginBridge(PluginType plugin_type, F&& create_socket_instance) // This is still correct for VST3 plugins because we can configure an // entire directory (the module's bundle) at once - : config(load_config_for(get_this_file_location())), - info(plugin_type, config.vst3_prefer_32bit), - io_context(), - sockets(create_socket_instance(io_context, info)), - generic_logger(Logger::create_from_environment( - create_logger_prefix(sockets.base_dir))), - plugin_host( - config.group + : config_(load_config_for(get_this_file_location())), + info_(plugin_type, config_.vst3_prefer_32bit), + io_context_(), + sockets_(create_socket_instance(io_context_, info_)), + generic_logger_(Logger::create_from_environment( + create_logger_prefix(sockets_.base_dir_))), + plugin_host_( + config_.group ? std::unique_ptr(std::make_unique( - io_context, - generic_logger, - config, - sockets, - info, + io_context_, + generic_logger_, + config_, + sockets_, + info_, HostRequest{ .plugin_type = plugin_type, - .plugin_path = info.windows_plugin_path.string(), - .endpoint_base_dir = sockets.base_dir.string(), + .plugin_path = info_.windows_plugin_path_.string(), + .endpoint_base_dir = sockets_.base_dir_.string(), .parent_pid = getpid()})) : std::unique_ptr( std::make_unique( - io_context, - generic_logger, - config, - sockets, - info, - HostRequest{ - .plugin_type = plugin_type, - .plugin_path = - info.windows_plugin_path.string(), - .endpoint_base_dir = sockets.base_dir.string(), - .parent_pid = getpid()}))), - has_realtime_priority(has_realtime_priority_promise.get_future()), - wine_io_handler([&]() { + io_context_, + generic_logger_, + config_, + sockets_, + info_, + HostRequest{.plugin_type = plugin_type, + .plugin_path = + info_.windows_plugin_path_.string(), + .endpoint_base_dir = + sockets_.base_dir_.string(), + .parent_pid = getpid()}))), + has_realtime_priority_(has_realtime_priority_promise_.get_future()), + wine_io_handler_([&]() { // We no longer run this thread with realtime scheduling because // plugins that produce a lot of FIXMEs could in theory cause // dropouts that way, but we still need to run this from a thread // to check whether we support it - has_realtime_priority_promise.set_value( + has_realtime_priority_promise_.set_value( set_realtime_priority(true)); set_realtime_priority(false); pthread_setname_np(pthread_self(), "wine-stdio"); - io_context.run(); + io_context_.run(); }) {} virtual ~PluginBridge() noexcept {}; @@ -139,14 +139,15 @@ class PluginBridge { << " (32-bit build)" #endif << std::endl; - init_msg << "host: '" << plugin_host->path().string() << "'" + init_msg << "host: '" << plugin_host_->path().string() << "'" << std::endl; - init_msg << "plugin: '" << info.windows_plugin_path.string() + init_msg << "plugin: '" << info_.windows_plugin_path_.string() << "'" << std::endl; init_msg << "plugin type: '" - << plugin_type_to_string(info.plugin_type) << "'" << std::endl; + << plugin_type_to_string(info_.plugin_type_) << "'" + << std::endl; init_msg << "realtime: "; - if (has_realtime_priority.get()) { + if (has_realtime_priority_.get()) { // Warn if `RLIMIT_RTTIME` is set to some low value. This can happen // when using PipeWire. if (auto rttime_limit = get_rttime_limit()) { @@ -225,7 +226,7 @@ class PluginBridge { << "memlock limit: 'WARNING: Could not fetch RLIMIT_MEMLOCK'" << std::endl; } - init_msg << "sockets: '" << sockets.base_dir.string() << "'" + init_msg << "sockets: '" << sockets_.base_dir_.string() << "'" << std::endl; init_msg << "wine prefix: '"; @@ -239,10 +240,10 @@ class PluginBridge { }, [&](const DefaultWinePrefix&) { init_msg << ""; }, }, - info.wine_prefix); + info_.wine_prefix_); init_msg << "'" << std::endl; - init_msg << "wine version: '" << info.wine_version() << "'" + init_msg << "wine version: '" << info_.wine_version() << "'" << std::endl; init_msg << std::endl; @@ -251,21 +252,21 @@ class PluginBridge { // useful but it'll be very noisy and it's likely going to be clear from // the shown values anyways. init_msg << "config from: '"; - if (config.matched_file && config.matched_pattern) { - init_msg << config.matched_file->string() << ", section \"" - << *config.matched_pattern << "\""; + if (config_.matched_file && config_.matched_pattern) { + init_msg << config_.matched_file->string() << ", section \"" + << *config_.matched_pattern << "\""; } else { init_msg << ""; } init_msg << "'" << std::endl; init_msg << "hosting mode: '"; - if (config.group) { - init_msg << "plugin group \"" << *config.group << "\""; + if (config_.group) { + init_msg << "plugin group \"" << *config_.group << "\""; } else { init_msg << "individually"; } - switch (info.plugin_arch) { + switch (info_.plugin_arch_) { case LibArchitecture::dll_32: init_msg << ", 32-bit"; break; @@ -277,33 +278,33 @@ class PluginBridge { init_msg << "other options: "; std::vector other_options; - if (config.disable_pipes) { + if (config_.disable_pipes) { other_options.push_back( "hack: pipes disabled, plugin output will go to \"" + - config.disable_pipes->string() + "\""); + config_.disable_pipes->string() + "\""); } - if (config.editor_coordinate_hack) { + if (config_.editor_coordinate_hack) { other_options.push_back("editor: coordinate hack"); } - if (config.editor_force_dnd) { + if (config_.editor_force_dnd) { other_options.push_back("editor: force drag-and-drop"); } - if (config.editor_xembed) { + if (config_.editor_xembed) { other_options.push_back("editor: XEmbed"); } - if (config.frame_rate) { + if (config_.frame_rate) { std::ostringstream option; option << "frame rate: " << std::setprecision(2) - << *config.frame_rate << " fps"; + << *config_.frame_rate << " fps"; other_options.push_back(option.str()); } - if (config.hide_daw) { + if (config_.hide_daw) { other_options.push_back("hack: hide DAW name"); } - if (config.vst3_no_scaling) { + if (config_.vst3_no_scaling) { other_options.push_back("vst3: no GUI scaling"); } - if (config.vst3_prefer_32bit) { + if (config_.vst3_prefer_32bit) { other_options.push_back("vst3: prefer 32-bit"); } if (!other_options.empty()) { @@ -315,14 +316,14 @@ class PluginBridge { // To make debugging easier, we'll print both unrecognized options (that // might be left over when an option gets removed) as well as options // have the wrong argument types - if (!config.invalid_options.empty()) { + if (!config_.invalid_options.empty()) { init_msg << "invalid arguments: " - << join_quoted_strings(config.invalid_options) + << join_quoted_strings(config_.invalid_options) << " (check the readme for more information)" << std::endl; } - if (!config.unknown_options.empty()) { + if (!config_.unknown_options.empty()) { init_msg << "unrecognized options: " - << join_quoted_strings(config.unknown_options) + << join_quoted_strings(config_.unknown_options) << std::endl; } init_msg << std::endl; @@ -345,7 +346,7 @@ class PluginBridge { init_msg << std::endl; for (std::string line = ""; std::getline(init_msg, line);) { - generic_logger.log(line); + generic_logger_.log(line); } } @@ -367,14 +368,14 @@ class PluginBridge { // and throw when it is not. The alternative would be to rewrite this to // using `async_accept`, Boost.Asio timers, and another IO context, but // I feel like this a much simpler solution. - host_watchdog_handler = std::jthread([&](std::stop_token st) { + host_watchdog_handler_ = std::jthread([&](std::stop_token st) { using namespace std::literals::chrono_literals; pthread_setname_np(pthread_self(), "watchdog"); while (!st.stop_requested()) { - if (!plugin_host->running()) { - generic_logger.log( + if (!plugin_host_->running()) { + generic_logger_.log( "The Wine host process has exited unexpectedly. Check " "the output above for more information."); @@ -396,9 +397,9 @@ class PluginBridge { }); #endif - sockets.connect(); + sockets_.connect(); #ifndef WITH_WINEDBG - host_watchdog_handler.request_stop(); + host_watchdog_handler_.request_stop(); #endif } @@ -410,13 +411,13 @@ class PluginBridge { */ void warn_on_version_mismatch(const std::string& host_version) { if (host_version != yabridge_git_version) { - generic_logger.log( + generic_logger_.log( "WARNING: The host application's version does not match"); - generic_logger.log( + generic_logger_.log( " this plugin's. If you just updated yabridge, then"); - generic_logger.log( + generic_logger_.log( " you may need rerun 'yabridgectl sync' first to"); - generic_logger.log(" update your plugins."); + generic_logger_.log(" update your plugins."); send_notification( "Version mismatch", @@ -432,24 +433,24 @@ class PluginBridge { * * @see ../utils.h:load_config_for */ - Configuration config; + Configuration config_; /** * Information about the plugin we're bridging. */ - const PluginInfo info; + const PluginInfo info_; - boost::asio::io_context io_context; + boost::asio::io_context io_context_; /** * The sockets used for communication with the Wine process. * - * @remark `sockets.connect()` should not be called directly. + * @remark `sockets_.connect()` should not be called directly. * `connect_sockets_guarded()` should be used instead. * * @see PluginBridge::connect_sockets_guarded */ - TSockets sockets; + TSockets sockets_; /** * The logging facility used for this instance of yabridge. See @@ -457,20 +458,20 @@ class PluginBridge { * * @see Logger::create_from_env */ - Logger generic_logger; + Logger generic_logger_; /** * The Wine process hosting our plugins. In the case of group hosts a * `PluginBridge` instance doesn't actually own a process, but rather either * spawns a new detached process or it connects to an existing one. */ - std::unique_ptr plugin_host; + std::unique_ptr plugin_host_; private: /** - * The promise belonging to `has_realtime_priority` below. + * The promise belonging to `has_realtime_priority_` below. */ - std::promise has_realtime_priority_promise; + std::promise has_realtime_priority_promise_; public: /** @@ -480,13 +481,13 @@ class PluginBridge { * that's initializing the plugin because some DAWs may do that from the UI * thread. */ - std::future has_realtime_priority; + std::future has_realtime_priority_; /** - * Runs the Boost.Asio `io_context` thread for logging the Wine process + * Runs the Boost.Asio `io_context_` thread for logging the Wine process * STDOUT and STDERR messages. */ - std::jthread wine_io_handler; + std::jthread wine_io_handler_; private: /** @@ -496,5 +497,5 @@ class PluginBridge { * detach the thread as it has to check whether the VST host is still * running. */ - std::jthread host_watchdog_handler; + std::jthread host_watchdog_handler_; }; diff --git a/src/plugin/bridges/vst2.cpp b/src/plugin/bridges/vst2.cpp index a92a19c9..3f2a180a 100644 --- a/src/plugin/bridges/vst2.cpp +++ b/src/plugin/bridges/vst2.cpp @@ -41,7 +41,7 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) [](boost::asio::io_context& io_context, const PluginInfo& info) { return Vst2Sockets( io_context, - generate_endpoint_base(info.native_library_path.filename() + generate_endpoint_base(info.native_library_path_.filename() .replace_extension("") .string()), true); @@ -49,9 +49,9 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) // All the fields should be zero initialized because // `Vst2PluginInstance::vstAudioMasterCallback` from Bitwig's plugin // bridge will crash otherwise - plugin(), - host_callback_function(host_callback), - logger(generic_logger) { + plugin_(), + host_callback_function_(host_callback), + logger_(generic_logger_) { log_init_message(); // This will block until all sockets have been connected to by the Wine VST @@ -60,23 +60,23 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) // Set up all pointers for our `AEffect` struct. We will fill this with data // from the VST plugin loaded in Wine at the end of this constructor. - plugin.ptr3 = this; - plugin.dispatcher = dispatch_proxy; - plugin.process = process_proxy; - plugin.setParameter = set_parameter_proxy; - plugin.getParameter = get_parameter_proxy; - plugin.processReplacing = process_replacing_proxy; - plugin.processDoubleReplacing = process_double_replacing_proxy; + plugin_.ptr3 = this; + plugin_.dispatcher = dispatch_proxy; + plugin_.process = process_proxy; + plugin_.setParameter = set_parameter_proxy; + plugin_.getParameter = get_parameter_proxy; + plugin_.processReplacing = process_replacing_proxy; + plugin_.processDoubleReplacing = process_double_replacing_proxy; // For our communication we use simple threads and blocking operations // instead of asynchronous IO since communication has to be handled in // lockstep anyway - host_callback_handler = std::jthread([&]() { + host_callback_handler_ = std::jthread([&]() { set_realtime_priority(true); pthread_setname_np(pthread_self(), "host-callbacks"); - sockets.vst_host_callback.receive_events( - std::pair(logger, false), + sockets_.vst_host_callback_.receive_events( + std::pair(logger_, false), [&](Vst2Event& event, bool /*on_main_thread*/) { switch (event.opcode) { // MIDI events sent from the plugin back to the host are @@ -87,9 +87,9 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) // actually send them to the host at the end of the // `process_replacing()` function. case audioMasterProcessEvents: { - std::lock_guard lock(incoming_midi_events_mutex); + std::lock_guard lock(incoming_midi_events_mutex_); - incoming_midi_events.push_back( + incoming_midi_events_.push_back( std::get(event.payload)); return Vst2EventResult{.return_value = 1, @@ -102,9 +102,9 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) // store the last resize request and then only pass it to // the host when it calls `effEditIdle()`. case audioMasterSizeWindow: { - std::lock_guard lock(incoming_resize_mutex); + std::lock_guard lock(incoming_resize_mutex_); - incoming_resize = std::pair(event.index, event.value); + incoming_resize_ = std::pair(event.index, event.value); return Vst2EventResult{.return_value = 1, .payload = nullptr, @@ -120,11 +120,13 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) // initialization, and at that point we will not yet // have sent the configuration to the plugin. case audioMasterGetProductString: { - if (config.hide_daw) { - logger.log("The plugin asked for the host's name."); - logger.log("Reporting \"" + - std::string(product_name_override) + - "\" instead of the actual host's name."); + if (config_.hide_daw) { + logger_.log( + "The plugin asked for the host's name."); + logger_.log( + "Reporting \"" + + std::string(product_name_override) + + "\" instead of the actual host's name."); return Vst2EventResult{ .return_value = 1, @@ -133,10 +135,10 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) } } break; case audioMasterGetVendorString: { - if (config.hide_daw) { - logger.log( + if (config_.hide_daw) { + logger_.log( "The plugin asked for the host's vendor."); - logger.log( + logger_.log( "Reporting \"" + std::string(vendor_name_override) + "\" instead of the actual host's vendor."); @@ -148,14 +150,14 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) } } break; case audioMasterDeadBeef: - logger.log(""); - logger.log( + logger_.log(""); + logger_.log( " The plugin wants to use REAPER's host vendor"); - logger.log( + logger_.log( " extensions which currently aren't supported " "by"); - logger.log(" yabridge. Ignoring the request."); - logger.log(""); + logger_.log(" yabridge. Ignoring the request."); + logger_.log(""); return Vst2EventResult{.return_value = 0, .payload = nullptr, @@ -163,7 +165,7 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) break; } - return passthrough_event(&plugin, host_callback_function, + return passthrough_event(&plugin_, host_callback_function_, event); }); }); @@ -174,7 +176,7 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) // over the `dispatcher()` socket. This would happen whenever the plugin // calls `audioMasterIOChanged()` and after the host calls `effOpen()`. const auto initialization_data = - sockets.host_vst_control.receive_single(); + sockets_.host_vst_control_.receive_single(); const auto initialized_plugin = std::get(initialization_data.payload); @@ -184,19 +186,19 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback) // After receiving the `AEffect` values we'll want to send the configuration // back to complete the startup process - sockets.host_vst_control.send(config); + sockets_.host_vst_control_.send(config_); - update_aeffect(plugin, initialized_plugin); + update_aeffect(plugin_, initialized_plugin); } Vst2PluginBridge::~Vst2PluginBridge() noexcept { try { // Drop all work make sure all sockets are closed - plugin_host->terminate(); + plugin_host_->terminate(); // The `stop()` method will cause the IO context to just drop all of its // outstanding work immediately - io_context.stop(); + io_context_.stop(); } catch (const boost::system::system_error&) { // It could be that the sockets have already been closed or that the // process has already exited (at which point we probably won't be @@ -210,10 +212,10 @@ class DispatchDataConverter : public DefaultDataConverter { std::vector& chunk_data, AEffect& plugin, VstRect& editor_rectangle) noexcept - : process_buffers(process_buffers), - chunk(chunk_data), - plugin(plugin), - rect(editor_rectangle) {} + : process_buffers_(process_buffers), + chunk_(chunk_data), + plugin_(plugin), + rect_(editor_rectangle) {} Vst2Event::Payload read_data(const int opcode, const int index, @@ -376,16 +378,16 @@ class DispatchDataConverter : public DefaultDataConverter { // any notification about this. const auto& updated_plugin = std::get(response.payload); - update_aeffect(plugin, updated_plugin); + update_aeffect(plugin_, updated_plugin); } break; case effMainsChanged: { if (const auto* audio_buffer_config = std::get_if( &response.payload)) { - if (!process_buffers) { - process_buffers.emplace(*audio_buffer_config); + if (!process_buffers_) { + process_buffers_.emplace(*audio_buffer_config); } else { - process_buffers->resize(*audio_buffer_config); + process_buffers_->resize(*audio_buffer_config); } } } break; @@ -397,9 +399,9 @@ class DispatchDataConverter : public DefaultDataConverter { } const auto& new_rect = std::get(response.payload); - rect = new_rect; + rect_ = new_rect; - *static_cast(data) = ▭ + *static_cast(data) = &rect_; } break; case effGetChunk: { // Write the chunk data to some publically accessible place in @@ -407,9 +409,9 @@ class DispatchDataConverter : public DefaultDataConverter { // data pointer const auto& buffer = std::get(response.payload).buffer; - chunk.assign(buffer.begin(), buffer.end()); + chunk_.assign(buffer.begin(), buffer.end()); - *static_cast(data) = chunk.data(); + *static_cast(data) = chunk_.data(); } break; case effGetInputProperties: case effGetOutputProperties: { @@ -492,10 +494,10 @@ class DispatchDataConverter : public DefaultDataConverter { } private: - std::optional& process_buffers; - std::vector& chunk; - AEffect& plugin; - VstRect& rect; + std::optional& process_buffers_; + std::vector& chunk_; + AEffect& plugin_; + VstRect& rect_; }; intptr_t Vst2PluginBridge::dispatch(AEffect* /*plugin*/, @@ -510,19 +512,19 @@ intptr_t Vst2PluginBridge::dispatch(AEffect* /*plugin*/, // been a release that contains the fix yet. This should be removed // once Ardour 6.0 gets released. // https://tracker.ardour.org/view.php?id=7668 - if (plugin.magic == 0) [[unlikely]] { - logger.log_event(true, opcode, index, value, nullptr, option, - std::nullopt); - logger.log( + if (plugin_.magic == 0) [[unlikely]] { + logger_.log_event(true, opcode, index, value, nullptr, option, + std::nullopt); + logger_.log( " Warning: The host has dispatched an event before the plugin " "has finished initializing, ignoring the event. (are we running " "Ardour 5.X?)"); - logger.log_event_response(true, opcode, 0, nullptr, std::nullopt); + logger_.log_event_response(true, opcode, 0, nullptr, std::nullopt); return 0; } - DispatchDataConverter converter(process_buffers, chunk_data, plugin, - editor_rectangle); + DispatchDataConverter converter(process_buffers_, chunk_data_, plugin_, + editor_rectangle_); switch (opcode) { case effClose: { @@ -533,13 +535,13 @@ intptr_t Vst2PluginBridge::dispatch(AEffect* /*plugin*/, intptr_t return_value = 0; try { // TODO: Add some kind of timeout? - return_value = sockets.host_vst_dispatch.send_event( - converter, std::pair(logger, true), + return_value = sockets_.host_vst_dispatch_.send_event( + converter, std::pair(logger_, true), opcode, index, value, data, option); } catch (const boost::system::system_error&) { // Thrown when the socket gets closed because the VST plugin // loaded into the Wine process crashed during shutdown - logger.log("The plugin crashed during shutdown, ignoring"); + logger_.log("The plugin crashed during shutdown, ignoring"); } delete this; @@ -555,26 +557,26 @@ intptr_t Vst2PluginBridge::dispatch(AEffect* /*plugin*/, // from a non-GUI thread (which could cause issues), or we would // need a timer anyways to proc the function when the GUI is being // blocked by for instance an open dropdown. - logger.log_event(true, opcode, index, value, nullptr, option, - std::nullopt); + logger_.log_event(true, opcode, index, value, nullptr, option, + std::nullopt); // REAPER requires `audioMasterSizeWindow()` calls to be done from // the GUI thread. In every other host this doesn't make a // difference, but in REAPER the FX window only resizes when this is // called from here. { - std::unique_lock lock(incoming_resize_mutex); - if (incoming_resize) { - const auto& [width, height] = *incoming_resize; - incoming_resize.reset(); + std::unique_lock lock(incoming_resize_mutex_); + if (incoming_resize_) { + const auto& [width, height] = *incoming_resize_; + incoming_resize_.reset(); lock.unlock(); - host_callback_function(&plugin, audioMasterSizeWindow, - width, height, nullptr, 0.0); + host_callback_function_(&plugin_, audioMasterSizeWindow, + width, height, nullptr, 0.0); } } - logger.log_event_response(true, opcode, 0, nullptr, std::nullopt); + logger_.log_event_response(true, opcode, 0, nullptr, std::nullopt); return 0; }; break; case effCanDo: { @@ -585,20 +587,20 @@ intptr_t Vst2PluginBridge::dispatch(AEffect* /*plugin*/, // window ID to `effEditOpen`. This is of course not going to // work when the GUI is handled using Wine so we'll ignore it. if (query == "hasCockosViewAsConfig") { - logger.log_event(true, opcode, index, value, query, option, - std::nullopt); + logger_.log_event(true, opcode, index, value, query, option, + std::nullopt); - logger.log(""); - logger.log( + logger_.log(""); + logger_.log( " The host has requested libSwell GUI support, which is"); - logger.log(" not supported when using Wine."); - logger.log( + logger_.log(" not supported when using Wine."); + logger_.log( " You can safely ignore this message; this is normal"); - logger.log(" when using REAPER."); - logger.log(""); + logger_.log(" when using REAPER."); + logger_.log(""); - logger.log_event_response(true, opcode, -1, nullptr, - std::nullopt); + logger_.log_event_response(true, opcode, -1, nullptr, + std::nullopt); return -1; } } break; @@ -609,8 +611,8 @@ intptr_t Vst2PluginBridge::dispatch(AEffect* /*plugin*/, // and loading plugin state it's much better to have bitsery or our // receiving function temporarily allocate a large enough buffer rather than // to have a bunch of allocated memory sitting around doing nothing. - return sockets.host_vst_dispatch.send_event( - converter, std::pair(logger, true), opcode, index, + return sockets_.host_vst_dispatch_.send_event( + converter, std::pair(logger_, true), opcode, index, value, data, option); } @@ -630,8 +632,8 @@ void Vst2PluginBridge::do_process(T** inputs, T** outputs, int sample_frames) { // VeSTige headers, let's just set all of them! const VstTimeInfo* returned_time_info = reinterpret_cast( - host_callback_function(&plugin, audioMasterGetTime, 0, - ~static_cast(0), nullptr, 0.0)); + host_callback_function_(&plugin_, audioMasterGetTime, 0, + ~static_cast(0), nullptr, 0.0)); if (returned_time_info) { request.current_time_info = *returned_time_info; } else { @@ -640,16 +642,16 @@ void Vst2PluginBridge::do_process(T** inputs, T** outputs, int sample_frames) { // Some plugisn also ask for the current process level, so we'll prefetch // that information as well - request.current_process_level = static_cast(host_callback_function( - &plugin, audioMasterGetCurrentProcessLevel, 0, 0, nullptr, 0.0)); + request.current_process_level = static_cast(host_callback_function_( + &plugin_, audioMasterGetCurrentProcessLevel, 0, 0, nullptr, 0.0)); // We'll synchronize the scheduling priority of the audio thread on the Wine // plugin host with that of the host's audio thread every once in a while const time_t now = time(nullptr); - if (now > last_audio_thread_priority_synchronization + + if (now > last_audio_thread_priority_synchronization_ + audio_thread_priority_synchronization_interval) { request.new_realtime_priority = get_realtime_priority(); - last_audio_thread_priority_synchronization = now; + last_audio_thread_priority_synchronization_ = now; } else { request.new_realtime_priority.reset(); } @@ -675,25 +677,25 @@ void Vst2PluginBridge::do_process(T** inputs, T** outputs, int sample_frames) { // The host should have called `effMainsChanged()` before sending audio to // process - assert(process_buffers); - for (int channel = 0; channel < plugin.numInputs; channel++) { - T* input_channel = process_buffers->input_channel_ptr(0, channel); + assert(process_buffers_); + for (int channel = 0; channel < plugin_.numInputs; channel++) { + T* input_channel = process_buffers_->input_channel_ptr(0, channel); std::copy_n(inputs[channel], sample_frames, input_channel); } // After writing audio to the shared memory buffers, we'll send the // processing request parameters to the Wine plugin host so it can start // processing audio. This is why we don't need any explicit synchronisation. - sockets.host_vst_process_replacing.send(request); + sockets_.host_vst_process_replacing_.send(request); // From the Wine side we'll send a zero byte struct back as an // acknowledgement that audio processing has finished. At this point the // audio will have been written to our buffers. - sockets.host_vst_process_replacing.receive_single(); + sockets_.host_vst_process_replacing_.receive_single(); - for (int channel = 0; channel < plugin.numOutputs; channel++) { + for (int channel = 0; channel < plugin_.numOutputs; channel++) { const T* output_channel = - process_buffers->output_channel_ptr(0, channel); + process_buffers_->output_channel_ptr(0, channel); if constexpr (replacing) { std::copy_n(output_channel, sample_frames, outputs[channel]); @@ -720,13 +722,13 @@ void Vst2PluginBridge::do_process(T** inputs, T** outputs, int sample_frames) { // prevent these events from getting delayed by a sample we'll process them // after the plugin is done processing audio rather than during the time // we're still waiting on the plugin. - std::lock_guard lock(incoming_midi_events_mutex); - for (DynamicVstEvents& events : incoming_midi_events) { - host_callback_function(&plugin, audioMasterProcessEvents, 0, 0, - &events.as_c_events(), 0.0); + std::lock_guard lock(incoming_midi_events_mutex_); + for (DynamicVstEvents& events : incoming_midi_events_) { + host_callback_function_(&plugin_, audioMasterProcessEvents, 0, 0, + &events.as_c_events(), 0.0); } - incoming_midi_events.clear(); + incoming_midi_events_.clear(); } void Vst2PluginBridge::process(AEffect* /*plugin*/, @@ -736,31 +738,31 @@ void Vst2PluginBridge::process(AEffect* /*plugin*/, // Technically either `Vst2PluginBridge::process()` or // `Vst2PluginBridge::process_replacing()` could actually call the other // function on the plugin depending on what the plugin supports. - logger.log_trace([]() { return ">> process() :: start"; }); + logger_.log_trace([]() { return ">> process() :: start"; }); do_process(inputs, outputs, sample_frames); - logger.log_trace([]() { return " process() :: end"; }); + logger_.log_trace([]() { return " process() :: end"; }); } void Vst2PluginBridge::process_replacing(AEffect* /*plugin*/, float** inputs, float** outputs, int sample_frames) { - logger.log_trace([]() { return ">> processReplacing() :: start"; }); + logger_.log_trace([]() { return ">> processReplacing() :: start"; }); do_process(inputs, outputs, sample_frames); - logger.log_trace([]() { return " processReplacing() :: end"; }); + logger_.log_trace([]() { return " processReplacing() :: end"; }); } void Vst2PluginBridge::process_double_replacing(AEffect* /*plugin*/, double** inputs, double** outputs, int sample_frames) { - logger.log_trace([]() { return ">> processDoubleReplacing() :: start"; }); + logger_.log_trace([]() { return ">> processDoubleReplacing() :: start"; }); do_process(inputs, outputs, sample_frames); - logger.log_trace([]() { return " processDoubleReplacing() :: end"; }); + logger_.log_trace([]() { return " processDoubleReplacing() :: end"; }); } float Vst2PluginBridge::get_parameter(AEffect* /*plugin*/, int index) { - logger.log_get_parameter(index); + logger_.log_get_parameter(index); const Parameter request{index, std::nullopt}; ParameterResult response; @@ -768,14 +770,14 @@ float Vst2PluginBridge::get_parameter(AEffect* /*plugin*/, int index) { // Prevent race conditions from `getParameter()` and `setParameter()` being // called at the same time since they share the same socket { - std::lock_guard lock(parameters_mutex); - sockets.host_vst_parameters.send(request); + std::lock_guard lock(parameters_mutex_); + sockets_.host_vst_parameters_.send(request); response = - sockets.host_vst_parameters.receive_single(); + sockets_.host_vst_parameters_.receive_single(); } - logger.log_get_parameter_response(*response.value); + logger_.log_get_parameter_response(*response.value); return *response.value; } @@ -783,20 +785,20 @@ float Vst2PluginBridge::get_parameter(AEffect* /*plugin*/, int index) { void Vst2PluginBridge::set_parameter(AEffect* /*plugin*/, int index, float value) { - logger.log_set_parameter(index, value); + logger_.log_set_parameter(index, value); const Parameter request{index, value}; ParameterResult response; { - std::lock_guard lock(parameters_mutex); - sockets.host_vst_parameters.send(request); + std::lock_guard lock(parameters_mutex_); + sockets_.host_vst_parameters_.send(request); response = - sockets.host_vst_parameters.receive_single(); + sockets_.host_vst_parameters_.receive_single(); } - logger.log_set_parameter_response(); + logger_.log_set_parameter_response(); // This should not contain any values and just serve as an acknowledgement assert(!response.value); diff --git a/src/plugin/bridges/vst2.h b/src/plugin/bridges/vst2.h index 6a762765..a396fb04 100644 --- a/src/plugin/bridges/vst2.h +++ b/src/plugin/bridges/vst2.h @@ -126,13 +126,13 @@ class Vst2PluginBridge : PluginBridge> { * VST host during initialization and then passed as a pointer to the Linux * native VST host from the Linux VST plugin's entry point. */ - AEffect plugin; + AEffect plugin_; private: /** * The thread that handles host callbacks. */ - std::jthread host_callback_handler; + std::jthread host_callback_handler_; /** * A mutex to prevent multiple simultaneous calls to `getParameter()` and @@ -140,18 +140,18 @@ class Vst2PluginBridge : PluginBridge> { * For `dispatch()` and `audioMaster()` there's some more complex logic for * this in `Vst2EventHandler`. */ - std::mutex parameters_mutex; + std::mutex parameters_mutex_; /** * The callback function passed by the host to the VST plugin instance. */ - audioMasterCallback host_callback_function; + audioMasterCallback host_callback_function_; /** * The logging facility used for this instance of yabridge. Wraps around * `PluginBridge::generic_logger`. */ - Vst2Logger logger; + Vst2Logger logger_; /** * A shared memory object that contains both the input and output audio @@ -165,14 +165,14 @@ class Vst2PluginBridge : PluginBridge> { * * This will be a nullopt until `effMainsChanged` has been called. */ - std::optional process_buffers; + std::optional process_buffers_; /** * We'll periodically synchronize the Wine host's audio thread priority with * that of the host. Since the overhead from doing so does add up, we'll * only do this every once in a while. */ - time_t last_audio_thread_priority_synchronization = 0; + time_t last_audio_thread_priority_synchronization_ = 0; /** * The VST host can query a plugin for arbitrary binary data such as @@ -180,12 +180,12 @@ class Vst2PluginBridge : PluginBridge> { * that data. This vector is where we store the chunk data for the last * `effGetChunk` event. */ - std::vector chunk_data; + std::vector chunk_data_; /** * The VST host will expect to be returned a pointer to a struct that stores * the dimensions of the editor window. */ - VstRect editor_rectangle; + VstRect editor_rectangle_; /** * Sending MIDI events sent to the host by the plugin using @@ -196,12 +196,12 @@ class Vst2PluginBridge : PluginBridge> { * we receive so we can send them to host on the audio thread at the end of * `process_replacing()`. */ - boost::container::small_vector incoming_midi_events; + boost::container::small_vector incoming_midi_events_; /** * Mutex for locking the above event queue, since recieving and processing * now happens in two different threads. */ - std::mutex incoming_midi_events_mutex; + std::mutex incoming_midi_events_mutex_; /** * REAPER requires us to call `audioMasterSizeWidnow()` from the same thread @@ -211,6 +211,6 @@ class Vst2PluginBridge : PluginBridge> { * `audioMasterSizeWindow`. If this contains a value, we'll then call * `audioMasterSizeWindow()` with the new size during `effEditIdle()`. */ - std::optional> incoming_resize; - std::mutex incoming_resize_mutex; + std::optional> incoming_resize_; + std::mutex incoming_resize_mutex_; }; diff --git a/src/plugin/bridges/vst3-impls/context-menu-target.cpp b/src/plugin/bridges/vst3-impls/context-menu-target.cpp index c5bcd72d..fb089a19 100644 --- a/src/plugin/bridges/vst3-impls/context-menu-target.cpp +++ b/src/plugin/bridges/vst3-impls/context-menu-target.cpp @@ -18,20 +18,21 @@ YaContextMenuTargetImpl::YaContextMenuTargetImpl(Vst3PluginBridge& bridge, ConstructArgs&& args) noexcept - : YaContextMenuTarget(std::move(args)), bridge(bridge) {} + : YaContextMenuTarget(std::move(args)), bridge_(bridge) {} tresult PLUGIN_API YaContextMenuTargetImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { const tresult result = YaContextMenuTarget::queryInterface(_iid, obj); - bridge.logger.log_query_interface("In IContextMenuTarget::queryInterface()", - result, Steinberg::FUID::fromTUID(_iid)); + bridge_.logger_.log_query_interface( + "In IContextMenuTarget::queryInterface()", result, + Steinberg::FUID::fromTUID(_iid)); return result; } tresult PLUGIN_API YaContextMenuTargetImpl::executeMenuItem(int32 tag) { - return bridge.send_message(YaContextMenuTarget::ExecuteMenuItem{ + return bridge_.send_message(YaContextMenuTarget::ExecuteMenuItem{ .owner_instance_id = owner_instance_id(), .context_menu_id = context_menu_id(), .target_tag = target_tag(), diff --git a/src/plugin/bridges/vst3-impls/context-menu-target.h b/src/plugin/bridges/vst3-impls/context-menu-target.h index 2d04a818..3bb75b2c 100644 --- a/src/plugin/bridges/vst3-impls/context-menu-target.h +++ b/src/plugin/bridges/vst3-impls/context-menu-target.h @@ -34,5 +34,5 @@ class YaContextMenuTargetImpl : public YaContextMenuTarget { tresult PLUGIN_API executeMenuItem(int32 tag) override; private: - Vst3PluginBridge& bridge; + Vst3PluginBridge& bridge_; }; diff --git a/src/plugin/bridges/vst3-impls/plug-view-proxy.cpp b/src/plugin/bridges/vst3-impls/plug-view-proxy.cpp index 761aa9ba..60f72036 100644 --- a/src/plugin/bridges/vst3-impls/plug-view-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plug-view-proxy.cpp @@ -17,10 +17,10 @@ #include "plug-view-proxy.h" RunLoopTasks::RunLoopTasks(Steinberg::IPtr plug_frame) - : run_loop(plug_frame) { + : run_loop_(plug_frame) { FUNKNOWN_CTOR - if (!run_loop) { + if (!run_loop_) { throw std::runtime_error( "The host's 'IPlugFrame' object does not support 'IRunLoop'"); } @@ -32,9 +32,9 @@ RunLoopTasks::RunLoopTasks(Steinberg::IPtr plug_frame) throw std::runtime_error("Failed to create a Unix domain socket"); } - socket_read_fd = sockets[0]; - socket_write_fd = sockets[1]; - if (run_loop->registerEventHandler(this, socket_read_fd) != + socket_read_fd_ = sockets[0]; + socket_write_fd_ = sockets[1]; + if (run_loop_->registerEventHandler(this, socket_read_fd_) != Steinberg::kResultOk) { throw std::runtime_error( "Failed to register an event handler with the host's run loop"); @@ -44,9 +44,9 @@ RunLoopTasks::RunLoopTasks(Steinberg::IPtr plug_frame) RunLoopTasks::~RunLoopTasks() { FUNKNOWN_DTOR - run_loop->unregisterEventHandler(this); - close(socket_read_fd); - close(socket_write_fd); + run_loop_->unregisterEventHandler(this); + close(socket_read_fd_); + close(socket_write_fd_); } #pragma GCC diagnostic push @@ -57,38 +57,38 @@ IMPLEMENT_FUNKNOWN_METHODS(RunLoopTasks, #pragma GCC diagnostic pop void RunLoopTasks::schedule(fu2::unique_function task) { - std::lock_guard eventfd_lock(tasks_mutex); - tasks.push_back(std::move(task)); + std::lock_guard eventfd_lock(tasks_mutex_); + tasks_.push_back(std::move(task)); uint8_t notify_value = 1; - assert(write(socket_write_fd, ¬ify_value, sizeof(notify_value)) == + assert(write(socket_write_fd_, ¬ify_value, sizeof(notify_value)) == sizeof(notify_value)); } void PLUGIN_API RunLoopTasks::onFDIsSet(Steinberg::Linux::FileDescriptor /*fd*/) { - std::lock_guard lock(tasks_mutex); + std::lock_guard lock(tasks_mutex_); // Run all tasks that have been submitted to our queue from the host's // calling thread (which will be the GUI thread) - for (auto& task : tasks) { + for (auto& task : tasks_) { task(); // This should in theory stop the host from calling this function, but // REAPER doesn't care. And funnily enough we only have to do all of // this because of REAPER. uint8_t notify_value; - assert(read(socket_read_fd, ¬ify_value, sizeof(notify_value)) == + assert(read(socket_read_fd_, ¬ify_value, sizeof(notify_value)) == sizeof(notify_value)); } - tasks.clear(); + tasks_.clear(); } Vst3PlugViewProxyImpl::Vst3PlugViewProxyImpl( Vst3PluginBridge& bridge, Vst3PlugViewProxy::ConstructArgs&& args) noexcept - : Vst3PlugViewProxy(std::move(args)), bridge(bridge) {} + : Vst3PlugViewProxy(std::move(args)), bridge_(bridge) {} Vst3PlugViewProxyImpl::~Vst3PlugViewProxyImpl() noexcept { // Also drop the plug view smart pointer on the Wine side when this gets @@ -96,15 +96,16 @@ Vst3PlugViewProxyImpl::~Vst3PlugViewProxyImpl() noexcept { // NOTE: This can actually throw (e.g. out of memory or the socket got // closed). But if that were to happen, then we wouldn't be able to // recover from it anyways. - bridge.send_mutually_recursive_message( + bridge_.send_mutually_recursive_message( Vst3PlugViewProxy::Destruct{.owner_instance_id = owner_instance_id()}); } tresult PLUGIN_API Vst3PlugViewProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { const tresult result = Vst3PlugViewProxy::queryInterface(_iid, obj); - bridge.logger.log_query_interface("In IPlugView::queryInterface()", result, - Steinberg::FUID::fromTUID(_iid)); + bridge_.logger_.log_query_interface("In IPlugView::queryInterface()", + result, + Steinberg::FUID::fromTUID(_iid)); return result; } @@ -114,11 +115,11 @@ Vst3PlugViewProxyImpl::isPlatformTypeSupported(Steinberg::FIDString type) { if (type) { // We'll swap the X11 window ID platform type string for the Win32 HWND // equivalent on the Wine side - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaPlugView::IsPlatformTypeSupported{ .owner_instance_id = owner_instance_id(), .type = type}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IPlugView::isPlatformTypeSupported()'"); return Steinberg::kInvalidArgument; @@ -130,31 +131,31 @@ tresult PLUGIN_API Vst3PlugViewProxyImpl::attached(void* parent, if (parent && type) { // We will embed the Wine Win32 window into the X11 window provided by // the host - return bridge.send_mutually_recursive_message(YaPlugView::Attached{ + return bridge_.send_mutually_recursive_message(YaPlugView::Attached{ .owner_instance_id = owner_instance_id(), .parent = reinterpret_cast(parent), .type = type}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to 'IPlugView::attached()'"); return Steinberg::kInvalidArgument; } } tresult PLUGIN_API Vst3PlugViewProxyImpl::removed() { - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaPlugView::Removed{.owner_instance_id = owner_instance_id()}); } tresult PLUGIN_API Vst3PlugViewProxyImpl::onWheel(float distance) { - return bridge.send_mutually_recursive_message(YaPlugView::OnWheel{ + return bridge_.send_mutually_recursive_message(YaPlugView::OnWheel{ .owner_instance_id = owner_instance_id(), .distance = distance}); } tresult PLUGIN_API Vst3PlugViewProxyImpl::onKeyDown(char16 key, int16 keyCode, int16 modifiers) { - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaPlugView::OnKeyDown{.owner_instance_id = owner_instance_id(), .key = key, .key_code = keyCode, @@ -164,7 +165,7 @@ tresult PLUGIN_API Vst3PlugViewProxyImpl::onKeyDown(char16 key, tresult PLUGIN_API Vst3PlugViewProxyImpl::onKeyUp(char16 key, int16 keyCode, int16 modifiers) { - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaPlugView::OnKeyUp{.owner_instance_id = owner_instance_id(), .key = key, .key_code = keyCode, @@ -173,14 +174,15 @@ tresult PLUGIN_API Vst3PlugViewProxyImpl::onKeyUp(char16 key, tresult PLUGIN_API Vst3PlugViewProxyImpl::getSize(Steinberg::ViewRect* size) { if (size) { - const GetSizeResponse response = bridge.send_mutually_recursive_message( - YaPlugView::GetSize{.owner_instance_id = owner_instance_id()}); + const GetSizeResponse response = + bridge_.send_mutually_recursive_message( + YaPlugView::GetSize{.owner_instance_id = owner_instance_id()}); *size = response.size; return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to 'IPlugView::getSize()'"); return Steinberg::kInvalidArgument; } @@ -188,17 +190,17 @@ tresult PLUGIN_API Vst3PlugViewProxyImpl::getSize(Steinberg::ViewRect* size) { tresult PLUGIN_API Vst3PlugViewProxyImpl::onSize(Steinberg::ViewRect* newSize) { if (newSize) { - return bridge.send_mutually_recursive_message(YaPlugView::OnSize{ + return bridge_.send_mutually_recursive_message(YaPlugView::OnSize{ .owner_instance_id = owner_instance_id(), .new_size = *newSize}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to 'IPlugView::onSize()'"); return Steinberg::kInvalidArgument; } } tresult PLUGIN_API Vst3PlugViewProxyImpl::onFocus(TBool state) { - return bridge.send_mutually_recursive_message(YaPlugView::OnFocus{ + return bridge_.send_mutually_recursive_message(YaPlugView::OnFocus{ .owner_instance_id = owner_instance_id(), .state = state}); } @@ -209,35 +211,35 @@ Vst3PlugViewProxyImpl::setFrame(Steinberg::IPlugFrame* frame) { if (frame) { // We'll store the pointer for when the plugin later makes a callback to // this component handler - plug_frame = frame; + plug_frame_ = frame; // REAPER's GUI is not thread safe, and if we don't call // `IPlugFrame::resizeView()` or `IContextMenu::popup()` from a thread // owned by REAPER then REAPER will eventually segfault We should thus // try to call those functions from an `IRunLoop` event handler. try { - run_loop_tasks.emplace(plug_frame); + run_loop_tasks_.emplace(plug_frame_); } catch (const std::runtime_error& error) { // In case the host does not support `IRunLoop` or if we can't // register an event handler, we'll throw during `RunLoopTasks`' // constructor - run_loop_tasks.reset(); + run_loop_tasks_.reset(); - bridge.logger.log( + bridge_.logger_.log( "The host does not support IRunLoop, falling back to naive GUI " "function execution: " + std::string(error.what())); } - return bridge.send_mutually_recursive_message(YaPlugView::SetFrame{ + return bridge_.send_mutually_recursive_message(YaPlugView::SetFrame{ .owner_instance_id = owner_instance_id(), .plug_frame_args = Vst3PlugFrameProxy::ConstructArgs( - plug_frame, owner_instance_id())}); + plug_frame_, owner_instance_id())}); } else { - plug_frame.reset(); - run_loop_tasks.reset(); + plug_frame_.reset(); + run_loop_tasks_.reset(); - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaPlugView::SetFrame{.owner_instance_id = owner_instance_id(), .plug_frame_args = std::nullopt}); } @@ -248,11 +250,12 @@ tresult PLUGIN_API Vst3PlugViewProxyImpl::canResize() { YaPlugView::CanResize{.owner_instance_id = owner_instance_id()}; { - std::lock_guard lock(can_resize_cache_mutex); - if (const tresult* result = can_resize_cache.get_and_keep_alive(5)) { - const bool log_response = bridge.logger.log_request(true, request); + std::lock_guard lock(can_resize_cache_mutex_); + if (const tresult* result = can_resize_cache_.get_and_keep_alive(5)) { + const bool log_response = + bridge_.logger_.log_request(true, request); if (log_response) { - bridge.logger.log_response( + bridge_.logger_.log_response( true, YaPlugView::CanResize::Response(*result), true); } @@ -261,11 +264,11 @@ tresult PLUGIN_API Vst3PlugViewProxyImpl::canResize() { } const UniversalTResult result = - bridge.send_mutually_recursive_message(request); + bridge_.send_mutually_recursive_message(request); { - std::lock_guard lock(can_resize_cache_mutex); - can_resize_cache.set(result, 5); + std::lock_guard lock(can_resize_cache_mutex_); + can_resize_cache_.set(result, 5); } return result; @@ -275,7 +278,7 @@ tresult PLUGIN_API Vst3PlugViewProxyImpl::checkSizeConstraint(Steinberg::ViewRect* rect) { if (rect) { const CheckSizeConstraintResponse response = - bridge.send_mutually_recursive_message( + bridge_.send_mutually_recursive_message( YaPlugView::CheckSizeConstraint{ .owner_instance_id = owner_instance_id(), .rect = *rect}); @@ -283,7 +286,7 @@ Vst3PlugViewProxyImpl::checkSizeConstraint(Steinberg::ViewRect* rect) { return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IPlugView::checkSizeConstraint()'"); return Steinberg::kInvalidArgument; @@ -295,10 +298,11 @@ tresult PLUGIN_API Vst3PlugViewProxyImpl::findParameter( int32 yPos, Steinberg::Vst::ParamID& resultTag /*out*/) { const FindParameterResponse response = - bridge.send_mutually_recursive_message(YaParameterFinder::FindParameter{ - .owner_instance_id = owner_instance_id(), - .x_pos = xPos, - .y_pos = yPos}); + bridge_.send_mutually_recursive_message( + YaParameterFinder::FindParameter{ + .owner_instance_id = owner_instance_id(), + .x_pos = xPos, + .y_pos = yPos}); resultTag = response.result_tag; @@ -307,7 +311,7 @@ tresult PLUGIN_API Vst3PlugViewProxyImpl::findParameter( tresult PLUGIN_API Vst3PlugViewProxyImpl::setContentScaleFactor(ScaleFactor factor) { - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaPlugViewContentScaleSupport::SetContentScaleFactor{ .owner_instance_id = owner_instance_id(), .factor = factor}); } diff --git a/src/plugin/bridges/vst3-impls/plug-view-proxy.h b/src/plugin/bridges/vst3-impls/plug-view-proxy.h index 355a004d..dfb4e3d3 100644 --- a/src/plugin/bridges/vst3-impls/plug-view-proxy.h +++ b/src/plugin/bridges/vst3-impls/plug-view-proxy.h @@ -73,7 +73,7 @@ class RunLoopTasks : public Steinberg::Linux::IEventHandler { * This pointer is cast from `plug_frame` once `IPlugView::setFrame()` has * been called. */ - Steinberg::FUnknownPtr run_loop; + Steinberg::FUnknownPtr run_loop_; /** * Tasks that should be executed in the next `IRunLoop` event handler call. @@ -82,8 +82,8 @@ class RunLoopTasks : public Steinberg::Linux::IEventHandler { * * @see RunLoopTasks::schedule */ - std::vector> tasks; - std::mutex tasks_mutex; + std::vector> tasks_; + std::mutex tasks_mutex_; /** * A dumy Unix domain socket file descriptor used to signal that there is a @@ -93,12 +93,12 @@ class RunLoopTasks : public Steinberg::Linux::IEventHandler { * XXX: This should be backed by eventfd instead, but Ardour doesn't support * that */ - int socket_read_fd = -1; + int socket_read_fd_ = -1; /** * The other side of `socket_read_fd`. We'll write to this when we want the * hsot to call our event handler. */ - int socket_write_fd = -1; + int socket_write_fd_ = -1; }; class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy { @@ -131,9 +131,9 @@ class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy { * * This works similarly to * `Vst3Bridge::do_mutual_recursion_or_handle_in_main_context`, except that - * we can post tasks to `run_loop_tasks` instead of executing them directly - * in `main_context` when no mutually recursive function calls are happening - * right now. + * we can post tasks to `run_loop_tasks_` instead of executing them directly + * in `main_context_` when no mutually recursive function calls are + * happening right now. * * @see Vst3HostBridge::send_mutually_recursive_message */ @@ -148,15 +148,15 @@ class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy { // registered to the host's run loop, if that exists. Finally if the // host does not support `IRunLoop`, then we'll just run `fn` directly. if (const auto result = - bridge.maybe_run_on_mutual_recursion_thread(fn)) { + bridge_.maybe_run_on_mutual_recursion_thread(fn)) { return *result; } - if (run_loop_tasks) { + if (run_loop_tasks_) { std::packaged_task do_call(std::forward(fn)); std::future do_call_response = do_call.get_future(); - run_loop_tasks->schedule(std::move(do_call)); + run_loop_tasks_->schedule(std::move(do_call)); return do_call_response.get(); } else { @@ -198,10 +198,10 @@ class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy { * `IPlugView::setFrame()`. When the plugin makes a callback on the * `IPlugFrame` proxy object, we'll pass the call through to this object. */ - Steinberg::IPtr plug_frame; + Steinberg::IPtr plug_frame_; private: - Vst3PluginBridge& bridge; + Vst3PluginBridge& bridge_; /** * If the host supports `IRunLoop`, we'll use this to run certain tasks from @@ -210,7 +210,7 @@ class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy { * * This will be an `std::nullopt` if the hostdoes not support `IRunLoop`. */ - std::optional run_loop_tasks; + std::optional run_loop_tasks_; // Caches @@ -225,6 +225,6 @@ class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy { * resizing a lot laggier than they would have to be, so as a compromise * we'll remember this value for the duration of the resize. */ - TimedValueCache can_resize_cache; - std::mutex can_resize_cache_mutex; + TimedValueCache can_resize_cache_; + std::mutex can_resize_cache_mutex_; }; diff --git a/src/plugin/bridges/vst3-impls/plugin-factory-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-factory-proxy.cpp index 6a778443..30d48957 100644 --- a/src/plugin/bridges/vst3-impls/plugin-factory-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-factory-proxy.cpp @@ -24,14 +24,15 @@ Vst3PluginFactoryProxyImpl::Vst3PluginFactoryProxyImpl( Vst3PluginBridge& bridge, Vst3PluginFactoryProxy::ConstructArgs&& args) noexcept - : Vst3PluginFactoryProxy(std::move(args)), bridge(bridge) {} + : Vst3PluginFactoryProxy(std::move(args)), bridge_(bridge) {} tresult PLUGIN_API Vst3PluginFactoryProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { const tresult result = Vst3PluginFactoryProxy::queryInterface(_iid, obj); - bridge.logger.log_query_interface("In IPluginFactory::queryInterface()", - result, Steinberg::FUID::fromTUID(_iid)); + bridge_.logger_.log_query_interface("In IPluginFactory::queryInterface()", + result, + Steinberg::FUID::fromTUID(_iid)); return result; } @@ -63,16 +64,16 @@ Vst3PluginFactoryProxyImpl::createInstance(Steinberg::FIDString cid, } else { // When the host requests an interface we do not (yet) implement, we'll // print a recognizable log message - bridge.logger.log_query_interface("In IPluginFactory::createInstance()", - Steinberg::kNotImplemented, - requested_iid); + bridge_.logger_.log_query_interface( + "In IPluginFactory::createInstance()", Steinberg::kNotImplemented, + requested_iid); *obj = nullptr; return Steinberg::kNotImplemented; } std::variant result = - bridge.send_mutually_recursive_message(Vst3PluginProxy::Construct{ + bridge_.send_mutually_recursive_message(Vst3PluginProxy::Construct{ .cid = cid_array, .requested_interface = requested_interface}); return std::visit( @@ -83,7 +84,7 @@ Vst3PluginFactoryProxyImpl::createInstance(Steinberg::FIDString cid, // reference count of 1), and then the receiving side will use // `Steinberg::owned()` to adopt it to an `IPtr`. Vst3PluginProxyImpl* proxy_object = - new Vst3PluginProxyImpl(bridge, std::move(args)); + new Vst3PluginProxyImpl(bridge_, std::move(args)); // We return a properly downcasted version of the proxy object // we just created @@ -111,18 +112,18 @@ Vst3PluginFactoryProxyImpl::setHostContext(Steinberg::FUnknown* context) { // interfaces as `context`, and then we'll store `context` in this // object. We can then use it to handle callbacks made by the Windows // VST3 plugin to this context. - host_context = context; + host_context_ = context; // Automatically converted smart pointers for when the plugin performs a // callback later - host_application = host_context; - plug_interface_support = host_context; + host_application_ = host_context_; + plug_interface_support_ = host_context_; - return bridge.send_message(YaPluginFactory3::SetHostContext{ + return bridge_.send_message(YaPluginFactory3::SetHostContext{ .host_context_args = Vst3HostContextProxy::ConstructArgs( - host_context, std::nullopt)}); + host_context_, std::nullopt)}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IPluginFactory3::setHostContext()'"); return Steinberg::kInvalidArgument; diff --git a/src/plugin/bridges/vst3-impls/plugin-factory-proxy.h b/src/plugin/bridges/vst3-impls/plugin-factory-proxy.h index 19e754d5..7e68d3cd 100644 --- a/src/plugin/bridges/vst3-impls/plugin-factory-proxy.h +++ b/src/plugin/bridges/vst3-impls/plugin-factory-proxy.h @@ -43,16 +43,16 @@ class Vst3PluginFactoryProxyImpl : public Vst3PluginFactoryProxy { // The following pointers are cast from `host_context` if // `IPluginFactory3::setHostContext()` has been called - Steinberg::FUnknownPtr host_application; + Steinberg::FUnknownPtr host_application_; Steinberg::FUnknownPtr - plug_interface_support; + plug_interface_support_; private: - Vst3PluginBridge& bridge; + Vst3PluginBridge& bridge_; /** * An host context if we get passed one through * `IPluginFactory3::setHostContext()`. */ - Steinberg::IPtr host_context; + Steinberg::IPtr host_context_; }; diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp index bdce2bf1..e5173516 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.cpp +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.cpp @@ -31,7 +31,7 @@ constexpr char other_instance_message_id[] = "yabridge_other_instance"; /** * In the message described above we'll use this attribute to pass through a * pointer to the sender of the message. This will the other side set the - * `connected_instance_id` field on the other object to the instance ID of that + * `connected_instance_id_` field on the other object to the instance ID of that * connected object. This will let us bypass the connection proxy since we can * then just connect the two objects directly. */ @@ -43,7 +43,7 @@ Vst3PluginProxyImpl::ContextMenu::ContextMenu( Vst3PluginProxyImpl::Vst3PluginProxyImpl(Vst3PluginBridge& bridge, Vst3PluginProxy::ConstructArgs&& args) - : Vst3PluginProxy(std::move(args)), bridge(bridge) { + : Vst3PluginProxy(std::move(args)), bridge_(bridge) { bridge.register_plugin_proxy(*this); } @@ -51,26 +51,26 @@ Vst3PluginProxyImpl::~Vst3PluginProxyImpl() noexcept { // NOTE: This can actually throw (e.g. out of memory or the socket got // closed). But if that were to happen, then we wouldn't be able to // recover from it anyways. - bridge.send_message( + bridge_.send_message( Vst3PluginProxy::Destruct{.instance_id = instance_id()}); - bridge.unregister_plugin_proxy(*this); + bridge_.unregister_plugin_proxy(*this); } tresult PLUGIN_API Vst3PluginProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { const tresult result = Vst3PluginProxy::queryInterface(_iid, obj); - bridge.logger.log_query_interface("In FUnknown::queryInterface()", result, - Steinberg::FUID::fromTUID(_iid)); + bridge_.logger_.log_query_interface("In FUnknown::queryInterface()", result, + Steinberg::FUID::fromTUID(_iid)); return result; } size_t Vst3PluginProxyImpl::register_context_menu( Steinberg::IPtr menu) { - std::lock_guard lock(context_menus_mutex); + std::lock_guard lock(context_menus_mutex_); - const size_t context_menu_id = current_context_menu_id.fetch_add(1); - context_menus.emplace(context_menu_id, menu); + const size_t context_menu_id = current_context_menu_id_.fetch_add(1); + context_menus_.emplace(context_menu_id, menu); return context_menu_id; } @@ -81,22 +81,22 @@ size_t Vst3PluginProxyImpl::register_context_menu( * returned by the host. */ bool Vst3PluginProxyImpl::unregister_context_menu(size_t context_menu_id) { - std::lock_guard lock(context_menus_mutex); - return context_menus.erase(context_menu_id); + std::lock_guard lock(context_menus_mutex_); + return context_menus_.erase(context_menu_id); } void Vst3PluginProxyImpl::clear_caches() noexcept { clear_bus_cache(); - std::lock_guard lock(function_result_cache_mutex); - function_result_cache = FunctionResultCache{}; + std::lock_guard lock(function_result_cache_mutex_); + function_result_cache_ = FunctionResultCache{}; } tresult PLUGIN_API Vst3PluginProxyImpl::setAudioPresentationLatencySamples( Steinberg::Vst::BusDirection dir, int32 busIndex, uint32 latencyInSamples) { - return bridge.send_message( + return bridge_.send_message( YaAudioPresentationLatency::SetAudioPresentationLatencySamples{ .instance_id = instance_id(), .dir = dir, @@ -113,7 +113,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setBusArrangements( // NOTE: Ardour passes a null pointer when `numIns` or `numOuts` is 0, so we // need to work around that - return bridge.send_audio_processor_message( + return bridge_.send_audio_processor_message( YaAudioProcessor::SetBusArrangements{ .instance_id = instance_id(), .inputs = @@ -134,8 +134,9 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getBusArrangement( int32 index, Steinberg::Vst::SpeakerArrangement& arr) { const GetBusArrangementResponse response = - bridge.send_audio_processor_message(YaAudioProcessor::GetBusArrangement{ - .instance_id = instance_id(), .dir = dir, .index = index}); + bridge_.send_audio_processor_message( + YaAudioProcessor::GetBusArrangement{ + .instance_id = instance_id(), .dir = dir, .index = index}); arr = response.arr; @@ -149,13 +150,14 @@ Vst3PluginProxyImpl::canProcessSampleSize(int32 symbolicSampleSize) { .symbolic_sample_size = symbolicSampleSize}; { - std::lock_guard lock(function_result_cache_mutex); - if (auto it = function_result_cache.can_process_sample_size.find( + std::lock_guard lock(function_result_cache_mutex_); + if (auto it = function_result_cache_.can_process_sample_size.find( symbolicSampleSize); - it != function_result_cache.can_process_sample_size.end()) { - const bool log_response = bridge.logger.log_request(true, request); + it != function_result_cache_.can_process_sample_size.end()) { + const bool log_response = + bridge_.logger_.log_request(true, request); if (log_response) { - bridge.logger.log_response( + bridge_.logger_.log_response( true, YaAudioProcessor::CanProcessSampleSize::Response( it->second), @@ -166,11 +168,11 @@ Vst3PluginProxyImpl::canProcessSampleSize(int32 symbolicSampleSize) { } } - const tresult result = bridge.send_audio_processor_message(request); + const tresult result = bridge_.send_audio_processor_message(request); { - std::lock_guard lock(function_result_cache_mutex); - function_result_cache.can_process_sample_size[symbolicSampleSize] = + std::lock_guard lock(function_result_cache_mutex_); + function_result_cache_.can_process_sample_size[symbolicSampleSize] = result; } @@ -178,22 +180,22 @@ Vst3PluginProxyImpl::canProcessSampleSize(int32 symbolicSampleSize) { } uint32 PLUGIN_API Vst3PluginProxyImpl::getLatencySamples() { - return bridge.send_audio_processor_message( + return bridge_.send_audio_processor_message( YaAudioProcessor::GetLatencySamples{.instance_id = instance_id()}); } tresult PLUGIN_API Vst3PluginProxyImpl::setupProcessing(Steinberg::Vst::ProcessSetup& setup) { const YaAudioProcessor::SetupProcessingResponse response = - bridge.send_audio_processor_message(YaAudioProcessor::SetupProcessing{ + bridge_.send_audio_processor_message(YaAudioProcessor::SetupProcessing{ .instance_id = instance_id(), .setup = setup}); // We have now set up the shared audio buffers on the Wine side, and we'll // be able to able to connect to them by using the same audio configuration - if (!process_buffers) { - process_buffers.emplace(response.audio_buffers_config); + if (!process_buffers_) { + process_buffers_.emplace(response.audio_buffers_config); } else { - process_buffers->resize(response.audio_buffers_config); + process_buffers_->resize(response.audio_buffers_config); } return response.result; @@ -206,15 +208,15 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setProcessing(TBool state) { // cache. We keep this in because it can still help performance a little in // some DAWs. { - std::lock_guard lock(processing_bus_cache_mutex); + std::lock_guard lock(processing_bus_cache_mutex_); if (state) { - processing_bus_cache.emplace(); + processing_bus_cache_.emplace(); } else { - processing_bus_cache.reset(); + processing_bus_cache_.reset(); } } - return bridge.send_audio_processor_message(YaAudioProcessor::SetProcessing{ + return bridge_.send_audio_processor_message(YaAudioProcessor::SetProcessing{ .instance_id = instance_id(), .state = state}); } @@ -224,19 +226,19 @@ Vst3PluginProxyImpl::process(Steinberg::Vst::ProcessData& data) { // plugin host with that of the host's audio thread every once in a while std::optional new_realtime_priority = std::nullopt; time_t now = time(nullptr); - if (now > last_audio_thread_priority_synchronization + + if (now > last_audio_thread_priority_synchronization_ + audio_thread_priority_synchronization_interval) { new_realtime_priority = get_realtime_priority(); - last_audio_thread_priority_synchronization = now; + last_audio_thread_priority_synchronization_ = now; } // We reuse this existing object to avoid allocations. // `YaProcessData::repopulate()` will write the input audio to the shared // audio buffers, so they're not stored within the request object itself. - assert(process_buffers); - process_request.instance_id = instance_id(); - process_request.data.repopulate(data, *process_buffers); - process_request.new_realtime_priority = new_realtime_priority; + assert(process_buffers_); + process_request_.instance_id = instance_id(); + process_request_.data.repopulate(data, *process_buffers_); + process_request_.new_realtime_priority = new_realtime_priority; // HACK: This is a bit ugly. This `YaProcessData::Response` object actually // contains pointers to the corresponding `YaProcessData` fields in @@ -250,30 +252,30 @@ Vst3PluginProxyImpl::process(Steinberg::Vst::ProcessData& data) { // // `YaProcessData::Response::serialize()` should make this a lot // clearer. - process_response.output_data = process_request.data.create_response(); + process_response_.output_data = process_request_.data.create_response(); // We'll also receive the response into an existing object so we can also // avoid heap allocations there - bridge.receive_audio_processor_message_into( - MessageReference(process_request), - process_response); + bridge_.receive_audio_processor_message_into( + MessageReference(process_request_), + process_response_); // At this point the shared audio buffers should contain the output audio, // so we'll write that back to the host along with any metadata (which in // practice are only the silence flags), as well as any output parameter // changes and events - process_request.data.write_back_outputs(data, *process_buffers); + process_request_.data.write_back_outputs(data, *process_buffers_); - return process_response.result; + return process_response_.result; } uint32 PLUGIN_API Vst3PluginProxyImpl::getTailSamples() { - return bridge.send_audio_processor_message( + return bridge_.send_audio_processor_message( YaAudioProcessor::GetTailSamples{.instance_id = instance_id()}); } tresult PLUGIN_API Vst3PluginProxyImpl::setAutomationState(int32 state) { - return bridge.send_message(YaAutomationState::SetAutomationState{ + return bridge_.send_message(YaAutomationState::SetAutomationState{ .instance_id = instance_id(), .state = state}); } @@ -281,7 +283,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getControllerClassId(Steinberg::TUID classId) { if (classId) { const GetControllerClassIdResponse response = - bridge.send_audio_processor_message( + bridge_.send_audio_processor_message( YaComponent::GetControllerClassId{.instance_id = instance_id()}); @@ -290,7 +292,7 @@ Vst3PluginProxyImpl::getControllerClassId(Steinberg::TUID classId) { return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IComponent::getControllerClassId()'"); return Steinberg::kInvalidArgument; @@ -298,7 +300,7 @@ Vst3PluginProxyImpl::getControllerClassId(Steinberg::TUID classId) { } tresult PLUGIN_API Vst3PluginProxyImpl::setIoMode(Steinberg::Vst::IoMode mode) { - return bridge.send_audio_processor_message( + return bridge_.send_audio_processor_message( YaComponent::SetIoMode{.instance_id = instance_id(), .mode = mode}); } @@ -311,14 +313,14 @@ Vst3PluginProxyImpl::getBusCount(Steinberg::Vst::MediaType type, std::tuple args{ type, dir}; { - std::lock_guard lock(processing_bus_cache_mutex); - if (processing_bus_cache) { - if (auto it = processing_bus_cache->bus_count.find(args); - it != processing_bus_cache->bus_count.end()) { + std::lock_guard lock(processing_bus_cache_mutex_); + if (processing_bus_cache_) { + if (auto it = processing_bus_cache_->bus_count.find(args); + it != processing_bus_cache_->bus_count.end()) { const bool log_response = - bridge.logger.log_request(true, request); + bridge_.logger_.log_request(true, request); if (log_response) { - bridge.logger.log_response( + bridge_.logger_.log_response( true, YaComponent::GetBusCount::Response(it->second), true); } @@ -328,12 +330,12 @@ Vst3PluginProxyImpl::getBusCount(Steinberg::Vst::MediaType type, } } - const int32 result = bridge.send_audio_processor_message(request); + const int32 result = bridge_.send_audio_processor_message(request); { - std::lock_guard lock(processing_bus_cache_mutex); - if (processing_bus_cache) { - processing_bus_cache->bus_count[args] = result; + std::lock_guard lock(processing_bus_cache_mutex_); + if (processing_bus_cache_) { + processing_bus_cache_->bus_count[args] = result; } } @@ -351,14 +353,14 @@ Vst3PluginProxyImpl::getBusInfo(Steinberg::Vst::MediaType type, std::tuple args{type, dir, index}; { - std::lock_guard lock(processing_bus_cache_mutex); - if (processing_bus_cache) { - if (auto it = processing_bus_cache->bus_info.find(args); - it != processing_bus_cache->bus_info.end()) { + std::lock_guard lock(processing_bus_cache_mutex_); + if (processing_bus_cache_) { + if (auto it = processing_bus_cache_->bus_info.find(args); + it != processing_bus_cache_->bus_info.end()) { const bool log_response = - bridge.logger.log_request(true, request); + bridge_.logger_.log_request(true, request); if (log_response) { - bridge.logger.log_response( + bridge_.logger_.log_response( false, YaComponent::GetBusInfo::Response{ .result = Steinberg::kResultOk, .bus = it->second}, @@ -373,14 +375,14 @@ Vst3PluginProxyImpl::getBusInfo(Steinberg::Vst::MediaType type, } const GetBusInfoResponse response = - bridge.send_audio_processor_message(request); + bridge_.send_audio_processor_message(request); bus = response.bus; { - std::lock_guard lock(processing_bus_cache_mutex); - if (processing_bus_cache) { - processing_bus_cache->bus_info[args] = response.bus; + std::lock_guard lock(processing_bus_cache_mutex_); + if (processing_bus_cache_) { + processing_bus_cache_->bus_info[args] = response.bus; } } @@ -391,7 +393,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getRoutingInfo( Steinberg::Vst::RoutingInfo& inInfo, Steinberg::Vst::RoutingInfo& outInfo /*out*/) { const GetRoutingInfoResponse response = - bridge.send_audio_processor_message(YaComponent::GetRoutingInfo{ + bridge_.send_audio_processor_message(YaComponent::GetRoutingInfo{ .instance_id = instance_id(), .in_info = inInfo}); outInfo = response.out_info; @@ -404,7 +406,7 @@ Vst3PluginProxyImpl::activateBus(Steinberg::Vst::MediaType type, Steinberg::Vst::BusDirection dir, int32 index, TBool state) { - return bridge.send_audio_processor_message( + return bridge_.send_audio_processor_message( YaComponent::ActivateBus{.instance_id = instance_id(), .type = type, .dir = dir, @@ -420,7 +422,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setActive(TBool state) { // workaround of its ownn. Great! clear_bus_cache(); - return bridge.send_audio_processor_message( + return bridge_.send_audio_processor_message( YaComponent::SetActive{.instance_id = instance_id(), .state = state}); } @@ -434,10 +436,11 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setState(Steinberg::IBStream* state) { // GUI thread. So if the GUI is active, we'll use the mutual // recursion mechanism to allow this resize call to also be // performed from the GUI thread. - return bridge.send_mutually_recursive_message(Vst3PluginProxy::SetState{ - .instance_id = instance_id(), .state = state}); + return bridge_.send_mutually_recursive_message( + Vst3PluginProxy::SetState{.instance_id = instance_id(), + .state = state}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'I{Component,EditController}::setState()'"); return Steinberg::kInvalidArgument; @@ -456,14 +459,14 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getState(Steinberg::IBStream* state) { // into a situation where we need mutually recursive function // calls. const GetStateResponse response = - bridge.send_mutually_recursive_message(Vst3PluginProxy::GetState{ + bridge_.send_mutually_recursive_message(Vst3PluginProxy::GetState{ .instance_id = instance_id(), .state = state}); assert(response.state.write_back(state) == Steinberg::kResultOk); return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'I{Component,EditController}::getState()'"); return Steinberg::kInvalidArgument; @@ -472,7 +475,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getState(Steinberg::IBStream* state) { tresult PLUGIN_API Vst3PluginProxyImpl::connect(IConnectionPoint* other) { if (!other) { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IConnectionPointProxy::connect()'"); return Steinberg::kInvalidArgument; @@ -491,18 +494,18 @@ tresult PLUGIN_API Vst3PluginProxyImpl::connect(IConnectionPoint* other) { // out which object the plugins are connected to, we'll still proxy the // host's connection proxy. if (auto other_instance = dynamic_cast(other)) { - connected_instance_id = other_instance->instance_id(); + connected_instance_id_ = other_instance->instance_id(); - return bridge.send_message( + return bridge_.send_message( YaConnectionPoint::Connect{.instance_id = instance_id(), .other = other_instance->instance_id()}); } // As mentioned above, we'll first try to bypass the connection point proxy // and connect the objects directly - if (host_application) { - Steinberg::IPtr message = - Steinberg::owned(Steinberg::Vst::allocateMessage(host_application)); + if (host_application_) { + Steinberg::IPtr message = Steinberg::owned( + Steinberg::Vst::allocateMessage(host_application_)); if (message) { message->setMessageID(other_instance_message_id); @@ -517,18 +520,18 @@ tresult PLUGIN_API Vst3PluginProxyImpl::connect(IConnectionPoint* other) { // If we are connected with another object instance from this // plugin, `connected_instance_id` should now be set other->notify(message); - if (connected_instance_id) { - return bridge.send_message(YaConnectionPoint::Connect{ + if (connected_instance_id_) { + return bridge_.send_message(YaConnectionPoint::Connect{ .instance_id = instance_id(), - .other = *connected_instance_id}); + .other = *connected_instance_id_}); } } } // If we cannot bypass the proxy, we'll just proxy the host's proxy - connection_point_proxy = other; + connection_point_proxy_ = other; - return bridge.send_message(YaConnectionPoint::Connect{ + return bridge_.send_message(YaConnectionPoint::Connect{ .instance_id = instance_id(), .other = Vst3ConnectionPointProxy::ConstructArgs(other, instance_id())}); @@ -538,15 +541,15 @@ tresult PLUGIN_API Vst3PluginProxyImpl::disconnect(IConnectionPoint* /*other*/) { // See `Vst3PluginProxyImpl::connect()`, if we directly connected two // instances we'll also disconnect them again - if (connected_instance_id) { - return bridge.send_message(YaConnectionPoint::Disconnect{ + if (connected_instance_id_) { + return bridge_.send_message(YaConnectionPoint::Disconnect{ .instance_id = instance_id(), - .other_instance_id = *connected_instance_id}); + .other_instance_id = *connected_instance_id_}); } else { - const tresult result = bridge.send_message( + const tresult result = bridge_.send_message( YaConnectionPoint::Disconnect{.instance_id = instance_id(), .other_instance_id = std::nullopt}); - connection_point_proxy.reset(); + connection_point_proxy_.reset(); return result; } @@ -566,7 +569,7 @@ Vst3PluginProxyImpl::notify(Steinberg::Vst::IMessage* message) { // so we don't have to do any additional when those objects pass through // messages. if (auto message_ptr = dynamic_cast(message)) { - return bridge.send_message(YaConnectionPoint::Notify{ + return bridge_.send_message(YaConnectionPoint::Notify{ .instance_id = instance_id(), .message_ptr = *message_ptr}); } @@ -588,14 +591,14 @@ Vst3PluginProxyImpl::notify(Steinberg::Vst::IMessage* message) { *reinterpret_cast( static_cast(other_object_ptr)); - other_object.connected_instance_id = instance_id(); + other_object.connected_instance_id_ = instance_id(); return Steinberg::kResultOk; } } } - bridge.logger.log( + bridge_.logger_.log( "WARNING: Unknown message type passed to " "'IConnectionPoint::notify()', ignoring"); return Steinberg::kNotImplemented; @@ -604,10 +607,10 @@ Vst3PluginProxyImpl::notify(Steinberg::Vst::IMessage* message) { tresult PLUGIN_API Vst3PluginProxyImpl::setComponentState(Steinberg::IBStream* state) { if (state) { - return bridge.send_message(YaEditController::SetComponentState{ + return bridge_.send_message(YaEditController::SetComponentState{ .instance_id = instance_id(), .state = state}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IEditController::setComponentState()'"); return Steinberg::kInvalidArgument; @@ -619,26 +622,27 @@ int32 PLUGIN_API Vst3PluginProxyImpl::getParameterCount() { YaEditController::GetParameterCount{.instance_id = instance_id()}; { - std::lock_guard lock(function_result_cache_mutex); - if (function_result_cache.parameter_count) { - const bool log_response = bridge.logger.log_request(true, request); + std::lock_guard lock(function_result_cache_mutex_); + if (function_result_cache_.parameter_count) { + const bool log_response = + bridge_.logger_.log_request(true, request); if (log_response) { - bridge.logger.log_response( + bridge_.logger_.log_response( true, YaEditController::GetParameterCount::Response( - *function_result_cache.parameter_count), + *function_result_cache_.parameter_count), true); } - return *function_result_cache.parameter_count; + return *function_result_cache_.parameter_count; } } - const int32 result = bridge.send_message(request); + const int32 result = bridge_.send_message(request); { - std::lock_guard lock(function_result_cache_mutex); - function_result_cache.parameter_count = result; + std::lock_guard lock(function_result_cache_mutex_); + function_result_cache_.parameter_count = result; } return result; @@ -651,12 +655,13 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getParameterInfo( .instance_id = instance_id(), .param_index = paramIndex}; { - std::lock_guard lock(function_result_cache_mutex); - if (auto it = function_result_cache.parameter_info.find(paramIndex); - it != function_result_cache.parameter_info.end()) { - const bool log_response = bridge.logger.log_request(true, request); + std::lock_guard lock(function_result_cache_mutex_); + if (auto it = function_result_cache_.parameter_info.find(paramIndex); + it != function_result_cache_.parameter_info.end()) { + const bool log_response = + bridge_.logger_.log_request(true, request); if (log_response) { - bridge.logger.log_response( + bridge_.logger_.log_response( true, YaEditController::GetParameterInfo::Response{ .result = Steinberg::kResultOk, .info = it->second}, @@ -669,13 +674,13 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getParameterInfo( } } - const GetParameterInfoResponse response = bridge.send_message(request); + const GetParameterInfoResponse response = bridge_.send_message(request); info = response.info; { - std::lock_guard lock(function_result_cache_mutex); - function_result_cache.parameter_info[paramIndex] = response.info; + std::lock_guard lock(function_result_cache_mutex_); + function_result_cache_.parameter_info[paramIndex] = response.info; } return response.result; @@ -687,7 +692,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getParamStringByValue( Steinberg::Vst::String128 string /*out*/) { if (string) { const GetParamStringByValueResponse response = - bridge.send_message(YaEditController::GetParamStringByValue{ + bridge_.send_message(YaEditController::GetParamStringByValue{ .instance_id = instance_id(), .id = id, .value_normalized = valueNormalized}); @@ -697,7 +702,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getParamStringByValue( return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IEditController::getParamStringByValue()'"); return Steinberg::kInvalidArgument; @@ -710,14 +715,14 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getParamValueByString( Steinberg::Vst::ParamValue& valueNormalized /*out*/) { if (string) { const GetParamValueByStringResponse response = - bridge.send_message(YaEditController::GetParamValueByString{ + bridge_.send_message(YaEditController::GetParamValueByString{ .instance_id = instance_id(), .id = id, .string = string}); valueNormalized = response.value_normalized; return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IEditController::getParamValueByString()'"); return Steinberg::kInvalidArgument; @@ -728,7 +733,7 @@ Steinberg::Vst::ParamValue PLUGIN_API Vst3PluginProxyImpl::normalizedParamToPlain( Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue valueNormalized) { - return bridge.send_message(YaEditController::NormalizedParamToPlain{ + return bridge_.send_message(YaEditController::NormalizedParamToPlain{ .instance_id = instance_id(), .id = id, .value_normalized = valueNormalized}); @@ -738,20 +743,20 @@ Steinberg::Vst::ParamValue PLUGIN_API Vst3PluginProxyImpl::plainParamToNormalized( Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue plainValue) { - return bridge.send_message(YaEditController::PlainParamToNormalized{ + return bridge_.send_message(YaEditController::PlainParamToNormalized{ .instance_id = instance_id(), .id = id, .plain_value = plainValue}); } Steinberg::Vst::ParamValue PLUGIN_API Vst3PluginProxyImpl::getParamNormalized(Steinberg::Vst::ParamID id) { - return bridge.send_message(YaEditController::GetParamNormalized{ + return bridge_.send_message(YaEditController::GetParamNormalized{ .instance_id = instance_id(), .id = id}); } tresult PLUGIN_API Vst3PluginProxyImpl::setParamNormalized(Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue value) { - return bridge.send_message(YaEditController::SetParamNormalized{ + return bridge_.send_message(YaEditController::SetParamNormalized{ .instance_id = instance_id(), .id = id, .value = value}); } @@ -762,33 +767,33 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setComponentHandler( if (handler) { // We'll store the pointer for when the plugin later makes a callback to // this component handler - component_handler = handler; + component_handler_ = handler; // Automatically converted smart pointers for when the plugin performs a // callback later - component_handler_2 = component_handler; - component_handler_3 = component_handler; - component_handler_bus_activation = component_handler; - progress = component_handler; - unit_handler = component_handler; - unit_handler_2 = component_handler; + component_handler_2_ = component_handler_; + component_handler_3_ = component_handler_; + component_handler_bus_activation_ = component_handler_; + progress_ = component_handler_; + unit_handler_ = component_handler_; + unit_handler_2_ = component_handler_; - return bridge.send_message(YaEditController::SetComponentHandler{ + return bridge_.send_message(YaEditController::SetComponentHandler{ .instance_id = instance_id(), .component_handler_proxy_args = - Vst3ComponentHandlerProxy::ConstructArgs(component_handler, + Vst3ComponentHandlerProxy::ConstructArgs(component_handler_, instance_id())}); } else { - component_handler = nullptr; + component_handler_ = nullptr; - component_handler_2 = nullptr; - component_handler_3 = nullptr; - component_handler_bus_activation = nullptr; - progress = nullptr; - unit_handler = nullptr; - unit_handler_2 = nullptr; + component_handler_2_ = nullptr; + component_handler_3_ = nullptr; + component_handler_bus_activation_ = nullptr; + progress_ = nullptr; + unit_handler_ = nullptr; + unit_handler_2_ = nullptr; - return bridge.send_message(YaEditController::SetComponentHandler{ + return bridge_.send_message(YaEditController::SetComponentHandler{ .instance_id = instance_id(), .component_handler_proxy_args = std::nullopt}); } @@ -798,25 +803,25 @@ Steinberg::IPlugView* PLUGIN_API Vst3PluginProxyImpl::createView(Steinberg::FIDString name) { if (name) { CreateViewResponse response = - bridge.send_message(YaEditController::CreateView{ + bridge_.send_message(YaEditController::CreateView{ .instance_id = instance_id(), .name = name}); if (response.plug_view_args) { // The host should manage this. Returning raw pointers feels scary. auto plug_view_proxy = new Vst3PlugViewProxyImpl( - bridge, std::move(*response.plug_view_args)); + bridge_, std::move(*response.plug_view_args)); // We also need to store an (unmanaged, since we don't want to // affect the reference counting) pointer to this to be able to // handle calls to `IPlugFrame::resizeView()` in the future - last_created_plug_view = plug_view_proxy; + last_created_plug_view_ = plug_view_proxy; return plug_view_proxy; } else { return nullptr; } } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IEditController::createView()'"); return nullptr; @@ -825,29 +830,29 @@ Vst3PluginProxyImpl::createView(Steinberg::FIDString name) { tresult PLUGIN_API Vst3PluginProxyImpl::setKnobMode(Steinberg::Vst::KnobMode mode) { - return bridge.send_message(YaEditController2::SetKnobMode{ + return bridge_.send_message(YaEditController2::SetKnobMode{ .instance_id = instance_id(), .mode = mode}); } tresult PLUGIN_API Vst3PluginProxyImpl::openHelp(TBool onlyCheck) { - return bridge.send_message(YaEditController2::OpenHelp{ + return bridge_.send_message(YaEditController2::OpenHelp{ .instance_id = instance_id(), .only_check = onlyCheck}); } tresult PLUGIN_API Vst3PluginProxyImpl::openAboutBox(TBool onlyCheck) { - return bridge.send_message(YaEditController2::OpenAboutBox{ + return bridge_.send_message(YaEditController2::OpenAboutBox{ .instance_id = instance_id(), .only_check = onlyCheck}); } tresult PLUGIN_API Vst3PluginProxyImpl::beginEditFromHost(Steinberg::Vst::ParamID paramID) { - return bridge.send_message(YaEditControllerHostEditing::BeginEditFromHost{ + return bridge_.send_message(YaEditControllerHostEditing::BeginEditFromHost{ .instance_id = instance_id(), .param_id = paramID}); } tresult PLUGIN_API Vst3PluginProxyImpl::endEditFromHost(Steinberg::Vst::ParamID paramID) { - return bridge.send_message(YaEditControllerHostEditing::EndEditFromHost{ + return bridge_.send_message(YaEditControllerHostEditing::EndEditFromHost{ .instance_id = instance_id(), .param_id = paramID}); } @@ -861,12 +866,12 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setChannelContextInfos( // these things need to be handled on the GUI thread on their // receiving sides, resulting in a deadlock without this mutual // recursion. - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaInfoListener::SetChannelContextInfos{ .instance_id = instance_id(), .list = YaAttributeList::read_channel_context(list)}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IInfoListener::setChannelContextInfos()'"); return Steinberg::kInvalidArgument; @@ -875,7 +880,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setChannelContextInfos( int32 PLUGIN_API Vst3PluginProxyImpl::getKeyswitchCount(int32 busIndex, int16 channel) { - return bridge.send_message( + return bridge_.send_message( YaKeyswitchController::GetKeyswitchCount{.instance_id = instance_id(), .bus_index = busIndex, .channel = channel}); @@ -887,7 +892,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getKeyswitchInfo( int32 keySwitchIndex, Steinberg::Vst::KeyswitchInfo& info /*out*/) { const GetKeyswitchInfoResponse response = - bridge.send_message(YaKeyswitchController::GetKeyswitchInfo{ + bridge_.send_message(YaKeyswitchController::GetKeyswitchInfo{ .instance_id = instance_id(), .bus_index = busIndex, .channel = channel, @@ -902,7 +907,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::onLiveMIDIControllerInput( int32 busIndex, int16 channel, Steinberg::Vst::CtrlNumber midiCC) { - return bridge.send_message( + return bridge_.send_message( YaMidiLearn::OnLiveMIDIControllerInput{.instance_id = instance_id(), .bus_index = busIndex, .channel = channel, @@ -915,7 +920,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getMidiControllerAssignment( Steinberg::Vst::CtrlNumber midiControllerNumber, Steinberg::Vst::ParamID& id /*out*/) { const GetMidiControllerAssignmentResponse response = - bridge.send_message(YaMidiMapping::GetMidiControllerAssignment{ + bridge_.send_message(YaMidiMapping::GetMidiControllerAssignment{ .instance_id = instance_id(), .bus_index = busIndex, .channel = channel, @@ -928,7 +933,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getMidiControllerAssignment( int32 PLUGIN_API Vst3PluginProxyImpl::getNoteExpressionCount(int32 busIndex, int16 channel) { - return bridge.send_message( + return bridge_.send_message( YaNoteExpressionController::GetNoteExpressionCount{ .instance_id = instance_id(), .bus_index = busIndex, @@ -941,7 +946,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getNoteExpressionInfo( int32 noteExpressionIndex, Steinberg::Vst::NoteExpressionTypeInfo& info /*out*/) { const GetNoteExpressionInfoResponse response = - bridge.send_message(YaNoteExpressionController::GetNoteExpressionInfo{ + bridge_.send_message(YaNoteExpressionController::GetNoteExpressionInfo{ .instance_id = instance_id(), .bus_index = busIndex, .channel = channel, @@ -960,7 +965,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getNoteExpressionStringByValue( Steinberg::Vst::String128 string /*out*/) { if (string) { const GetNoteExpressionStringByValueResponse response = - bridge.send_message( + bridge_.send_message( YaNoteExpressionController::GetNoteExpressionStringByValue{ .instance_id = instance_id(), .bus_index = busIndex, @@ -973,7 +978,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getNoteExpressionStringByValue( return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'INoteExpressionController::getNoteExpressionStringByValue()'"); return Steinberg::kInvalidArgument; @@ -988,7 +993,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getNoteExpressionValueByString( Steinberg::Vst::NoteExpressionValue& valueNormalized /*out*/) { if (string) { const GetNoteExpressionValueByStringResponse response = - bridge.send_message( + bridge_.send_message( YaNoteExpressionController::GetNoteExpressionValueByString{ .instance_id = instance_id(), .bus_index = busIndex, @@ -1000,7 +1005,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getNoteExpressionValueByString( return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'INoteExpressionController::getNoteExpressionValueByString()'"); return Steinberg::kInvalidArgument; @@ -1011,7 +1016,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getPhysicalUIMapping( int32 busIndex, int16 channel, Steinberg::Vst::PhysicalUIMapList& list) { - const GetNotePhysicalUIMappingResponse response = bridge.send_message( + const GetNotePhysicalUIMappingResponse response = bridge_.send_message( YaNoteExpressionPhysicalUIMapping::GetNotePhysicalUIMapping{ .instance_id = instance_id(), .bus_index = busIndex, @@ -1029,7 +1034,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getParameterIDFromFunctionName( Steinberg::Vst::ParamID& paramID) { if (functionName) { const GetParameterIDFromFunctionNameResponse response = - bridge.send_message( + bridge_.send_message( YaParameterFunctionName::GetParameterIDFromFunctionName{ .instance_id = instance_id(), .unit_id = unitID, @@ -1039,7 +1044,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getParameterIDFromFunctionName( return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IParameterFunctionName::getParameterIDFromFunctionName()'"); return Steinberg::kInvalidArgument; @@ -1052,18 +1057,18 @@ tresult PLUGIN_API Vst3PluginProxyImpl::initialize(FUnknown* context) { // interfaces as `context`, and then we'll store `context` in this // object. We can then use it to handle callbacks made by the Windows // VST3 plugin to this context. - host_context = context; + host_context_ = context; // Automatically converted smart pointers for when the plugin performs a // callback later - host_application = host_context; - plug_interface_support = host_context; + host_application_ = host_context_; + plug_interface_support_ = host_context_; InitializeResponse response = - bridge.send_message(Vst3PluginProxy::Initialize{ + bridge_.send_message(Vst3PluginProxy::Initialize{ .instance_id = instance_id(), .host_context_args = Vst3HostContextProxy::ConstructArgs( - host_context, instance_id())}); + host_context_, instance_id())}); // HACK: For some reason, Waves plugins will only allow querying the // `IEditController` interface after this point, so we need to @@ -1073,21 +1078,21 @@ tresult PLUGIN_API Vst3PluginProxyImpl::initialize(FUnknown* context) { return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to 'IPluginBase::initialize()'"); return Steinberg::kInvalidArgument; } } tresult PLUGIN_API Vst3PluginProxyImpl::terminate() { - return bridge.send_message( + return bridge_.send_message( YaPluginBase::Terminate{.instance_id = instance_id()}); } tresult PLUGIN_API Vst3PluginProxyImpl::getPrefetchableSupport( Steinberg::Vst::PrefetchableSupport& prefetchable /*out*/) { const GetPrefetchableSupportResponse response = - bridge.send_audio_processor_message( + bridge_.send_audio_processor_message( YaPrefetchableSupport::GetPrefetchableSupport{.instance_id = instance_id()}); @@ -1097,14 +1102,14 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getPrefetchableSupport( } uint32 PLUGIN_API Vst3PluginProxyImpl::getProcessContextRequirements() { - return bridge.send_message( + return bridge_.send_message( YaProcessContextRequirements::GetProcessContextRequirements{ .instance_id = instance_id()}); } tresult PLUGIN_API Vst3PluginProxyImpl::programDataSupported( Steinberg::Vst::ProgramListID listId) { - return bridge.send_message(YaProgramListData::ProgramDataSupported{ + return bridge_.send_message(YaProgramListData::ProgramDataSupported{ .instance_id = instance_id(), .list_id = listId}); } @@ -1113,7 +1118,7 @@ Vst3PluginProxyImpl::getProgramData(Steinberg::Vst::ProgramListID listId, int32 programIndex, Steinberg::IBStream* data) { if (data) { - const GetProgramDataResponse response = bridge.send_message( + const GetProgramDataResponse response = bridge_.send_message( YaProgramListData::GetProgramData{.instance_id = instance_id(), .list_id = listId, .program_index = programIndex, @@ -1123,7 +1128,7 @@ Vst3PluginProxyImpl::getProgramData(Steinberg::Vst::ProgramListID listId, return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IProgramListData::getProgramData()'"); return Steinberg::kInvalidArgument; @@ -1135,13 +1140,13 @@ Vst3PluginProxyImpl::setProgramData(Steinberg::Vst::ProgramListID listId, int32 programIndex, Steinberg::IBStream* data) { if (data) { - return bridge.send_message( + return bridge_.send_message( YaProgramListData::SetProgramData{.instance_id = instance_id(), .list_id = listId, .program_index = programIndex, .data = data}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IProgramListData::setProgramData()'"); return Steinberg::kInvalidArgument; @@ -1150,7 +1155,7 @@ Vst3PluginProxyImpl::setProgramData(Steinberg::Vst::ProgramListID listId, tresult PLUGIN_API Vst3PluginProxyImpl::unitDataSupported(Steinberg::Vst::UnitID unitId) { - return bridge.send_message(YaUnitData::UnitDataSupported{ + return bridge_.send_message(YaUnitData::UnitDataSupported{ .instance_id = instance_id(), .unit_id = unitId}); } @@ -1159,14 +1164,14 @@ Vst3PluginProxyImpl::getUnitData(Steinberg::Vst::UnitID unitId, Steinberg::IBStream* data) { if (data) { const GetUnitDataResponse response = - bridge.send_message(YaUnitData::GetUnitData{ + bridge_.send_message(YaUnitData::GetUnitData{ .instance_id = instance_id(), .unit_id = unitId, .data = data}); assert(response.data.write_back(data) == Steinberg::kResultOk); return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to 'IUnitData::getUnitData()'"); return Steinberg::kInvalidArgument; } @@ -1176,17 +1181,17 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setUnitData(Steinberg::Vst::UnitID unitId, Steinberg::IBStream* data) { if (data) { - return bridge.send_message(YaUnitData::SetUnitData{ + return bridge_.send_message(YaUnitData::SetUnitData{ .instance_id = instance_id(), .unit_id = unitId, .data = data}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to 'IUnitData::setUnitData()'"); return Steinberg::kInvalidArgument; } } int32 PLUGIN_API Vst3PluginProxyImpl::getUnitCount() { - return bridge.send_message( + return bridge_.send_message( YaUnitInfo::GetUnitCount{.instance_id = instance_id()}); } @@ -1194,7 +1199,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getUnitInfo(int32 unitIndex, Steinberg::Vst::UnitInfo& info /*out*/) { const GetUnitInfoResponse response = - bridge.send_message(YaUnitInfo::GetUnitInfo{ + bridge_.send_message(YaUnitInfo::GetUnitInfo{ .instance_id = instance_id(), .unit_index = unitIndex}); info = response.info; @@ -1203,7 +1208,7 @@ Vst3PluginProxyImpl::getUnitInfo(int32 unitIndex, } int32 PLUGIN_API Vst3PluginProxyImpl::getProgramListCount() { - return bridge.send_message( + return bridge_.send_message( YaUnitInfo::GetProgramListCount{.instance_id = instance_id()}); } @@ -1211,7 +1216,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getProgramListInfo( int32 listIndex, Steinberg::Vst::ProgramListInfo& info /*out*/) { const GetProgramListInfoResponse response = - bridge.send_message(YaUnitInfo::GetProgramListInfo{ + bridge_.send_message(YaUnitInfo::GetProgramListInfo{ .instance_id = instance_id(), .list_index = listIndex}); info = response.info; @@ -1224,7 +1229,7 @@ Vst3PluginProxyImpl::getProgramName(Steinberg::Vst::ProgramListID listId, int32 programIndex, Steinberg::Vst::String128 name /*out*/) { if (name) { - const GetProgramNameResponse response = bridge.send_message( + const GetProgramNameResponse response = bridge_.send_message( YaUnitInfo::GetProgramName{.instance_id = instance_id(), .list_id = listId, .program_index = programIndex}); @@ -1234,7 +1239,7 @@ Vst3PluginProxyImpl::getProgramName(Steinberg::Vst::ProgramListID listId, return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to 'IUnitInfo::getProgramName()'"); return Steinberg::kInvalidArgument; } @@ -1246,7 +1251,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getProgramInfo( Steinberg::Vst::CString attributeId /*in*/, Steinberg::Vst::String128 attributeValue /*out*/) { if (attributeId && attributeValue) { - const GetProgramInfoResponse response = bridge.send_message( + const GetProgramInfoResponse response = bridge_.send_message( YaUnitInfo::GetProgramInfo{.instance_id = instance_id(), .list_id = listId, .program_index = programIndex, @@ -1258,7 +1263,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getProgramInfo( return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to 'IUnitInfo::getProgramInfo()'"); return Steinberg::kInvalidArgument; } @@ -1267,7 +1272,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getProgramInfo( tresult PLUGIN_API Vst3PluginProxyImpl::hasProgramPitchNames(Steinberg::Vst::ProgramListID listId, int32 programIndex) { - return bridge.send_message( + return bridge_.send_message( YaUnitInfo::HasProgramPitchNames{.instance_id = instance_id(), .list_id = listId, .program_index = programIndex}); @@ -1279,7 +1284,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getProgramPitchName( int16 midiPitch, Steinberg::Vst::String128 name /*out*/) { if (name) { - const GetProgramPitchNameResponse response = bridge.send_message( + const GetProgramPitchNameResponse response = bridge_.send_message( YaUnitInfo::GetProgramPitchName{.instance_id = instance_id(), .list_id = listId, .program_index = programIndex, @@ -1290,7 +1295,7 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getProgramPitchName( return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IUnitInfo::getProgramPitchName()'"); return Steinberg::kInvalidArgument; @@ -1298,13 +1303,13 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getProgramPitchName( } Steinberg::Vst::UnitID PLUGIN_API Vst3PluginProxyImpl::getSelectedUnit() { - return bridge.send_message( + return bridge_.send_message( YaUnitInfo::GetSelectedUnit{.instance_id = instance_id()}); } tresult PLUGIN_API Vst3PluginProxyImpl::selectUnit(Steinberg::Vst::UnitID unitId) { - return bridge.send_message(YaUnitInfo::SelectUnit{ + return bridge_.send_message(YaUnitInfo::SelectUnit{ .instance_id = instance_id(), .unit_id = unitId}); } @@ -1314,7 +1319,7 @@ Vst3PluginProxyImpl::getUnitByBus(Steinberg::Vst::MediaType type, int32 busIndex, int32 channel, Steinberg::Vst::UnitID& unitId /*out*/) { - const GetUnitByBusResponse response = bridge.send_message( + const GetUnitByBusResponse response = bridge_.send_message( YaUnitInfo::GetUnitByBus{.instance_id = instance_id(), .type = type, .dir = dir, @@ -1331,13 +1336,13 @@ Vst3PluginProxyImpl::setUnitProgramData(int32 listOrUnitId, int32 programIndex, Steinberg::IBStream* data) { if (data) { - return bridge.send_message( + return bridge_.send_message( YaUnitInfo::SetUnitProgramData{.instance_id = instance_id(), .list_or_unit_id = listOrUnitId, .program_index = programIndex, .data = data}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IUnitInfo::setUnitProgramData()'"); return Steinberg::kInvalidArgument; @@ -1348,15 +1353,18 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getXmlRepresentationStream( Steinberg::Vst::RepresentationInfo& info /*in*/, Steinberg::IBStream* stream /*out*/) { if (stream) { - const GetXmlRepresentationStreamResponse response = bridge.send_message( - YaXmlRepresentationController::GetXmlRepresentationStream{ - .instance_id = instance_id(), .info = info, .stream = stream}); + const GetXmlRepresentationStreamResponse response = + bridge_.send_message( + YaXmlRepresentationController::GetXmlRepresentationStream{ + .instance_id = instance_id(), + .info = info, + .stream = stream}); response.stream.write_back(stream); return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IXmlRepresentationController::getXmlRepresentationStream()'"); return Steinberg::kInvalidArgument; @@ -1364,8 +1372,8 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getXmlRepresentationStream( } void Vst3PluginProxyImpl::clear_bus_cache() noexcept { - std::lock_guard lock(processing_bus_cache_mutex); - if (processing_bus_cache) { - processing_bus_cache.emplace(); + std::lock_guard lock(processing_bus_cache_mutex_); + if (processing_bus_cache_) { + processing_bus_cache_.emplace(); } } diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.h b/src/plugin/bridges/vst3-impls/plugin-proxy.h index 56eef6d7..268cd790 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.h +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.h @@ -71,8 +71,8 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * * See the bottom of this class for more information on what we're caching. * - * @see clear_bus_cache - * @see function_result_cache + * @see clear_bus_cache_ + * @see function_result_cache_ */ void clear_caches() noexcept; @@ -309,7 +309,7 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * callback on a component handler proxy object, we'll pass the call through * to this object. */ - Steinberg::IPtr component_handler; + Steinberg::IPtr component_handler_; /** * If the host places a proxy between two objects in @@ -320,15 +320,15 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * IDs this way, we'll still connect the objects directly on the Wine plugin * host side. So far this is only needed for Ardour. */ - std::optional connected_instance_id; + std::optional connected_instance_id_; /** * If we cannot manage to bypass the connection proxy as mentioned in the - * docstring of `connected_instance_id`, then we'll store the host's + * docstring of `connected_instance_id_`, then we'll store the host's * connection point proxy here and we'll proxy that proxy, if that makes any * sense. */ - Steinberg::IPtr connection_point_proxy; + Steinberg::IPtr connection_point_proxy_; /** * An unmanaged, raw pointer to the `IPlugView` instance returned in our @@ -340,7 +340,7 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * currently only defines a single type of view so that shouldn't be an * issue */ - Vst3PlugViewProxyImpl* last_created_plug_view = nullptr; + Vst3PlugViewProxyImpl* last_created_plug_view_ = nullptr; /** * A pointer to a context menu returned by the host as a response to a call @@ -373,28 +373,28 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * @see Vst3PluginProxyImpl::register_context_menu * @see Vst3PluginProxyImpl::unregister_context_menu */ - std::map context_menus; - std::mutex context_menus_mutex; + std::map context_menus_; + std::mutex context_menus_mutex_; // The following pointers are cast from `host_context` if // `IPluginBase::initialize()` has been called - Steinberg::FUnknownPtr host_application; + Steinberg::FUnknownPtr host_application_; Steinberg::FUnknownPtr - plug_interface_support; + plug_interface_support_; // The following pointers are cast from `component_handler` if // `IEditController::setComponentHandler()` has been called Steinberg::FUnknownPtr - component_handler_2; + component_handler_2_; Steinberg::FUnknownPtr - component_handler_3; + component_handler_3_; Steinberg::FUnknownPtr - component_handler_bus_activation; - Steinberg::FUnknownPtr progress; - Steinberg::FUnknownPtr unit_handler; - Steinberg::FUnknownPtr unit_handler_2; + component_handler_bus_activation_; + Steinberg::FUnknownPtr progress_; + Steinberg::FUnknownPtr unit_handler_; + Steinberg::FUnknownPtr unit_handler_2_; private: /** @@ -409,11 +409,11 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * manually flush this cache when the stores information potentially becomes * invalid. * - * @see processing_bus_cache + * @see processing_bus_cache_ */ void clear_bus_cache() noexcept; - Vst3PluginBridge& bridge; + Vst3PluginBridge& bridge_; /** * An host context if we get passed one through `IPluginBase::initialize()`. @@ -422,14 +422,14 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * all plugin instances so we should not have to store it here separately, * but for the sake of correctness we will. */ - Steinberg::IPtr host_context; + Steinberg::IPtr host_context_; /** * We'll periodically synchronize the Wine host's audio thread priority with * that of the host. Since the overhead from doing so does add up, we'll * only do this every once in a while. */ - time_t last_audio_thread_priority_synchronization = 0; + time_t last_audio_thread_priority_synchronization_ = 0; /** * Used to assign unique identifiers to context menus created by @@ -437,7 +437,7 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * * @related Vst3PluginProxyImpl::register_context_menu */ - std::atomic_size_t current_context_menu_id; + std::atomic_size_t current_context_menu_id_; /** * We'll reuse the request objects for the audio processor so we can keep @@ -449,16 +449,16 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * from and to existing objects without having to copy or reallocate them. * * To reduce the amount of copying during audio processing we'll write the - * audio data to a shared memory object stored in `process_buffers` first. + * audio data to a shared memory object stored in `process_buffers_` first. */ - YaAudioProcessor::Process process_request; + YaAudioProcessor::Process process_request_; /** * The response object we'll get in return when we send the - * `process_request` object above to the Wine plugin host. This object also + * `process_request_` object above to the Wine plugin host. This object also * contains heap data, so we also want to reuse this. */ - YaAudioProcessor::ProcessResponse process_response; + YaAudioProcessor::ProcessResponse process_response_; /** * A shared memory object to share audio buffers between the native plugin @@ -469,7 +469,7 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * * This will be set up during `IAudioProcessor::setupProcessing()`. */ - std::optional process_buffers; + std::optional process_buffers_; // Caches @@ -480,7 +480,7 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * values should be immutable until the plugin tells the host that this * information has changed). * - * @see processing_bus_cache + * @see processing_bus_cache_ */ struct BusInfoCache { // `std::unordered_map` would be better here, but tuples aren't hashable @@ -508,10 +508,10 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * Since this information is immutable during audio processing, this cache * will only be available at those times. * - * @see clear_bus_cache + * @see clear_bus_cache_ */ - std::optional processing_bus_cache; - std::mutex processing_bus_cache_mutex; + std::optional processing_bus_cache_; + std::mutex processing_bus_cache_mutex_; /** * A cache for several function calls that should be safe to cache since @@ -519,7 +519,7 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * calls until the plugin tells the host that parameter information has * changed. * - * @see function_result_cache + * @see function_result_cache_ */ struct FunctionResultCache { /** @@ -551,6 +551,6 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { * * @see clear_caches */ - FunctionResultCache function_result_cache; - std::mutex function_result_cache_mutex; + FunctionResultCache function_result_cache_; + std::mutex function_result_cache_mutex_; }; diff --git a/src/plugin/bridges/vst3.cpp b/src/plugin/bridges/vst3.cpp index c3b823e6..737a4400 100644 --- a/src/plugin/bridges/vst3.cpp +++ b/src/plugin/bridges/vst3.cpp @@ -30,12 +30,12 @@ Vst3PluginBridge::Vst3PluginBridge() [](boost::asio::io_context& io_context, const PluginInfo& info) { return Vst3Sockets( io_context, - generate_endpoint_base(info.native_library_path.filename() + generate_endpoint_base(info.native_library_path_.filename() .replace_extension("") .string()), true); }), - logger(generic_logger) { + logger_(generic_logger_) { log_init_message(); // This will block until all sockets have been connected to by the Wine VST @@ -47,12 +47,12 @@ Vst3PluginBridge::Vst3PluginBridge() // messaging mechanism is how we relay the VST3 communication protocol. As a // first thing, the Wine VST host will ask us for a copy of the // configuration. - host_callback_handler = std::jthread([&]() { + host_callback_handler_ = std::jthread([&]() { set_realtime_priority(true); pthread_setname_np(pthread_self(), "host-callbacks"); - sockets.vst_host_callback.receive_messages( - std::pair(logger, false), + sockets_.vst_host_callback_.receive_messages( + std::pair(logger_, false), overload{ [&](const Vst3ContextMenuProxy::Destruct& request) -> Vst3ContextMenuProxy::Destruct::Response { @@ -68,14 +68,14 @@ Vst3PluginBridge::Vst3PluginBridge() -> WantsConfiguration::Response { warn_on_version_mismatch(request.host_version); - return config; + return config_; }, [&](const YaComponentHandler::BeginEdit& request) -> YaComponentHandler::BeginEdit::Response { const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.component_handler->beginEdit( + return proxy_object.component_handler_->beginEdit( request.id); }, [&](const YaComponentHandler::PerformEdit& request) @@ -83,7 +83,7 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.component_handler->performEdit( + return proxy_object.component_handler_->performEdit( request.id, request.value_normalized); }, [&](const YaComponentHandler::EndEdit& request) @@ -91,7 +91,7 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.component_handler->endEdit(request.id); + return proxy_object.component_handler_->endEdit(request.id); }, [&](const YaComponentHandler::RestartComponent& request) -> YaComponentHandler::RestartComponent::Response { @@ -102,7 +102,7 @@ Vst3PluginBridge::Vst3PluginBridge() // of our caches whenever a plugin requests a restart proxy_object.clear_caches(); - return proxy_object.component_handler->restartComponent( + return proxy_object.component_handler_->restartComponent( request.flags); }, [&](const YaComponentHandler2::SetDirty& request) @@ -110,7 +110,7 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.component_handler_2->setDirty( + return proxy_object.component_handler_2_->setDirty( request.state); }, [&](const YaComponentHandler2::RequestOpenEditor& request) @@ -118,7 +118,7 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.component_handler_2->requestOpenEditor( + return proxy_object.component_handler_2_->requestOpenEditor( request.name.c_str()); }, [&](const YaComponentHandler2::StartGroupEdit& request) @@ -126,14 +126,14 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.component_handler_2->startGroupEdit(); + return proxy_object.component_handler_2_->startGroupEdit(); }, [&](const YaComponentHandler2::FinishGroupEdit& request) -> YaComponentHandler2::FinishGroupEdit::Response { const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.component_handler_2->finishGroupEdit(); + return proxy_object.component_handler_2_->finishGroupEdit(); }, [&](const YaComponentHandler3::CreateContextMenu& request) -> YaComponentHandler3::CreateContextMenu::Response { @@ -146,13 +146,15 @@ Vst3PluginBridge::Vst3PluginBridge() // (and only) `IPlugView*` instance returned by the // plugin. Vst3PlugViewProxyImpl* plug_view = - proxy_object.last_created_plug_view; + proxy_object.last_created_plug_view_; Steinberg::IPtr context_menu = Steinberg::owned( - proxy_object.component_handler_3->createContextMenu( - plug_view, request.param_id ? &*request.param_id - : nullptr)); + proxy_object.component_handler_3_ + ->createContextMenu(plug_view, + request.param_id + ? &*request.param_id + : nullptr)); if (context_menu) { const size_t context_menu_id = @@ -176,7 +178,7 @@ Vst3PluginBridge::Vst3PluginBridge() request.owner_instance_id); return proxy_object - .component_handler_bus_activation + .component_handler_bus_activation_ ->requestBusActivation( request.type, request.dir, request.index, request.state); @@ -186,7 +188,7 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.context_menus + return proxy_object.context_menus_ .at(request.context_menu_id) .menu->getItemCount(); }, @@ -196,7 +198,7 @@ Vst3PluginBridge::Vst3PluginBridge() get_proxy(request.owner_instance_id); Vst3PluginProxyImpl::ContextMenu& context_menu = - proxy_object.context_menus.at(request.context_menu_id); + proxy_object.context_menus_.at(request.context_menu_id); if (request.target) { context_menu.targets[request.item.tag] = @@ -217,7 +219,7 @@ Vst3PluginBridge::Vst3PluginBridge() get_proxy(request.owner_instance_id); Vst3PluginProxyImpl::ContextMenu& context_menu = - proxy_object.context_menus.at(request.context_menu_id); + proxy_object.context_menus_.at(request.context_menu_id); if (const auto it = context_menu.targets.find(request.item.tag); @@ -236,9 +238,9 @@ Vst3PluginBridge::Vst3PluginBridge() // REAPER requires this to be run from its provided event // loop or else it will likely segfault at some point - return proxy_object.last_created_plug_view->run_gui_task( + return proxy_object.last_created_plug_view_->run_gui_task( [&, &proxy_object = proxy_object]() -> tresult { - return proxy_object.context_menus + return proxy_object.context_menus_ .at(request.context_menu_id) .menu->popup(request.x, request.y); }); @@ -248,7 +250,7 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(request.instance_id); - return proxy_object.connection_point_proxy->notify( + return proxy_object.connection_point_proxy_->notify( &request.message_ptr); }, [&](const YaHostApplication::GetName& request) @@ -263,7 +265,7 @@ Vst3PluginBridge::Vst3PluginBridge() // under some other host. We do this here to stay // consistent with the VST2 version, where it has to // be done on the plugin's side. - if (config.hide_daw) { + if (config_.hide_daw) { // This is the only sane-ish way to copy a c-style // string to an UTF-16 string buffer Steinberg::UString128(product_name_override) @@ -279,10 +281,11 @@ Vst3PluginBridge::Vst3PluginBridge() get_proxy(*request.owner_instance_id); result = - proxy_object.host_application->getName(name); + proxy_object.host_application_->getName(name); } else { result = - plugin_factory->host_application->getName(name); + plugin_factory_->host_application_->getName( + name); } } @@ -302,12 +305,12 @@ Vst3PluginBridge::Vst3PluginBridge() // (and only) `IPlugView*` instance returned by the // plugin. Vst3PlugViewProxyImpl* plug_view = - proxy_object.last_created_plug_view; + proxy_object.last_created_plug_view_; // REAPER requires this to be run from its provided event // loop or else it will likely segfault at some point return plug_view->run_gui_task([&]() -> tresult { - return plug_view->plug_frame->resizeView( + return plug_view->plug_frame_->resizeView( plug_view, &request.new_size); }); }, @@ -323,11 +326,11 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(*request.owner_instance_id); - return proxy_object.plug_interface_support + return proxy_object.plug_interface_support_ ->isPlugInterfaceSupported( request.iid.get_native_uid().data()); } else { - return plugin_factory->plug_interface_support + return plugin_factory_->plug_interface_support_ ->isPlugInterfaceSupported( request.iid.get_native_uid().data()); } @@ -338,7 +341,7 @@ Vst3PluginBridge::Vst3PluginBridge() get_proxy(request.owner_instance_id); Steinberg::Vst::IProgress::ID out_id; - const tresult result = proxy_object.progress->start( + const tresult result = proxy_object.progress_->start( request.type, request.optional_description ? u16string_to_tchar_pointer( @@ -354,22 +357,22 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.progress->update(request.id, - request.norm_value); + return proxy_object.progress_->update(request.id, + request.norm_value); }, [&](const YaProgress::Finish& request) -> YaProgress::Finish::Response { const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.progress->finish(request.id); + return proxy_object.progress_->finish(request.id); }, [&](const YaUnitHandler::NotifyUnitSelection& request) -> YaUnitHandler::NotifyUnitSelection::Response { const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.unit_handler->notifyUnitSelection( + return proxy_object.unit_handler_->notifyUnitSelection( request.unit_id); }, [&](const YaUnitHandler::NotifyProgramListChange& request) @@ -377,7 +380,7 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.unit_handler->notifyProgramListChange( + return proxy_object.unit_handler_->notifyProgramListChange( request.list_id, request.program_index); }, [&](const YaUnitHandler2::NotifyUnitByBusChange& request) @@ -385,7 +388,8 @@ Vst3PluginBridge::Vst3PluginBridge() const auto& [proxy_object, _] = get_proxy(request.owner_instance_id); - return proxy_object.unit_handler_2->notifyUnitByBusChange(); + return proxy_object.unit_handler_2_ + ->notifyUnitByBusChange(); }, }); }); @@ -394,8 +398,8 @@ Vst3PluginBridge::Vst3PluginBridge() Vst3PluginBridge::~Vst3PluginBridge() noexcept { try { // Drop all work make sure all sockets are closed - plugin_host->terminate(); - io_context.stop(); + plugin_host_->terminate(); + io_context_.stop(); } catch (const boost::system::system_error&) { // It could be that the sockets have already been closed or that the // process has already exited (at which point we probably won't be @@ -409,56 +413,56 @@ Steinberg::IPluginFactory* Vst3PluginBridge::get_plugin_factory() { // the plugin factory with an `IPtr` ourselves so it cannot be freed before // `Vst3PluginBridge` gets freed. This is needed for REAPER as REAPER does // not call `ModuleExit()`. - if (!plugin_factory) { + if (!plugin_factory_) { // Set up the plugin factory, since this is the first thing the host // will request after loading the module. Host callback handlers should // have started before this since the Wine plugin host will request a // copy of the configuration during its initialization. Vst3PluginFactoryProxy::ConstructArgs factory_args = - sockets.host_vst_control.send_message( + sockets_.host_vst_control_.send_message( Vst3PluginFactoryProxy::Construct{}, - std::pair(logger, true)); - plugin_factory = Steinberg::owned( + std::pair(logger_, true)); + plugin_factory_ = Steinberg::owned( new Vst3PluginFactoryProxyImpl(*this, std::move(factory_args))); } // Because we're returning a raw pointer, we have to increase the reference // count ourselves - plugin_factory->addRef(); + plugin_factory_->addRef(); - return plugin_factory; + return plugin_factory_; } std::pair> Vst3PluginBridge::get_proxy(size_t instance_id) noexcept { - std::shared_lock lock(plugin_proxies_mutex); + std::shared_lock lock(plugin_proxies_mutex_); return std::pair>( - plugin_proxies.at(instance_id).get(), std::move(lock)); + plugin_proxies_.at(instance_id).get(), std::move(lock)); } void Vst3PluginBridge::register_plugin_proxy( Vst3PluginProxyImpl& proxy_object) { - std::unique_lock lock(plugin_proxies_mutex); + std::unique_lock lock(plugin_proxies_mutex_); - plugin_proxies.emplace(proxy_object.instance_id(), - std::ref(proxy_object)); + plugin_proxies_.emplace(proxy_object.instance_id(), + std::ref(proxy_object)); // For optimization reaons we use dedicated sockets for functions that will // be run in the audio processing loop if (proxy_object.YaAudioProcessor::supported() || proxy_object.YaComponent::supported()) { - sockets.add_audio_processor_and_connect(proxy_object.instance_id()); + sockets_.add_audio_processor_and_connect(proxy_object.instance_id()); } } void Vst3PluginBridge::unregister_plugin_proxy( Vst3PluginProxyImpl& proxy_object) { - std::lock_guard lock(plugin_proxies_mutex); + std::lock_guard lock(plugin_proxies_mutex_); - plugin_proxies.erase(proxy_object.instance_id()); + plugin_proxies_.erase(proxy_object.instance_id()); if (proxy_object.YaAudioProcessor::supported() || proxy_object.YaComponent::supported()) { - sockets.remove_audio_processor(proxy_object.instance_id()); + sockets_.remove_audio_processor(proxy_object.instance_id()); } } diff --git a/src/plugin/bridges/vst3.h b/src/plugin/bridges/vst3.h index 40c772a4..fd8e8123 100644 --- a/src/plugin/bridges/vst3.h +++ b/src/plugin/bridges/vst3.h @@ -70,7 +70,7 @@ class Vst3PluginBridge : PluginBridge> { * have to manually increase the reference count here for every plugin * factory instance we return. * - * @see plugin_factory + * @see plugin_factory_ */ Steinberg::IPluginFactory* get_plugin_factory(); @@ -93,7 +93,7 @@ class Vst3PluginBridge : PluginBridge> { * @param proxy_object The proxy object so we can access its host context * and unique instance identifier. * - * @see plugin_proxies + * @see plugin_proxies_ */ void register_plugin_proxy(Vst3PluginProxyImpl& proxy_object); @@ -105,19 +105,19 @@ class Vst3PluginBridge : PluginBridge> { * @param proxy_object The proxy object so we can access its unique instance * identifier. * - * @see plugin_proxies + * @see plugin_proxies_ */ void unregister_plugin_proxy(Vst3PluginProxyImpl& proxy_object); /** * Send a control message to the Wine plugin host return the response. This - * is a shorthand for `sockets.host_vst_control.send_message` for use in + * is a shorthand for `sockets_.host_vst_control_.send_message()` for use in * VST3 interface implementations. */ template typename T::Response send_message(const T& object) { - return sockets.host_vst_control.send_message( - object, std::pair(logger, true)); + return sockets_.host_vst_control_.send_message( + object, std::pair(logger_, true)); } /** @@ -128,8 +128,8 @@ class Vst3PluginBridge : PluginBridge> { */ template typename T::Response send_audio_processor_message(const T& object) { - return sockets.send_audio_processor_message( - object, std::pair(logger, true)); + return sockets_.send_audio_processor_message( + object, std::pair(logger_, true)); } /** @@ -142,9 +142,9 @@ class Vst3PluginBridge : PluginBridge> { typename T::Response& receive_audio_processor_message_into( const T& object, typename T::Response& response_object) { - return sockets.receive_audio_processor_message_into( + return sockets_.receive_audio_processor_message_into( object, response_object, - std::pair(logger, true)); + std::pair(logger_, true)); } /** @@ -161,7 +161,7 @@ class Vst3PluginBridge : PluginBridge> { */ template typename T::Response send_mutually_recursive_message(const T& object) { - return mutual_recursion.fork([&]() { return send_message(object); }); + return mutual_recursion_.fork([&]() { return send_message(object); }); } /** @@ -178,21 +178,21 @@ class Vst3PluginBridge : PluginBridge> { template std::optional> maybe_run_on_mutual_recursion_thread( F&& fn) { - return mutual_recursion.maybe_handle(std::forward(fn)); + return mutual_recursion_.maybe_handle(std::forward(fn)); } /** * The logging facility used for this instance of yabridge. Wraps around * `PluginBridge::generic_logger`. */ - Vst3Logger logger; + Vst3Logger logger_; private: /** * Handles callbacks from the plugin to the host over the - * `vst_host_callback` sockets. + * `vst_host_callback_` sockets. */ - std::jthread host_callback_handler; + std::jthread host_callback_handler_; /** * Our plugin factory. All information about the plugin and its supported @@ -202,7 +202,7 @@ class Vst3PluginBridge : PluginBridge> { * * @related get_plugin_factory */ - Steinberg::IPtr plugin_factory = nullptr; + Steinberg::IPtr plugin_factory_ = nullptr; /** * All VST3 plugin objects we created from this plugin. We keep track of @@ -215,7 +215,7 @@ class Vst3PluginBridge : PluginBridge> { * the destructor. */ std::unordered_map> - plugin_proxies; + plugin_proxies_; /** * In theory all object handling is safe iff the host also doesn't do @@ -228,12 +228,12 @@ class Vst3PluginBridge : PluginBridge> { * `get_proxy()` never yields to the scheduler during audio * processing, but it's still something we should avoid at all costs. */ - std::shared_mutex plugin_proxies_mutex; + std::shared_mutex plugin_proxies_mutex_; /** * Used in `Vst3Bridge::send_mutually_recursive_message()` to be able to * execute functions from that same calling thread while we're waiting for a * response. This is used in `Vst3PlugViewProxyImpl::run_loop_tasks()`. */ - MutualRecursionHelper mutual_recursion; + MutualRecursionHelper mutual_recursion_; }; diff --git a/src/plugin/host-process.cpp b/src/plugin/host-process.cpp index b43a4f4f..1d777d38 100644 --- a/src/plugin/host-process.cpp +++ b/src/plugin/host-process.cpp @@ -29,11 +29,11 @@ HostProcess::HostProcess(boost::asio::io_context& io_context, Logger& logger, const Configuration& config, Sockets& sockets) - : stdout_pipe(io_context), - stderr_pipe(io_context), - config(config), - sockets(sockets), - logger(logger) { + : stdout_pipe_(io_context), + stderr_pipe_(io_context), + config_(config), + sockets_(sockets), + logger_(logger) { // See the comment above the `on_exec_setup` in `launch_host()` if (config.disable_pipes) { logger.log(""); @@ -44,9 +44,9 @@ HostProcess::HostProcess(boost::asio::io_context& io_context, // Print the Wine host's STDOUT and STDERR streams to the log file. This // should be done before trying to accept the sockets as otherwise we // will miss all output. - logger.async_log_pipe_lines(stdout_pipe, stdout_buffer, + logger.async_log_pipe_lines(stdout_pipe_, stdout_buffer_, "[Wine STDOUT] "); - logger.async_log_pipe_lines(stderr_pipe, stderr_buffer, + logger.async_log_pipe_lines(stderr_pipe_, stderr_buffer_, "[Wine STDERR] "); } } @@ -60,12 +60,12 @@ IndividualHost::IndividualHost(boost::asio::io_context& io_context, const PluginInfo& plugin_info, const HostRequest& host_request) : HostProcess(io_context, logger, config, sockets), - plugin_info(plugin_info), - host_path(find_vst_host(plugin_info.native_library_path, - plugin_info.plugin_arch, - false)), - host( - launch_host(host_path, + plugin_info_(plugin_info), + host_path_(find_vst_host(plugin_info.native_library_path_, + plugin_info.plugin_arch_, + false)), + host_( + launch_host(host_path_, plugin_type_to_string(host_request.plugin_type), #if defined(WITH_WINEDBG) && defined(WINEDBG_LEGACY_ARGUMENT_QUOTING) // Old versions of winedbg flattened all command line @@ -92,13 +92,13 @@ IndividualHost::IndividualHost(boost::asio::io_context& io_context, } fs::path IndividualHost::path() { - return host_path; + return host_path_; } bool IndividualHost::running() { // NOTE: `boost::process::child::running()` still considers zombies as // running, so it's useless for our purposes. - return pid_running(host.id()); + return pid_running(host_.id()); } void IndividualHost::terminate() { @@ -107,12 +107,12 @@ void IndividualHost::terminate() { // by that process, so if we don't manually close the sockets there // will still be threads listening on those sockets which in turn also // prevents us from joining our `std::jthread`s on the plugin side. - sockets.close(); + sockets_.close(); - host.terminate(); + host_.terminate(); // NOTE: This leaves a zombie, because Boost.Process will actually not call // `wait()` after we have terminated the process. - host.wait(); + host_.wait(); } GroupHost::GroupHost(boost::asio::io_context& io_context, @@ -122,10 +122,10 @@ GroupHost::GroupHost(boost::asio::io_context& io_context, const PluginInfo& plugin_info, const HostRequest& host_request) : HostProcess(io_context, logger, config, sockets), - plugin_info(plugin_info), - host_path(find_vst_host(plugin_info.native_library_path, - plugin_info.plugin_arch, - true)) { + plugin_info_(plugin_info), + host_path_(find_vst_host(plugin_info.native_library_path_, + plugin_info.plugin_arch_, + true)) { // When using plugin groups, we'll first try to connect to an existing group // host process and ask it to host our plugin. If no such process exists, // then we'll start a new process. In the event that multiple yabridge @@ -134,10 +134,10 @@ GroupHost::GroupHost(boost::asio::io_context& io_context, // other processes will exit. When a plugin's host process has exited, it // will try to connect to the socket once more in the case that another // process is now listening on it. - const fs::path endpoint_base_dir = sockets.base_dir; + const fs::path endpoint_base_dir = sockets.base_dir_; const fs::path group_socket_path = generate_group_endpoint( *config.group, plugin_info.normalize_wine_prefix(), - plugin_info.plugin_arch); + plugin_info.plugin_arch_); const auto connect = [&io_context, host_request, endpoint_base_dir, group_socket_path]() { boost::asio::local::stream_protocol::socket group_socket(io_context); @@ -157,12 +157,12 @@ GroupHost::GroupHost(boost::asio::io_context& io_context, // because it should run independently of this yabridge instance as // it will likely outlive it. bp::child group_host = - launch_host(host_path, group_socket_path, + launch_host(host_path_, group_socket_path, bp::env = plugin_info.create_host_env()); group_host.detach(); const pid_t group_host_pid = group_host.id(); - group_host_connect_handler = + group_host_connect_handler_ = std::jthread([this, connect, group_host_pid]() { set_realtime_priority(true); pthread_setname_np(pthread_self(), "group-connect"); @@ -191,26 +191,26 @@ GroupHost::GroupHost(boost::asio::io_context& io_context, try { connect(); } catch (const boost::system::system_error&) { - startup_failed = true; + startup_failed_ = true; } }); } } fs::path GroupHost::path() { - return host_path; + return host_path_; } bool GroupHost::running() noexcept { // When we are unable to connect to a new or existing group host process, // then we'll consider the startup failed and we'll allow the initialization // process to terminate. - return !startup_failed; + return !startup_failed_; } void GroupHost::terminate() { // There's no need to manually terminate group host processes as they will // shut down automatically after all plugins have exited. Manually closing // the sockets will cause the associated plugin to exit. - sockets.close(); + sockets_.close(); } diff --git a/src/plugin/host-process.h b/src/plugin/host-process.h index f06d160d..3483bf99 100644 --- a/src/plugin/host-process.h +++ b/src/plugin/host-process.h @@ -90,8 +90,8 @@ class HostProcess { #else host_path, #endif // WITH_WINEDBG - boost::process::std_out = stdout_pipe, - boost::process::std_err = stderr_pipe, + boost::process::std_out = stdout_pipe_, + boost::process::std_err = stderr_pipe_, // NOTE: If the Wine process outlives the host, then it may cause // issues if our process is still keeping the host's file // descriptors alive that. This can prevent Ardour from @@ -113,9 +113,9 @@ class HostProcess { } // See above - if (config.disable_pipes) { + if (config_.disable_pipes) { const int redirect_fd = - open(config.disable_pipes->c_str(), + open(config_.disable_pipes->c_str(), O_CREAT | O_APPEND | O_WRONLY, 0640); assert(redirect_fd != -1); @@ -147,31 +147,31 @@ class HostProcess { /** * The STDOUT stream of the Wine process we can forward to the logger. */ - patched_async_pipe stdout_pipe; + patched_async_pipe stdout_pipe_; /** * The STDERR stream of the Wine process we can forward to the logger. */ - patched_async_pipe stderr_pipe; + patched_async_pipe stderr_pipe_; /** * The current plugin instance's configuration. */ - const Configuration& config; + const Configuration& config_; /** * The associated sockets for the plugin we're hosting. This is used to * terminate the plugin. */ - Sockets& sockets; + Sockets& sockets_; private: /** * The logger the Wine output will be written to. */ - Logger& logger; + Logger& logger_; - boost::asio::streambuf stdout_buffer; - boost::asio::streambuf stderr_buffer; + boost::asio::streambuf stdout_buffer_; + boost::asio::streambuf stderr_buffer_; }; /** @@ -212,9 +212,9 @@ class IndividualHost : public HostProcess { void terminate() override; private: - const PluginInfo& plugin_info; - boost::filesystem::path host_path; - boost::process::child host; + const PluginInfo& plugin_info_; + boost::filesystem::path host_path_; + boost::process::child host_; }; /** @@ -260,8 +260,8 @@ class GroupHost : public HostProcess { void terminate() override; private: - const PluginInfo& plugin_info; - boost::filesystem::path host_path; + const PluginInfo& plugin_info_; + boost::filesystem::path host_path_; /** * We want to either connect to an existing group host process, or spawn a @@ -279,7 +279,7 @@ class GroupHost : public HostProcess { * When this last step also fails, then we'll say that startup has failed * and we will terminate the plugin initialization process. */ - std::atomic_bool startup_failed; + std::atomic_bool startup_failed_; /** * A thread that waits for the group host to have started and then ask it to @@ -290,5 +290,5 @@ class GroupHost : public HostProcess { * TODO: Replace the polling with inotify to prevent delays and to reduce * wasting resources */ - std::jthread group_host_connect_handler; + std::jthread group_host_connect_handler_; }; diff --git a/src/plugin/utils.cpp b/src/plugin/utils.cpp index f9dfc05a..1a457f03 100644 --- a/src/plugin/utils.cpp +++ b/src/plugin/utils.cpp @@ -52,19 +52,19 @@ std::variant find_wine_prefix( fs::path windows_plugin_path); PluginInfo::PluginInfo(PluginType plugin_type, bool prefer_32bit_vst3) - : plugin_type(plugin_type), - native_library_path(get_this_file_location()), + : plugin_type_(plugin_type), + native_library_path_(get_this_file_location()), // As explained in the docstring, this is the actual Windows library. For // VST3 plugins that come in a module we should be loading that module // instead of the `.vst3` file within in, which is where // `windows_plugin_path` comes in. - windows_library_path(find_plugin_library(native_library_path, - plugin_type, - prefer_32bit_vst3)), - plugin_arch(find_dll_architecture(windows_library_path)), - windows_plugin_path( - normalize_plugin_path(windows_library_path, plugin_type)), - wine_prefix(find_wine_prefix(windows_plugin_path)) {} + windows_library_path_(find_plugin_library(native_library_path_, + plugin_type, + prefer_32bit_vst3)), + plugin_arch_(find_dll_architecture(windows_library_path_)), + windows_plugin_path_( + normalize_plugin_path(windows_library_path_, plugin_type)), + wine_prefix_(find_wine_prefix(windows_plugin_path_)) {} bp::environment PluginInfo::create_host_env() const { bp::environment env = boost::this_process::environment(); @@ -79,7 +79,7 @@ bp::environment PluginInfo::create_host_env() const { }, [](const DefaultWinePrefix&) {}, }, - wine_prefix); + wine_prefix_); return env; } @@ -94,7 +94,7 @@ boost::filesystem::path PluginInfo::normalize_wine_prefix() const { return fs::path(env.at("HOME").to_string()) / ".wine"; }, }, - wine_prefix); + wine_prefix_); } std::string PluginInfo::wine_version() const { diff --git a/src/plugin/utils.h b/src/plugin/utils.h index 94dae376..db61c3c7 100644 --- a/src/plugin/utils.h +++ b/src/plugin/utils.h @@ -70,7 +70,7 @@ struct PluginInfo { PluginInfo(PluginType plugin_type, bool prefer_32bit_vst3 = false); /** - * Create the environment for the plugin host based on `wine_prefix`. If + * Create the environment for the plugin host based on `wine_prefix_`. If * `WINEPREFIX` was already set then nothing will be changed. Otherwise * we'll set `WINEPREFIX` to the detected Wine prefix, or it will be left * unset if we could not detect a prefix. @@ -96,27 +96,27 @@ struct PluginInfo { */ std::string wine_version() const; - const PluginType plugin_type; + const PluginType plugin_type_; /** * The path to our `.so` file. For VST3 plugins this is *not* the VST3 * module (since that has to be bundle on Linux) but rather the .so file * contained in that bundle. */ - const boost::filesystem::path native_library_path; + const boost::filesystem::path native_library_path_; private: /** * The path to the Windows library (`.dll` or `.vst3`, not to be confused * with a `.vst3` bundle) that we're targeting. This should **not** be - * passed to the plugin host and `windows_plugin_path` should be used + * passed to the plugin host and `windows_plugin_path_` should be used * instead. We store this intermediate value so we can determine the * plugin's architecture. */ - const boost::filesystem::path windows_library_path; + const boost::filesystem::path windows_library_path_; public: - const LibArchitecture plugin_arch; + const LibArchitecture plugin_arch_; /** * The path to the plugin (`.dll` or module) we're going to in the Wine @@ -132,20 +132,20 @@ struct PluginInfo { * * https://developer.steinberg.help/pages/viewpage.action?pageId=9798275 */ - const boost::filesystem::path windows_plugin_path; + const boost::filesystem::path windows_plugin_path_; /** - * The Wine prefix to use for hosting `windows_plugin_path`. If the + * The Wine prefix to use for hosting `windows_plugin_path_`. If the * `WINEPREFIX` environment variable is set, then that will be used as an * override. Otherwise, we'll try to find the Wine prefix - * `windows_plugin_path` is located in. The detection works by looking for a - * directory containing a directory called `dosdevices`. If the plugin is + * `windows_plugin_path_` is located in. The detection works by looking for + * a directory containing a directory called `dosdevices`. If the plugin is * not inside of a Wine prefix, this will be left empty, and the default * prefix will be used instead. */ const std:: variant - wine_prefix; + wine_prefix_; }; /** diff --git a/src/plugin/vst2-plugin.cpp b/src/plugin/vst2-plugin.cpp index a45147b6..9c314429 100644 --- a/src/plugin/vst2-plugin.cpp +++ b/src/plugin/vst2-plugin.cpp @@ -48,7 +48,7 @@ extern "C" VST_EXPORT AEffect* VSTPluginMain( // received. Vst2PluginBridge* bridge = new Vst2PluginBridge(host_callback); - return &bridge->plugin; + return &bridge->plugin_; } catch (const std::exception& error) { Logger logger = Logger::create_exception_logger(); diff --git a/src/wine-host/bridges/common.cpp b/src/wine-host/bridges/common.cpp index d0261e26..a9a57e15 100644 --- a/src/wine-host/bridges/common.cpp +++ b/src/wine-host/bridges/common.cpp @@ -50,11 +50,11 @@ constexpr unsigned int juce_message_id = WM_USER + 123; HostBridge::HostBridge(MainContext& main_context, boost::filesystem::path plugin_path, pid_t parent_pid) - : plugin_path(plugin_path), - main_context(main_context), - generic_logger(Logger::create_wine_stderr()), - parent_pid(parent_pid), - watchdog_guard(main_context.register_watchdog(*this)) {} + : plugin_path_(plugin_path), + main_context_(main_context), + generic_logger_(Logger::create_wine_stderr()), + parent_pid_(parent_pid), + watchdog_guard_(main_context.register_watchdog(*this)) {} HostBridge::~HostBridge() noexcept {} @@ -81,7 +81,7 @@ void HostBridge::shutdown_if_dangling() { // `recv()`), then we'll close the sockets here so that the plugin bridge // exits gracefully. This will be periodically called from `MainContext`'s // watchdog thread. - if (!pid_running(parent_pid)) { + if (!pid_running(parent_pid_)) { std::cerr << "WARNING: The native plugin host seems to have died." << std::endl; std::cerr << " This bridge will shut down now." << std::endl; diff --git a/src/wine-host/bridges/common.h b/src/wine-host/bridges/common.h index 5667ab92..d6b7b89b 100644 --- a/src/wine-host/bridges/common.h +++ b/src/wine-host/bridges/common.h @@ -74,7 +74,7 @@ class HostBridge { * function doesn't have any per-plugin behavior, only a single invocation * of this is needed when hosting multiple plugins. This is run on a timer * in the same IO context as the one that handles the events, i.e. - * `main_context`. + * `main_context_`. * * Because of the way the Win32 API works we have to process events on the * same thread as the one the window was created on, and that thread is the @@ -98,7 +98,7 @@ class HostBridge { /** * The path to the .dll being loaded in the Wine plugin host. */ - const boost::filesystem::path plugin_path; + const boost::filesystem::path plugin_path_; protected: /** @@ -114,7 +114,7 @@ class HostBridge { * message handling can be performed from a single thread, even when hosting * multiple plugins. */ - MainContext& main_context; + MainContext& main_context_; /** * A logger, just like we have on the plugin side. This is normally not @@ -123,7 +123,7 @@ class HostBridge { * * @see Logger::create_wine_stderr */ - Logger generic_logger; + Logger generic_logger_; private: /** @@ -133,11 +133,11 @@ class HostBridge { * if this process is still alive, and close the sockets if it is not to * prevent dangling processes. */ - const pid_t parent_pid; + const pid_t parent_pid_; /** * A guard that, while in scope, will cause `shutdown_if_dangling()` to * periodically be called. */ - MainContext::WatchdogGuard watchdog_guard; + MainContext::WatchdogGuard watchdog_guard_; }; diff --git a/src/wine-host/bridges/group.cpp b/src/wine-host/bridges/group.cpp index b319a23e..25a9d519 100644 --- a/src/wine-host/bridges/group.cpp +++ b/src/wine-host/bridges/group.cpp @@ -61,52 +61,53 @@ std::string create_logger_prefix(const fs::path& socket_path); StdIoCapture::StdIoCapture(boost::asio::io_context& io_context, int file_descriptor) - : pipe(io_context), - target_fd(file_descriptor), - original_fd_copy(dup(file_descriptor)) { + : pipe_(io_context), + target_fd_(file_descriptor), + original_fd_copy_(dup(file_descriptor)) { // We'll use the second element of these two file descriptors to reopen // `file_descriptor`, and the first one to read the captured contents from - if (::pipe(pipe_fd) != 0) { + if (::pipe(pipe_fd_) != 0) { throw std::system_error(errno, std::system_category()); } // We've already created a copy of the original file descriptor, so we can // reopen it using the newly created pipe - dup2(pipe_fd[1], target_fd); - close(pipe_fd[1]); + dup2(pipe_fd_[1], target_fd_); + close(pipe_fd_[1]); - pipe.assign(pipe_fd[0]); + pipe_.assign(pipe_fd_[0]); } StdIoCapture::~StdIoCapture() noexcept { // Restore the original file descriptor and close the pipe. The other wend // was already closed in the constructor. - dup2(original_fd_copy, target_fd); - close(original_fd_copy); - close(pipe_fd[0]); + dup2(original_fd_copy_, target_fd_); + close(original_fd_copy_); + close(pipe_fd_[0]); } GroupBridge::GroupBridge(boost::filesystem::path group_socket_path) - : logger(Logger::create_from_environment( + : logger_(Logger::create_from_environment( create_logger_prefix(group_socket_path))), - 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(main_context.context, - group_socket_endpoint)), - shutdown_timer(main_context.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(main_context_.context_, + group_socket_endpoint_)), + shutdown_timer_(main_context_.context_) { // Write this process's original STDOUT and STDERR streams to the logger - logger.async_log_pipe_lines(stdout_redirect.pipe, stdout_buffer, - "[STDOUT] "); - logger.async_log_pipe_lines(stderr_redirect.pipe, stderr_buffer, - "[STDERR] "); + logger_.async_log_pipe_lines(stdout_redirect_.pipe_, stdout_buffer_, + "[STDOUT] "); + logger_.async_log_pipe_lines(stderr_redirect_.pipe_, stderr_buffer_, + "[STDERR] "); - stdio_handler = Win32Thread([&]() { + stdio_handler_ = Win32Thread([&]() { pthread_setname_np(pthread_self(), "group-stdio"); - stdio_context.run(); + stdio_context_.run(); }); } @@ -114,15 +115,15 @@ GroupBridge::~GroupBridge() noexcept { // Our fancy `Vst2Sockets` and `Vst3Sockets` clean up after themselves, but // here we need to do it manually // TODO: Encapsulate this, destructors are evil - fs::remove(group_socket_endpoint.path()); + fs::remove(group_socket_endpoint_.path()); - stdio_context.stop(); + stdio_context_.stop(); } bool GroupBridge::is_event_loop_inhibited() noexcept { - std::lock_guard lock(active_plugins_mutex); + std::lock_guard lock(active_plugins_mutex_); - for (auto& [parameters, value] : active_plugins) { + for (auto& [parameters, value] : active_plugins_) { auto& [thread, bridge] = value; if (bridge->inhibits_event_loop()) { return true; @@ -135,7 +136,7 @@ bool GroupBridge::is_event_loop_inhibited() noexcept { void GroupBridge::handle_plugin_run(size_t plugin_id, HostBridge* bridge) { // Blocks this thread until the plugin shuts down bridge->run(); - logger.log("'" + bridge->plugin_path.string() + "' has exited"); + logger_.log("'" + bridge->plugin_path_.string() + "' has exited"); // After the plugin has exited we'll remove this thread's plugin from the // active plugins. This is done within the IO context because the call to @@ -143,12 +144,12 @@ void GroupBridge::handle_plugin_run(size_t plugin_id, HostBridge* bridge) { // 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. - main_context.schedule_task([this, plugin_id]() { - std::lock_guard lock(active_plugins_mutex); + main_context_.schedule_task([this, plugin_id]() { + std::lock_guard lock(active_plugins_mutex_); // The join is implicit because we're using Win32Thread (which mimics // std::jthread) - active_plugins.erase(plugin_id); + active_plugins_.erase(plugin_id); }); // Defer actually shutting down the process to allow for fast plugin @@ -164,23 +165,23 @@ void GroupBridge::handle_incoming_connections() { // shut the process down again. maybe_schedule_shutdown(5s); - logger.log( + logger_.log( "Group host is up and running, now accepting incoming connections"); - main_context.run(); + main_context_.run(); } void GroupBridge::accept_requests() { - group_socket_acceptor.async_accept( + group_socket_acceptor_.async_accept( [&](const boost::system::error_code& error, boost::asio::local::stream_protocol::socket socket) { - std::lock_guard lock(active_plugins_mutex); + std::lock_guard lock(active_plugins_mutex_); // Stop the whole process when the socket gets closed unexpectedly if (error.failed()) { - logger.log("Error while listening for incoming connections:"); - logger.log(error.message()); + logger_.log("Error while listening for incoming connections:"); + logger_.log(error.message()); - main_context.stop(); + main_context_.stop(); } // Read the parameters, and then host the plugin in this process @@ -195,27 +196,27 @@ void GroupBridge::accept_requests() { // The plugin has to be initiated on the IO context's thread because // this has to be done on the same thread that's handling messages, // and all window messages have to be handled from the same thread. - logger.log("Received request to host " + - plugin_type_to_string(request.plugin_type) + - " plugin at '" + request.plugin_path + - "' using socket endpoint base directory '" + - request.endpoint_base_dir + "'"); + logger_.log("Received request to host " + + plugin_type_to_string(request.plugin_type) + + " plugin at '" + request.plugin_path + + "' using socket endpoint base directory '" + + request.endpoint_base_dir + "'"); try { // Cancel the (initial) shutdown timer, since the plugin may // take longer to initialize if it is new - shutdown_timer.cancel(); + shutdown_timer_.cancel(); std::unique_ptr bridge = nullptr; switch (request.plugin_type) { case PluginType::vst2: bridge = std::make_unique( - main_context, request.plugin_path, + main_context_, request.plugin_path, request.endpoint_base_dir, request.parent_pid); break; case PluginType::vst3: #ifdef WITH_VST3 bridge = std::make_unique( - main_context, request.plugin_path, + main_context_, request.plugin_path, request.endpoint_base_dir, request.parent_pid); #else throw std::runtime_error( @@ -230,8 +231,8 @@ void GroupBridge::accept_requests() { break; } - logger.log("Finished initializing '" + request.plugin_path + - "'"); + logger_.log("Finished initializing '" + request.plugin_path + + "'"); // Start listening for dispatcher events sent to the plugin's // socket on another thread. Parts of the actual event handling @@ -244,8 +245,8 @@ void GroupBridge::accept_requests() { // when using the Spitfire plugins, as they will block the // message loop until `effOpen()` has been called and thus // prevent this lock from happening. - const size_t plugin_id = next_plugin_id.fetch_add(1); - active_plugins[plugin_id] = std::pair( + const size_t plugin_id = next_plugin_id_.fetch_add(1); + active_plugins_[plugin_id] = std::pair( Win32Thread([this, plugin_id, plugin_ptr = bridge.get()]() { const std::string thread_name = "worker-" + std::to_string(plugin_id); @@ -255,9 +256,9 @@ void GroupBridge::accept_requests() { }), std::move(bridge)); } catch (const std::exception& error) { - logger.log("Error while initializing '" + request.plugin_path + - "':"); - logger.log(error.what()); + logger_.log("Error while initializing '" + request.plugin_path + + "':"); + logger_.log(error.what()); maybe_schedule_shutdown(5s); } @@ -267,9 +268,9 @@ void GroupBridge::accept_requests() { } void GroupBridge::async_handle_events() { - main_context.async_handle_events( + main_context_.async_handle_events( [&]() { - std::lock_guard lock(active_plugins_mutex); + std::lock_guard lock(active_plugins_mutex_); // Keep the loop responsive by not handling too many events at once. // All X11 events are handled from a Win32 timer so they'll still be @@ -319,23 +320,23 @@ boost::asio::local::stream_protocol::acceptor create_acceptor_if_inactive( void GroupBridge::maybe_schedule_shutdown( std::chrono::steady_clock::duration delay) { - std::lock_guard lock(shutdown_timer_mutex); + std::lock_guard lock(shutdown_timer_mutex_); - shutdown_timer.expires_after(delay); - shutdown_timer.async_wait([this](const boost::system::error_code& error) { + shutdown_timer_.expires_after(delay); + shutdown_timer_.async_wait([this](const boost::system::error_code& error) { // A previous timer gets canceled automatically when another plugin // exits if (error.failed()) { return; } - std::lock_guard lock(active_plugins_mutex); - if (active_plugins.size() == 0) { - logger.log( + std::lock_guard lock(active_plugins_mutex_); + if (active_plugins_.size() == 0) { + logger_.log( "All plugins have exited, shutting down the group process"); // The whole process will exit in `group-host.cpp` because of this - main_context.stop(); + main_context_.stop(); } }); } diff --git a/src/wine-host/bridges/group.h b/src/wine-host/bridges/group.h index f6b8fb44..a3fb5bb7 100644 --- a/src/wine-host/bridges/group.h +++ b/src/wine-host/bridges/group.h @@ -67,26 +67,26 @@ class StdIoCapture { * The pipe endpoint where all output from the original file descriptor gets * redirected to. This can be read from like any other `Boost.Asio` stream. */ - boost::asio::posix::stream_descriptor pipe; + boost::asio::posix::stream_descriptor pipe_; private: /** * The file descriptor of the stream we're capturing. */ - const int target_fd; + const int target_fd_; /** * A copy of the original file descriptor. Will be used to undo * the capture when this object gets destroyed. */ - const int original_fd_copy; + const int original_fd_copy_; /** * The two file descriptors generated by the `pipe()` function call. * `pipe_fd[1]` is used to reopen/capture the passed file descriptor, and * `pipe_fd[0]` can be used to read the captured output from. */ - int pipe_fd[2]; + int pipe_fd_[2]; }; /** @@ -148,12 +148,12 @@ class GroupBridge { * thread. * * Once the plugin has exited, this thread will then be joined to the main - * thread and removed from the `active_plugins` from the main IO context. If - * this causes the vector to become empty, we will terminate this process. - * This check is delayed by a few seconds to prevent having to constantly - * restart the group process during plugin scanning. + * thread and removed from the `active_plugins_` from the main IO context. + * If this causes the vector to become empty, we will terminate this + * process. This check is delayed by a few seconds to prevent having to + * constantly restart the group process during plugin scanning. * - * @param plugin_id The ID of this plugin in the `active_plugins` map. Used + * @param plugin_id The ID of this plugin in the `active_plugins_` map. Used * to unload the plugin and join this thread again after the plugin exits. * * @note In the case that the process starts but no plugin gets initiated, @@ -181,7 +181,7 @@ class GroupBridge { * 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 - * `main_context`. + * `main_context_`. * * @see handle_plugin_run */ @@ -205,14 +205,14 @@ class GroupBridge { * identify which plugin is generating (debug) output, every line will only * be prefixed with the name of the group. */ - Logger logger; + Logger logger_; /** * The IO context that connections will be accepted on, and that any plugin * operations that may involve the Win32 mesasge loop (e.g. initialization * and most `AEffect::dispatcher()` calls) should be run on. */ - MainContext main_context; + MainContext main_context_; /** * A seperate IO context that handles the STDIO redirect through * `StdIoCapture`. This is separated from the `main_context` above so that @@ -220,33 +220,33 @@ class GroupBridge { * 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; + boost::asio::io_context stdio_context_; - boost::asio::streambuf stdout_buffer; - boost::asio::streambuf stderr_buffer; + boost::asio::streambuf stdout_buffer_; + boost::asio::streambuf stderr_buffer_; /** * Contains a pipe used for capturing this process's STDOUT stream. Needed * to be able to process the output generated by Wine and plugins and to be * able write it write it to an external log file. */ - StdIoCapture stdout_redirect; + StdIoCapture stdout_redirect_; /** * Contains a pipe used for capturing this process's STDERR stream. Needed * to be able to process the output generated by Wine and plugins and to be * able write it write it to an external log file. */ - StdIoCapture stderr_redirect; + StdIoCapture stderr_redirect_; /** - * A thread that runs the `stdio_context` loop. + * A thread that runs the `stdio_context_` loop. */ - Win32Thread stdio_handler; + Win32Thread stdio_handler_; - boost::asio::local::stream_protocol::endpoint group_socket_endpoint; + boost::asio::local::stream_protocol::endpoint group_socket_endpoint_; /** * The UNIX domain socket acceptor that will be used to listen for incoming * connections to spawn new plugins within this process. */ - boost::asio::local::stream_protocol::acceptor group_socket_acceptor; + boost::asio::local::stream_protocol::acceptor group_socket_acceptor_; /** * A map of threads that are currently hosting a plugin within this process @@ -255,24 +255,24 @@ class GroupBridge { * this map. This is to keep track of the amount of plugins currently * running with their associated thread handles. The key that identifies the * thread and plugin is a unique plugin ID obtained by doing a fetch-and-add - * on `next_plugin_id`. + * on `next_plugin_id_`. */ std::unordered_map>> - active_plugins; + active_plugins_; /** * A counter for the next unique plugin ID. When hosting a new plugin we'll * do a fetch-and-add to ensure that every thread gets its own unique * identifier. */ - std::atomic_size_t next_plugin_id; + std::atomic_size_t next_plugin_id_; /** * A mutex to prevent two threads from simultaneously accessing the plugins * map, and also to prevent `handle_plugin_run()` from terminating the * process because it thinks there are no active plugins left just as a new * plugin is being spawned. */ - std::mutex active_plugins_mutex; + std::mutex active_plugins_mutex_; /** * A timer to defer shutting down the process, allowing for fast plugin @@ -281,10 +281,10 @@ class GroupBridge { * * @see handle_plugin_run */ - boost::asio::steady_timer shutdown_timer; + boost::asio::steady_timer shutdown_timer_; /** * A mutex to prevent two threads from simultaneously modifying the shutdown * timer when multiple plugins exit at the same time. */ - std::mutex shutdown_timer_mutex; + std::mutex shutdown_timer_mutex_; }; diff --git a/src/wine-host/bridges/vst2.cpp b/src/wine-host/bridges/vst2.cpp index e096336c..36fc2745 100644 --- a/src/wine-host/bridges/vst2.cpp +++ b/src/wine-host/bridges/vst2.cpp @@ -144,10 +144,10 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context, std::string endpoint_base_dir, pid_t parent_pid) : HostBridge(main_context, plugin_dll_path, parent_pid), - logger(generic_logger), - plugin_handle(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary), - sockets(main_context.context, endpoint_base_dir, false) { - if (!plugin_handle) { + logger_(generic_logger_), + plugin_handle_(LoadLibrary(plugin_dll_path.c_str()), FreeLibrary), + sockets_(main_context.context_, endpoint_base_dir, false) { + if (!plugin_handle_) { throw std::runtime_error("Could not load the Windows .dll file at '" + plugin_dll_path + "'"); } @@ -158,7 +158,7 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context, for (auto name : {"VSTPluginMain", "main"}) { vst_entry_point = reinterpret_cast(reinterpret_cast( - GetProcAddress(plugin_handle.get(), name))); + GetProcAddress(plugin_handle_.get(), name))); if (vst_entry_point) { break; @@ -170,7 +170,7 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context, "'."); } - sockets.connect(); + sockets_.connect(); // We'll try to do the same `get_bridge_instance()` trick as in //`plugin/bridges/vst2.cpp`, but since the plugin will probably call the @@ -183,11 +183,11 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context, // plugin are running using realtime scheduling, since Wine doesn't fully // implement the Win32 process priority API yet. set_realtime_priority(true); - plugin = vst_entry_point( + plugin_ = vst_entry_point( reinterpret_cast(host_callback_proxy)); set_realtime_priority(false); - if (!plugin) { + if (!plugin_) { throw std::runtime_error("VST plugin at '" + plugin_dll_path + "' failed to initialize."); } @@ -196,31 +196,31 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context, // initialized. Otherwise we can run into thread safety issues when a plugin // is processing audio while another plugin is being initialized. current_bridge_instance = nullptr; - plugin->ptr1 = this; - plugin->ptr2 = reinterpret_cast(yabridge_ptr2_magic); + plugin_->ptr1 = this; + plugin_->ptr2 = reinterpret_cast(yabridge_ptr2_magic); // Send the plugin's information to the Linux VST plugin. Any other updates // of this object will be sent over the `dispatcher()` socket. This would be // done after the host calls `effOpen()`, and when the plugin calls // `audioMasterIOChanged()`. We will also send along this host's version so // we can show a warning when the plugin's version doesn't match. - sockets.host_vst_control.send( + sockets_.host_vst_control_.send( Vst2EventResult{.return_value = 0, - .payload = *plugin, + .payload = *plugin_, .value_payload = yabridge_git_version}); // After sending the AEffect struct we'll receive this instance's // configuration as a response - config = sockets.host_vst_control.receive_single(); + config_ = sockets_.host_vst_control_.receive_single(); // Allow this plugin to configure the main context's tick rate - main_context.update_timer_interval(config.event_loop_interval()); + main_context.update_timer_interval(config_.event_loop_interval()); - parameters_handler = Win32Thread([&]() { + parameters_handler_ = Win32Thread([&]() { set_realtime_priority(true); pthread_setname_np(pthread_self(), "parameters"); - sockets.host_vst_parameters.receive_multi( + sockets_.host_vst_parameters_.receive_multi( [&](Parameter& request, SerializationBufferBase& buffer) { // Both `getParameter` and `setParameter` functions are passed // through on this socket since they have a lot of overlap. The @@ -228,21 +228,22 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context, // dealing with. if (request.value) { // `setParameter` - plugin->setParameter(plugin, request.index, *request.value); + plugin_->setParameter(plugin_, request.index, + *request.value); ParameterResult response{std::nullopt}; - sockets.host_vst_parameters.send(response, buffer); + sockets_.host_vst_parameters_.send(response, buffer); } else { // `getParameter` - float value = plugin->getParameter(plugin, request.index); + float value = plugin_->getParameter(plugin_, request.index); ParameterResult response{value}; - sockets.host_vst_parameters.send(response, buffer); + sockets_.host_vst_parameters_.send(response, buffer); } }); }); - process_replacing_handler = Win32Thread([&]() { + process_replacing_handler_ = Win32Thread([&]() { set_realtime_priority(true); pthread_setname_np(pthread_self(), "audio"); @@ -251,132 +252,129 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context, // they start producing denormals ScopedFlushToZero ftz_guard; - sockets.host_vst_process_replacing.receive_multi( - [&](Vst2ProcessRequest& process_request, - SerializationBufferBase& buffer) { - // Since the value cannot change during this processing cycle, - // we'll send the current transport information as part of the - // request so we prefetch it to avoid unnecessary callbacks from - // the audio thread - std::optional - time_info_cache_guard = - process_request.current_time_info - ? std::optional(time_info_cache.set( - *process_request.current_time_info)) - : std::nullopt; + sockets_.host_vst_process_replacing_.receive_multi< + Vst2ProcessRequest>([&](Vst2ProcessRequest& process_request, + SerializationBufferBase& buffer) { + // Since the value cannot change during this processing cycle, + // we'll send the current transport information as part of the + // request so we prefetch it to avoid unnecessary callbacks from + // the audio thread + std::optional + time_info_cache_guard = + process_request.current_time_info + ? std::optional(time_info_cache_.set( + *process_request.current_time_info)) + : std::nullopt; - // We'll also prefetch the process level, since some plugins - // will ask for this during every processing cycle - decltype(process_level_cache)::Guard process_level_cache_guard = - process_level_cache.set( - process_request.current_process_level); + // We'll also prefetch the process level, since some plugins + // will ask for this during every processing cycle + decltype(process_level_cache_)::Guard process_level_cache_guard = + process_level_cache_.set(process_request.current_process_level); - // As suggested by Jack Winter, we'll synchronize this thread's - // audio processing priority with that of the host's audio - // thread every once in a while - if (process_request.new_realtime_priority) { - set_realtime_priority( - true, *process_request.new_realtime_priority); - } + // As suggested by Jack Winter, we'll synchronize this thread's + // audio processing priority with that of the host's audio + // thread every once in a while + if (process_request.new_realtime_priority) { + set_realtime_priority(true, + *process_request.new_realtime_priority); + } - // Let the plugin process the MIDI events that were received - // since the last buffer, and then clean up those events. This - // approach should not be needed but Kontakt only stores - // pointers to rather than copies of the events. - std::lock_guard lock(next_buffer_midi_events_mutex); + // Let the plugin process the MIDI events that were received + // since the last buffer, and then clean up those events. This + // approach should not be needed but Kontakt only stores + // pointers to rather than copies of the events. + std::lock_guard lock(next_buffer_midi_events_mutex_); - // As an optimization we no don't pass the input audio along - // with `Vst2ProcessRequest`, and instead we'll write it to a - // shared memory object on the plugin side. We can then write - // the output audio to the same shared memory object. Since the - // host should only be calling one of `process()`, - // processReplacing()` or `processDoubleReplacing()`, we can all - // handle them all at once. We pick which one to call depending - // on the type of data we got sent and the plugin's reported - // support for these functions. - auto do_process = [&](T) { - // These were set up after the host called - // `effMainsChanged()` with the correct size, so this - // reinterpret cast is safe even if the host suddenly starts - // sending 32-bit single precision audio after it set up - // audio processing for double precision (not that the - // Windows VST2 plugin would be able to handle that, - // presumably) - T** input_channel_pointers = reinterpret_cast( - process_buffers_input_pointers.data()); - T** output_channel_pointers = reinterpret_cast( - process_buffers_output_pointers.data()); + // As an optimization we no don't pass the input audio along + // with `Vst2ProcessRequest`, and instead we'll write it to a + // shared memory object on the plugin side. We can then write + // the output audio to the same shared memory object. Since the + // host should only be calling one of `process()`, + // processReplacing()` or `processDoubleReplacing()`, we can all + // handle them all at once. We pick which one to call depending + // on the type of data we got sent and the plugin's reported + // support for these functions. + auto do_process = [&](T) { + // These were set up after the host called + // `effMainsChanged()` with the correct size, so this + // reinterpret cast is safe even if the host suddenly starts + // sending 32-bit single precision audio after it set up + // audio processing for double precision (not that the + // Windows VST2 plugin would be able to handle that, + // presumably) + T** input_channel_pointers = reinterpret_cast( + process_buffers_input_pointers_.data()); + T** output_channel_pointers = reinterpret_cast( + process_buffers_output_pointers_.data()); - if constexpr (std::is_same_v) { - // Any plugin made in the last fifteen years or so - // should support `processReplacing`. In the off chance - // it does not we can just emulate this behavior - // ourselves. - if (plugin->processReplacing) { - plugin->processReplacing( - plugin, input_channel_pointers, - output_channel_pointers, - process_request.sample_frames); - } else { - // If we zero out this buffer then the behavior is - // the same as `processReplacing` - for (int channel = 0; channel < plugin->numOutputs; - channel++) { - std::fill(output_channel_pointers[channel], - output_channel_pointers[channel] + - process_request.sample_frames, - static_cast(0.0)); - } - - plugin->process(plugin, input_channel_pointers, - output_channel_pointers, - process_request.sample_frames); - } - } else if (std::is_same_v) { - plugin->processDoubleReplacing( - plugin, input_channel_pointers, + if constexpr (std::is_same_v) { + // Any plugin made in the last fifteen years or so + // should support `processReplacing`. In the off chance + // it does not we can just emulate this behavior + // ourselves. + if (plugin_->processReplacing) { + plugin_->processReplacing( + plugin_, input_channel_pointers, output_channel_pointers, process_request.sample_frames); } else { - static_assert( - std::is_same_v || - std::is_same_v, - "Audio processing only works with single and " - "double precision floating point numbers"); + // If we zero out this buffer then the behavior is + // the same as `processReplacing` + for (int channel = 0; channel < plugin_->numOutputs; + channel++) { + std::fill(output_channel_pointers[channel], + output_channel_pointers[channel] + + process_request.sample_frames, + static_cast(0.0)); + } + + plugin_->process(plugin_, input_channel_pointers, + output_channel_pointers, + process_request.sample_frames); } - }; - - assert(process_buffers); - if (process_request.double_precision) { - // XXX: Clangd doesn't let you specify template parameters - // for templated lambdas. This argument should get - // optimized out - do_process(double()); + } else if (std::is_same_v) { + plugin_->processDoubleReplacing( + plugin_, input_channel_pointers, + output_channel_pointers, process_request.sample_frames); } else { - do_process(float()); + static_assert( + std::is_same_v || std::is_same_v, + "Audio processing only works with single and " + "double precision floating point numbers"); } + }; - // We modified the buffers within the `process_response` object, - // so we can just send that object back. Like on the plugin side - // we cannot reuse the request object because a plugin may have - // a different number of input and output channels - sockets.host_vst_process_replacing.send(Ack{}, buffer); + assert(process_buffers_); + if (process_request.double_precision) { + // XXX: Clangd doesn't let you specify template parameters + // for templated lambdas. This argument should get + // optimized out + do_process(double()); + } else { + do_process(float()); + } - // See the docstrong on `should_clear_midi_events` for why we - // don't just clear `next_buffer_midi_events` here - should_clear_midi_events = true; - }); + // We modified the buffers within the `process_response` object, + // so we can just send that object back. Like on the plugin side + // we cannot reuse the request object because a plugin may have + // a different number of input and output channels + sockets_.host_vst_process_replacing_.send(Ack{}, buffer); + + // See the docstrong on `should_clear_midi_events` for why we + // don't just clear `next_buffer_midi_events` here + should_clear_midi_events_ = true; + }); }); } bool Vst2Bridge::inhibits_event_loop() noexcept { - return !is_initialized; + return !is_initialized_; } void Vst2Bridge::run() { set_realtime_priority(true); - sockets.host_vst_dispatch.receive_events( + sockets_.host_vst_dispatch_.receive_events( std::nullopt, [&](Vst2Event& event, bool /*on_main_thread*/) -> Vst2EventResult { if (event.opcode == effProcessEvents) { @@ -390,24 +388,25 @@ void Vst2Bridge::run() { // we need to store a copy of the `DynamicVstEvents` struct // before passing the generated `VstEvents` object to the // plugin. - std::lock_guard lock(next_buffer_midi_events_mutex); + std::lock_guard lock(next_buffer_midi_events_mutex_); // See the docstring on `should_clear_midi_events` for why we // only deallocate old MIDI events here instead of a at the end // of every processing cycle - if (should_clear_midi_events) { - next_audio_buffer_midi_events.clear(); - should_clear_midi_events = false; + if (should_clear_midi_events_) { + next_audio_buffer_midi_events_.clear(); + should_clear_midi_events_ = false; } - next_audio_buffer_midi_events.push_back( + next_audio_buffer_midi_events_.push_back( std::get(event.payload)); - DynamicVstEvents& events = next_audio_buffer_midi_events.back(); + DynamicVstEvents& events = + next_audio_buffer_midi_events_.back(); // Exact same handling as in `passthrough_event()`, apart from // making a copy of the events first - const intptr_t return_value = plugin->dispatcher( - plugin, event.opcode, event.index, event.value, + const intptr_t return_value = plugin_->dispatcher( + plugin_, event.opcode, event.index, event.value, &events.as_c_events(), event.option); return Vst2EventResult{.return_value = return_value, @@ -416,7 +415,7 @@ void Vst2Bridge::run() { } Vst2EventResult result = passthrough_event( - plugin, + plugin_, [&](AEffect* plugin, int opcode, int index, intptr_t value, void* data, float option) -> intptr_t { // Certain functions will most definitely involve @@ -432,7 +431,7 @@ void Vst2Bridge::run() { const bool is_realtime_request = unsafe_requests_realtime.contains(opcode); - return main_context + return main_context_ .run_in_context([&]() -> intptr_t { if (is_realtime_request) { set_realtime_priority(true); @@ -449,7 +448,7 @@ void Vst2Bridge::run() { // this point to prevent plugins with partially // initialized states from misbehaving if (opcode == effOpen) { - is_initialized = true; + is_initialized_ = true; } return result; @@ -463,7 +462,7 @@ void Vst2Bridge::run() { // that callback if possible. This may be needed when // plugins use recursive mutexes, thus causing deadlocks // when the function is called from any other thread. - return mutual_recursion.handle([&]() { + return mutual_recursion_.handle([&]() { return dispatch_wrapper(plugin, opcode, index, value, data, option); }); @@ -498,7 +497,7 @@ void Vst2Bridge::run() { } void Vst2Bridge::close_sockets() { - sockets.close(); + sockets_.close(); } class HostCallbackDataConverter : public DefaultDataConverter { @@ -507,9 +506,9 @@ class HostCallbackDataConverter : public DefaultDataConverter { AEffect* plugin, VstTimeInfo& last_time_info, MutualRecursionHelper& mutual_recursion) noexcept - : plugin(plugin), - last_time_info(last_time_info), - mutual_recursion(mutual_recursion) {} + : plugin_(plugin), + last_time_info_(last_time_info), + mutual_recursion_(mutual_recursion) {} Vst2Event::Payload read_data(const int opcode, const int index, @@ -523,7 +522,7 @@ class HostCallbackDataConverter : public DefaultDataConverter { // This is a helpful event that indicates that the VST // plugin's `AEffect` struct has changed. Writing these // results back is done inside of `passthrough_event()`. - return AEffect(*plugin); + return AEffect(*plugin_); break; case audioMasterProcessEvents: return DynamicVstEvents(*static_cast(data)); @@ -590,7 +589,7 @@ class HostCallbackDataConverter : public DefaultDataConverter { // keep track of it so we can return a pointer to it in the // function below if (std::holds_alternative(response.payload)) { - last_time_info = std::get(response.payload); + last_time_info_ = std::get(response.payload); } break; default: @@ -608,7 +607,7 @@ class HostCallbackDataConverter : public DefaultDataConverter { if (original == 0) { return 0; } else { - return reinterpret_cast(&last_time_info); + return reinterpret_cast(&last_time_info_); } } break; default: @@ -628,7 +627,7 @@ class HostCallbackDataConverter : public DefaultDataConverter { const Vst2Event& event, SerializationBufferBase& buffer) const override { if (mutually_recursive_callbacks.contains(event.opcode)) { - return mutual_recursion.fork([&]() { + return mutual_recursion_.fork([&]() { return DefaultDataConverter::send_event(socket, event, buffer); }); } else { @@ -637,9 +636,9 @@ class HostCallbackDataConverter : public DefaultDataConverter { } private: - AEffect* plugin; - VstTimeInfo& last_time_info; - MutualRecursionHelper& mutual_recursion; + AEffect* plugin_; + VstTimeInfo& last_time_info_; + MutualRecursionHelper& mutual_recursion_; }; intptr_t Vst2Bridge::host_callback(AEffect* effect, @@ -653,31 +652,32 @@ intptr_t Vst2Bridge::host_callback(AEffect* effect, // transport information from the plugin side to avoid an unnecessary // callback case audioMasterGetTime: { - const VstTimeInfo* cached_time_info = time_info_cache.get(); + const VstTimeInfo* cached_time_info = time_info_cache_.get(); if (cached_time_info) { // This cached value is temporary, so we'll still use the // regular time info storing mechanism - last_time_info = *cached_time_info; + last_time_info_ = *cached_time_info; const intptr_t result = - reinterpret_cast(&last_time_info); + reinterpret_cast(&last_time_info_); // Make sure that these cached events don't get lost in the logs - logger.log_event(false, opcode, index, value, - WantsVstTimeInfo{}, option, std::nullopt); - logger.log_event_response(false, opcode, result, last_time_info, - std::nullopt, true); + logger_.log_event(false, opcode, index, value, + WantsVstTimeInfo{}, option, std::nullopt); + logger_.log_event_response(false, opcode, result, + last_time_info_, std::nullopt, true); return result; } } break; // We also send the current process level for similar reasons case audioMasterGetCurrentProcessLevel: { - const int* current_process_level = process_level_cache.get(); + const int* current_process_level = process_level_cache_.get(); if (current_process_level) { - logger.log_event(false, opcode, index, value, nullptr, option, - std::nullopt); - logger.log_event_response(false, opcode, *current_process_level, - nullptr, std::nullopt, true); + logger_.log_event(false, opcode, index, value, nullptr, option, + std::nullopt); + logger_.log_event_response(false, opcode, + *current_process_level, nullptr, + std::nullopt, true); return *current_process_level; } @@ -685,16 +685,16 @@ intptr_t Vst2Bridge::host_callback(AEffect* effect, // If the plugin changes its window size, we'll also resize the wrapper // window accordingly. case audioMasterSizeWindow: { - if (editor) { - editor->resize(index, value); + if (editor_) { + editor_->resize(index, value); } } break; } - HostCallbackDataConverter converter(effect, last_time_info, - mutual_recursion); - return sockets.vst_host_callback.send_event(converter, std::nullopt, opcode, - index, value, data, option); + HostCallbackDataConverter converter(effect, last_time_info_, + mutual_recursion_); + return sockets_.vst_host_callback_.send_event( + converter, std::nullopt, opcode, index, value, data, option); } intptr_t Vst2Bridge::dispatch_wrapper(AEffect* plugin, @@ -713,7 +713,7 @@ intptr_t Vst2Bridge::dispatch_wrapper(AEffect* plugin, case effSetBlockSize: { // Used to initialize the shared audio buffers when handling // `effMainsChanged` in `Vst2Bridge::run()` - max_samples_per_block = value; + max_samples_per_block_ = value; return plugin->dispatcher(plugin, opcode, index, value, data, option); @@ -724,9 +724,9 @@ intptr_t Vst2Bridge::dispatch_wrapper(AEffect* plugin, // the Wine window const auto x11_handle = reinterpret_cast(data); - Editor& editor_instance = editor.emplace( - main_context, config, generic_logger, x11_handle, - [plugin = this->plugin]() { + Editor& editor_instance = editor_.emplace( + main_context_, config_, generic_logger_, x11_handle, + [plugin = plugin_]() { plugin->dispatcher(plugin, effEditIdle, 0, 0, nullptr, 0.0); }); @@ -735,8 +735,8 @@ intptr_t Vst2Bridge::dispatch_wrapper(AEffect* plugin, VstRect* editor_rect = nullptr; plugin->dispatcher(plugin, effEditGetRect, 0, 0, &editor_rect, 0.0); if (editor_rect) { - editor->resize(editor_rect->right - editor_rect->left, - editor_rect->bottom - editor_rect->top); + editor_->resize(editor_rect->right - editor_rect->left, + editor_rect->bottom - editor_rect->top); } const intptr_t result = @@ -749,14 +749,14 @@ intptr_t Vst2Bridge::dispatch_wrapper(AEffect* plugin, // Cleanup is handled through RAII const intptr_t return_value = plugin->dispatcher(plugin, opcode, index, value, data, option); - editor.reset(); + editor_.reset(); return return_value; } break; case effSetProcessPrecision: { // Used to initialize the shared audio buffers when handling // `effMainsChanged` in `Vst2Bridge::run()` - double_precision = value == kVstProcessPrecision64; + double_precision_ = value == kVstProcessPrecision64; return plugin->dispatcher(plugin, opcode, index, value, data, option); @@ -776,61 +776,61 @@ AudioShmBuffer::Config Vst2Bridge::setup_shared_audio_buffers() { // audio channel are in samples (since they'll be used with pointer // arithmetic in `AudioShmBuffer`), and we'll only use the first bus (since // VST2 plugins don't have multiple audio busses). - assert(max_samples_per_block); + assert(max_samples_per_block_); uint32_t current_offset = 0; - std::vector input_channel_offsets(plugin->numInputs); - for (int channel = 0; channel < plugin->numInputs; channel++) { + std::vector input_channel_offsets(plugin_->numInputs); + for (int channel = 0; channel < plugin_->numInputs; channel++) { input_channel_offsets[channel] = current_offset; - current_offset += *max_samples_per_block; + current_offset += *max_samples_per_block_; } - std::vector output_channel_offsets(plugin->numOutputs); - for (int channel = 0; channel < plugin->numOutputs; channel++) { + std::vector output_channel_offsets(plugin_->numOutputs); + for (int channel = 0; channel < plugin_->numOutputs; channel++) { output_channel_offsets[channel] = current_offset; - current_offset += *max_samples_per_block; + current_offset += *max_samples_per_block_; } // The size of the buffer is in bytes, and it will depend on whether the // host is going to pass 32-bit or 64-bit audio to the plugin const uint32_t buffer_size = - current_offset * (double_precision ? sizeof(double) : sizeof(float)); + current_offset * (double_precision_ ? sizeof(double) : sizeof(float)); // We'll set up these shared memory buffers on the Wine side first, and then // when this request returns we'll do the same thing on the native plugin // side AudioShmBuffer::Config buffer_config{ - .name = sockets.base_dir.filename().string(), + .name = sockets_.base_dir_.filename().string(), .size = buffer_size, .input_offsets = {std::move(input_channel_offsets)}, .output_offsets = {std::move(output_channel_offsets)}}; - if (!process_buffers) { - process_buffers.emplace(buffer_config); + if (!process_buffers_) { + process_buffers_.emplace(buffer_config); } else { - process_buffers->resize(buffer_config); + process_buffers_->resize(buffer_config); } // The process functions expect a `T**` for their inputs and outputs, so // we'll also set those up right now - process_buffers_input_pointers.resize(plugin->numInputs); - for (int channel = 0; channel < plugin->numInputs; channel++) { - if (double_precision) { - process_buffers_input_pointers[channel] = - process_buffers->input_channel_ptr(0, channel); + process_buffers_input_pointers_.resize(plugin_->numInputs); + for (int channel = 0; channel < plugin_->numInputs; channel++) { + if (double_precision_) { + process_buffers_input_pointers_[channel] = + process_buffers_->input_channel_ptr(0, channel); } else { - process_buffers_input_pointers[channel] = - process_buffers->input_channel_ptr(0, channel); + process_buffers_input_pointers_[channel] = + process_buffers_->input_channel_ptr(0, channel); } } - process_buffers_output_pointers.resize(plugin->numOutputs); - for (int channel = 0; channel < plugin->numOutputs; channel++) { - if (double_precision) { - process_buffers_output_pointers[channel] = - process_buffers->output_channel_ptr(0, channel); + process_buffers_output_pointers_.resize(plugin_->numOutputs); + for (int channel = 0; channel < plugin_->numOutputs; channel++) { + if (double_precision_) { + process_buffers_output_pointers_[channel] = + process_buffers_->output_channel_ptr(0, channel); } else { - process_buffers_output_pointers[channel] = - process_buffers->output_channel_ptr(0, channel); + process_buffers_output_pointers_[channel] = + process_buffers_->output_channel_ptr(0, channel); } } diff --git a/src/wine-host/bridges/vst2.h b/src/wine-host/bridges/vst2.h index a78eb202..8ed91256 100644 --- a/src/wine-host/bridges/vst2.h +++ b/src/wine-host/bridges/vst2.h @@ -49,7 +49,7 @@ class Vst2Bridge : public HostBridge { * dangling Wine processes. * * @note The object has to be constructed from the same thread that calls - * `main_context.run()`. + * `main_context_.run()`. * * @throw std::runtime_error Thrown when the VST plugin could not be loaded, * or if communication could not be set up. @@ -103,14 +103,14 @@ class Vst2Bridge : public HostBridge { * This only has to be used instead of directly writing to `std::cerr` when * the message should be hidden on lower verbosity levels. */ - Vst2Logger logger; + Vst2Logger logger_; /** * The configuration for this instance of yabridge based on the `.so` file * that got loaded by the host. This configuration gets loaded on the plugin * side, and then sent over to the Wine host as part of the startup process. */ - Configuration config; + Configuration config_; /** * A shared memory object we'll write the input audio buffers to on the @@ -123,21 +123,21 @@ class Vst2Bridge : public HostBridge { * size and the processing precision indicated by the host so we know how * large this buffer needs to be in advance. */ - std::optional process_buffers; + std::optional process_buffers_; /** * Pointers to the input channels in process_buffers so we can pass them to * the plugin. These can be either `float*` or `double*`, so we sadly have * to use void pointers here. */ - std::vector process_buffers_input_pointers; + std::vector process_buffers_input_pointers_; /** * Pointers to the output channels in process_buffers so we can pass them to * the plugin. These can be either `float*` or `double*`, so we sadly have * to use void pointers here. */ - std::vector process_buffers_output_pointers; + std::vector process_buffers_output_pointers_; /** * The maximum number of samples the host will pass to the plugin during @@ -149,14 +149,14 @@ class Vst2Bridge : public HostBridge { * called. In that case we'll use the value obtained through * `audioMasterGetBlockSize()` instead. */ - std::optional max_samples_per_block; + std::optional max_samples_per_block_; /** * Whether the host is going to send double precision audio or not. This * will only be the case if the host has called `effSetProcessPrecision()` * with `kVstProcessPrecision64` before the call to `effMainsChanged()`. */ - bool double_precision = false; + bool double_precision_ = false; /** * We'll store the last transport information obtained from the host as a @@ -165,9 +165,9 @@ class Vst2Bridge : public HostBridge { * communication, we'll prefetch the current transport information in the * plugin as part of the audio processing call. * - * @see cached_time_info + * @see cached_time_info_ */ - VstTimeInfo last_time_info; + VstTimeInfo last_time_info_; /** * This will temporarily cache the current time info during an audio @@ -175,13 +175,13 @@ class Vst2Bridge : public HostBridge { * Some faulty plugins may even request this information for every sample, * which would otherwise cause a very noticeable performance hit. */ - ScopedValueCache time_info_cache; + ScopedValueCache time_info_cache_; /** * Some plugins will also ask for the current process level during audio * processing, so we'll also prefetch that to prevent expensive callbacks. */ - ScopedValueCache process_level_cache; + ScopedValueCache process_level_cache_; // FIXME: This emits `-Wignored-attributes` as of Wine 5.22 #pragma GCC diagnostic push @@ -192,7 +192,7 @@ class Vst2Bridge : public HostBridge { * Boost.DLL to work here, so we'll just load the VST plugisn by hand. */ std::unique_ptr, decltype(&FreeLibrary)> - plugin_handle; + plugin_handle_; #pragma GCC diagnostic pop @@ -200,23 +200,23 @@ class Vst2Bridge : public HostBridge { * The loaded plugin's `AEffect` struct, obtained using the above library * handle. */ - AEffect* plugin; + AEffect* plugin_; /** * Whether `effOpen()` has already been called. Used in * `HostBridge::inhibits_event_loop` to work around a bug in T-RackS 5. */ - bool is_initialized = false; + bool is_initialized_ = false; /** * The thread that responds to `getParameter` and `setParameter` requests. */ - Win32Thread parameters_handler; + Win32Thread parameters_handler_; /** * The thread that handles calls to `processReplacing` (and `process` as a * fallback) and `processDoubleReplacing`. */ - Win32Thread process_replacing_handler; + Win32Thread process_replacing_handler_; /** * All sockets used for communicating with this specific plugin. @@ -225,14 +225,14 @@ class Vst2Bridge : public HostBridge { * sockets will be closed first, and we can then safely wait for the * threads to exit. */ - Vst2Sockets sockets; + Vst2Sockets sockets_; /** * The plugin editor window. Allows embedding the plugin's editor into a * Wine window, and embedding that Wine window into a window provided by the * host. Should be empty when the editor is not open. */ - std::optional editor; + std::optional editor_; /** * The MIDI events that have been received **and processed** since the last @@ -246,7 +246,7 @@ class Vst2Bridge : public HostBridge { * `effProcessEvents()` call. */ boost::container::small_vector - next_audio_buffer_midi_events; + next_audio_buffer_midi_events_; /** * Whether `next_audio_buffer_midi_events` should be cleared before * inserting new events. @@ -256,12 +256,12 @@ class Vst2Bridge : public HostBridge { * event to stay alive if there have not been any new MIDI events * during the current processing cycle. */ - bool should_clear_midi_events = false; + bool should_clear_midi_events_ = false; /** * Mutex for locking the above event queue, since recieving and processing * now happens in two different threads. */ - std::mutex next_buffer_midi_events_mutex; + std::mutex next_buffer_midi_events_mutex_; /** * Used to allow the responses to host callbacks to be handled on the same @@ -272,8 +272,8 @@ class Vst2Bridge : public HostBridge { * See `mutually_recursive_callbacks` and * `safe_mutually_recursive_requests` in the implementation file for more * information on the callbacks where we want to use - * `mutual_recursion.fork()` to send them in a new thread, and the responses - * that have to be handled with `mutual_recursion.handle()`. + * `mutual_recursion_.fork()` to send them in a new thread, and the + * responses that have to be handled with `mutual_recursion_.handle()`. */ - MutualRecursionHelper mutual_recursion; + MutualRecursionHelper mutual_recursion_; }; diff --git a/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp b/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp index d67eb142..7a281472 100644 --- a/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/component-handler-proxy.cpp @@ -23,7 +23,7 @@ Vst3ComponentHandlerProxyImpl::Vst3ComponentHandlerProxyImpl( Vst3Bridge& bridge, Vst3ComponentHandlerProxy::ConstructArgs&& args) noexcept - : Vst3ComponentHandlerProxy(std::move(args)), bridge(bridge) { + : Vst3ComponentHandlerProxy(std::move(args)), bridge_(bridge) { // The lifecycle of this object is managed together with that of the plugin // object instance this host context got passed to } @@ -32,15 +32,16 @@ tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { const tresult result = Vst3ComponentHandlerProxy::queryInterface(_iid, obj); - bridge.logger.log_query_interface("In IComponentHandler::queryInterface()", - result, Steinberg::FUID::fromTUID(_iid)); + bridge_.logger_.log_query_interface( + "In IComponentHandler::queryInterface()", result, + Steinberg::FUID::fromTUID(_iid)); return result; } tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::beginEdit(Steinberg::Vst::ParamID id) { - return bridge.send_message(YaComponentHandler::BeginEdit{ + return bridge_.send_message(YaComponentHandler::BeginEdit{ .owner_instance_id = owner_instance_id(), .id = id}); } @@ -51,7 +52,7 @@ tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::performEdit( // `IEditController::setParamNormalized()` after this `performEdit()`, // so we need to be able to receive that // `IEditController::setParamNormalized()` on the same thread. - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaComponentHandler::PerformEdit{ .owner_instance_id = owner_instance_id(), .id = id, @@ -60,26 +61,26 @@ tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::performEdit( tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::endEdit(Steinberg::Vst::ParamID id) { - return bridge.send_message(YaComponentHandler::EndEdit{ + return bridge_.send_message(YaComponentHandler::EndEdit{ .owner_instance_id = owner_instance_id(), .id = id}); } tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::restartComponent(int32 flags) { - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaComponentHandler::RestartComponent{ .owner_instance_id = owner_instance_id(), .flags = flags}); } tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::setDirty(TBool state) { - return bridge.send_message(YaComponentHandler2::SetDirty{ + return bridge_.send_message(YaComponentHandler2::SetDirty{ .owner_instance_id = owner_instance_id(), .state = state}); } tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::requestOpenEditor(Steinberg::FIDString name) { if (name) { - return bridge.send_message(YaComponentHandler2::RequestOpenEditor{ + return bridge_.send_message(YaComponentHandler2::RequestOpenEditor{ .owner_instance_id = owner_instance_id(), .name = name}); } else { std::cerr << "WARNING: Null pointer passed to " @@ -90,12 +91,12 @@ Vst3ComponentHandlerProxyImpl::requestOpenEditor(Steinberg::FIDString name) { } tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::startGroupEdit() { - return bridge.send_message(YaComponentHandler2::StartGroupEdit{ + return bridge_.send_message(YaComponentHandler2::StartGroupEdit{ .owner_instance_id = owner_instance_id()}); } tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::finishGroupEdit() { - return bridge.send_message(YaComponentHandler2::FinishGroupEdit{ + return bridge_.send_message(YaComponentHandler2::FinishGroupEdit{ .owner_instance_id = owner_instance_id()}); } @@ -108,13 +109,13 @@ Vst3ComponentHandlerProxyImpl::createContextMenu( // parameter being zero' was a typo and that they mean passign a null // pointer. CreateContextMenuResponse response = - bridge.send_message(YaComponentHandler3::CreateContextMenu{ + bridge_.send_message(YaComponentHandler3::CreateContextMenu{ .owner_instance_id = owner_instance_id(), .param_id = (paramID ? std::optional(*paramID) : std::nullopt)}); if (response.context_menu_args) { return new Vst3ContextMenuProxyImpl( - bridge, std::move(*response.context_menu_args)); + bridge_, std::move(*response.context_menu_args)); } else { return nullptr; } @@ -125,7 +126,7 @@ tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::requestBusActivation( Steinberg::Vst::BusDirection dir, int32 index, TBool state) { - return bridge.send_message( + return bridge_.send_message( YaComponentHandlerBusActivation::RequestBusActivation{ .owner_instance_id = owner_instance_id(), .type = type, @@ -138,7 +139,7 @@ tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::start( ProgressType type, const Steinberg::tchar* optionalDescription, ID& outID) { - const StartResponse response = bridge.send_message(YaProgress::Start{ + const StartResponse response = bridge_.send_message(YaProgress::Start{ .owner_instance_id = owner_instance_id(), .type = type, .optional_description = @@ -155,20 +156,20 @@ tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::start( tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::update(ID id, Steinberg::Vst::ParamValue normValue) { - return bridge.send_message( + return bridge_.send_message( YaProgress::Update{.owner_instance_id = owner_instance_id(), .id = id, .norm_value = normValue}); } tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::finish(ID id) { - return bridge.send_message( + return bridge_.send_message( YaProgress::Finish{.owner_instance_id = owner_instance_id(), .id = id}); } tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::notifyUnitSelection( Steinberg::Vst::UnitID unitId) { - return bridge.send_message(YaUnitHandler::NotifyUnitSelection{ + return bridge_.send_message(YaUnitHandler::NotifyUnitSelection{ .owner_instance_id = owner_instance_id(), .unit_id = unitId}); } @@ -178,7 +179,7 @@ tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::notifyProgramListChange( // NOTE: When a plugin calls this, Ardour will fetch the new program names // with `IUnitInfo::getProgramName()`. TEOTE requires this to be // called from the same thread. - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaUnitHandler::NotifyProgramListChange{ .owner_instance_id = owner_instance_id(), .list_id = listId, @@ -186,6 +187,6 @@ tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::notifyProgramListChange( } tresult PLUGIN_API Vst3ComponentHandlerProxyImpl::notifyUnitByBusChange() { - return bridge.send_message(YaUnitHandler2::NotifyUnitByBusChange{ + return bridge_.send_message(YaUnitHandler2::NotifyUnitByBusChange{ .owner_instance_id = owner_instance_id()}); } diff --git a/src/wine-host/bridges/vst3-impls/component-handler-proxy.h b/src/wine-host/bridges/vst3-impls/component-handler-proxy.h index c9689a8d..04ed8d31 100644 --- a/src/wine-host/bridges/vst3-impls/component-handler-proxy.h +++ b/src/wine-host/bridges/vst3-impls/component-handler-proxy.h @@ -75,5 +75,5 @@ class Vst3ComponentHandlerProxyImpl : public Vst3ComponentHandlerProxy { tresult PLUGIN_API notifyUnitByBusChange() override; private: - Vst3Bridge& bridge; + Vst3Bridge& bridge_; }; diff --git a/src/wine-host/bridges/vst3-impls/connection-point-proxy.cpp b/src/wine-host/bridges/vst3-impls/connection-point-proxy.cpp index 03f97247..d8a0ff10 100644 --- a/src/wine-host/bridges/vst3-impls/connection-point-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/connection-point-proxy.cpp @@ -21,14 +21,15 @@ Vst3ConnectionPointProxyImpl::Vst3ConnectionPointProxyImpl( Vst3Bridge& bridge, Vst3ConnectionPointProxy::ConstructArgs&& args) noexcept - : Vst3ConnectionPointProxy(std::move(args)), bridge(bridge) {} + : Vst3ConnectionPointProxy(std::move(args)), bridge_(bridge) {} tresult PLUGIN_API Vst3ConnectionPointProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { const tresult result = Vst3ConnectionPointProxy::queryInterface(_iid, obj); - bridge.logger.log_query_interface("In IConnectionPoint::queryInterface()", - result, Steinberg::FUID::fromTUID(_iid)); + bridge_.logger_.log_query_interface("In IConnectionPoint::queryInterface()", + result, + Steinberg::FUID::fromTUID(_iid)); return result; } @@ -56,7 +57,7 @@ Vst3ConnectionPointProxyImpl::notify(Steinberg::Vst::IMessage* message) { // need to use our mutual recursion mechanism. Luckily only Ardour uses // connection proxies, so if this ends up breaking something it will // only affect Ardour. - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaConnectionPoint::Notify{.instance_id = owner_instance_id(), .message_ptr = YaMessagePtr(*message)}); } else { diff --git a/src/wine-host/bridges/vst3-impls/connection-point-proxy.h b/src/wine-host/bridges/vst3-impls/connection-point-proxy.h index 71df39e2..d7ae15a0 100644 --- a/src/wine-host/bridges/vst3-impls/connection-point-proxy.h +++ b/src/wine-host/bridges/vst3-impls/connection-point-proxy.h @@ -37,5 +37,5 @@ class Vst3ConnectionPointProxyImpl : public Vst3ConnectionPointProxy { tresult PLUGIN_API notify(Steinberg::Vst::IMessage* message) override; private: - Vst3Bridge& bridge; + Vst3Bridge& bridge_; }; diff --git a/src/wine-host/bridges/vst3-impls/context-menu-proxy.cpp b/src/wine-host/bridges/vst3-impls/context-menu-proxy.cpp index b8181a48..4b02293c 100644 --- a/src/wine-host/bridges/vst3-impls/context-menu-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/context-menu-proxy.cpp @@ -21,7 +21,7 @@ Vst3ContextMenuProxyImpl::Vst3ContextMenuProxyImpl( Vst3Bridge& bridge, Vst3ContextMenuProxy::ConstructArgs&& args) noexcept - : Vst3ContextMenuProxy(std::move(args)), bridge(bridge) { + : Vst3ContextMenuProxy(std::move(args)), bridge_(bridge) { bridge.register_context_menu(*this); } @@ -31,24 +31,25 @@ Vst3ContextMenuProxyImpl::~Vst3ContextMenuProxyImpl() noexcept { // NOTE: This can actually throw (e.g. out of memory or the socket got // closed). But if that were to happen, then we wouldn't be able to // recover from it anyways. - bridge.send_message( + bridge_.send_message( Vst3ContextMenuProxy::Destruct{.owner_instance_id = owner_instance_id(), .context_menu_id = context_menu_id()}); - bridge.unregister_context_menu(*this); + bridge_.unregister_context_menu(*this); } tresult PLUGIN_API Vst3ContextMenuProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { const tresult result = Vst3ContextMenuProxy::queryInterface(_iid, obj); - bridge.logger.log_query_interface("In IContextMenu::queryInterface()", - result, Steinberg::FUID::fromTUID(_iid)); + bridge_.logger_.log_query_interface("In IContextMenu::queryInterface()", + result, + Steinberg::FUID::fromTUID(_iid)); return result; } int32 PLUGIN_API Vst3ContextMenuProxyImpl::getItemCount() { - return bridge.send_message( + return bridge_.send_message( YaContextMenu::GetItemCount{.owner_instance_id = owner_instance_id(), .context_menu_id = context_menu_id()}); } @@ -60,11 +61,11 @@ tresult PLUGIN_API Vst3ContextMenuProxyImpl::getItem( // XXX: Should the plugin be able to get targets created by the host this // way? We'll just assume that this function won't ever be called by // the plugin (but we'll implement a basic version anyways). - if (index < 0 || index >= static_cast(items.size())) { + if (index < 0 || index >= static_cast(items_.size())) { return Steinberg::kInvalidArgument; } else { - item = items[index]; - *target = context_menu_targets[item.tag]; + item = items_[index]; + *target = context_menu_targets_[item.tag]; return Steinberg::kResultOk; } @@ -75,7 +76,7 @@ Vst3ContextMenuProxyImpl::addItem(const Steinberg::Vst::IContextMenuItem& item, Steinberg::Vst::IContextMenuTarget* target) { // TODO: I haven't come across a plugin that adds its own items, so this // hasn't been tested yet - const tresult result = bridge.send_message(YaContextMenu::AddItem{ + const tresult result = bridge_.send_message(YaContextMenu::AddItem{ .owner_instance_id = owner_instance_id(), .context_menu_id = context_menu_id(), .item = item, @@ -85,8 +86,8 @@ Vst3ContextMenuProxyImpl::addItem(const Steinberg::Vst::IContextMenuItem& item, : std::nullopt)}); if (result == Steinberg::kResultOk) { - items.push_back(item); - context_menu_targets[item.tag] = target; + items_.push_back(item); + context_menu_targets_[item.tag] = target; } return result; @@ -95,21 +96,21 @@ Vst3ContextMenuProxyImpl::addItem(const Steinberg::Vst::IContextMenuItem& item, tresult PLUGIN_API Vst3ContextMenuProxyImpl::removeItem( const Steinberg::Vst::IContextMenuItem& item, Steinberg::Vst::IContextMenuTarget* /*target*/) { - const tresult result = bridge.send_message( + const tresult result = bridge_.send_message( YaContextMenu::RemoveItem{.owner_instance_id = owner_instance_id(), .context_menu_id = context_menu_id(), .item = item}); if (result == Steinberg::kResultOk) { - items.erase( + items_.erase( std::remove_if( - items.begin(), items.end(), + items_.begin(), items_.end(), [&](const Steinberg::Vst::IContextMenuItem& candidate_item) { // They didn't implement `operator==` on the struct return candidate_item.tag == item.tag; }), - items.end()); - context_menu_targets.erase(item.tag); + items_.end()); + context_menu_targets_.erase(item.tag); } return result; @@ -120,7 +121,7 @@ tresult PLUGIN_API Vst3ContextMenuProxyImpl::popup(Steinberg::UCoord x, // NOTE: This requires mutual recursion, because REAPER will call // `getState()` whle the context menu is open, and `getState()` also // has to be handled from the GUi thread - return bridge.send_mutually_recursive_message( + return bridge_.send_mutually_recursive_message( YaContextMenu::Popup{.owner_instance_id = owner_instance_id(), .context_menu_id = context_menu_id(), .x = x, diff --git a/src/wine-host/bridges/vst3-impls/context-menu-proxy.h b/src/wine-host/bridges/vst3-impls/context-menu-proxy.h index 6b492e20..2d2741a9 100644 --- a/src/wine-host/bridges/vst3-impls/context-menu-proxy.h +++ b/src/wine-host/bridges/vst3-impls/context-menu-proxy.h @@ -57,14 +57,14 @@ class Vst3ContextMenuProxyImpl : public Vst3ContextMenuProxy { */ std::unordered_map> - context_menu_targets; + context_menu_targets_; private: - Vst3Bridge& bridge; + Vst3Bridge& bridge_; /** * The items passed when to `addItem` calls made by the plugin. This way we * can call these same targets later. */ - std::vector items; + std::vector items_; }; diff --git a/src/wine-host/bridges/vst3-impls/host-context-proxy.cpp b/src/wine-host/bridges/vst3-impls/host-context-proxy.cpp index 1096faad..7aaf6216 100644 --- a/src/wine-host/bridges/vst3-impls/host-context-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/host-context-proxy.cpp @@ -24,7 +24,7 @@ Vst3HostContextProxyImpl::Vst3HostContextProxyImpl( Vst3Bridge& bridge, Vst3HostContextProxy::ConstructArgs&& args) noexcept - : Vst3HostContextProxy(std::move(args)), bridge(bridge) { + : Vst3HostContextProxy(std::move(args)), bridge_(bridge) { // The lifecycle of this object is managed together with that of the plugin // object instance this host context got passed to } @@ -33,8 +33,8 @@ tresult PLUGIN_API Vst3HostContextProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { const tresult result = Vst3HostContextProxy::queryInterface(_iid, obj); - bridge.logger.log_query_interface("In FUnknown::queryInterface()", result, - Steinberg::FUID::fromTUID(_iid)); + bridge_.logger_.log_query_interface("In FUnknown::queryInterface()", result, + Steinberg::FUID::fromTUID(_iid)); return result; } @@ -43,7 +43,7 @@ tresult PLUGIN_API Vst3HostContextProxyImpl::getName(Steinberg::Vst::String128 name) { if (name) { const GetNameResponse response = - bridge.send_message(YaHostApplication::GetName{ + bridge_.send_message(YaHostApplication::GetName{ .owner_instance_id = owner_instance_id()}); std::copy(response.name.begin(), response.name.end(), name); @@ -51,7 +51,7 @@ Vst3HostContextProxyImpl::getName(Steinberg::Vst::String128 name) { return response.result; } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to 'IHostApplication::getName()'"); return Steinberg::kInvalidArgument; } @@ -86,8 +86,8 @@ Vst3HostContextProxyImpl::createInstance(Steinberg::TUID /*cid*/, } const Steinberg::FUID uid = Steinberg::FUID::fromTUID(_iid); - bridge.logger.log_query_interface("In IHostApplication::createInstance()", - response, uid); + bridge_.logger_.log_query_interface("In IHostApplication::createInstance()", + response, uid); return response; } @@ -95,12 +95,12 @@ Vst3HostContextProxyImpl::createInstance(Steinberg::TUID /*cid*/, tresult PLUGIN_API Vst3HostContextProxyImpl::isPlugInterfaceSupported(const Steinberg::TUID _iid) { if (_iid) { - return bridge.send_message( + return bridge_.send_message( YaPlugInterfaceSupport::IsPlugInterfaceSupported{ .owner_instance_id = owner_instance_id(), .iid = *reinterpret_cast(&_iid)}); } else { - bridge.logger.log( + bridge_.logger_.log( "WARNING: Null pointer passed to " "'IPlugInterfaceSupport::isPlugInterfaceSupported()'"); return Steinberg::kInvalidArgument; diff --git a/src/wine-host/bridges/vst3-impls/host-context-proxy.h b/src/wine-host/bridges/vst3-impls/host-context-proxy.h index 36213f73..845e5266 100644 --- a/src/wine-host/bridges/vst3-impls/host-context-proxy.h +++ b/src/wine-host/bridges/vst3-impls/host-context-proxy.h @@ -42,5 +42,5 @@ class Vst3HostContextProxyImpl : public Vst3HostContextProxy { isPlugInterfaceSupported(const Steinberg::TUID _iid) override; private: - Vst3Bridge& bridge; + Vst3Bridge& bridge_; }; diff --git a/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp b/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp index c8dfdd26..15156dfc 100644 --- a/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp +++ b/src/wine-host/bridges/vst3-impls/plug-frame-proxy.cpp @@ -21,7 +21,7 @@ Vst3PlugFrameProxyImpl::Vst3PlugFrameProxyImpl( Vst3Bridge& bridge, Vst3PlugFrameProxy::ConstructArgs&& args) noexcept - : Vst3PlugFrameProxy(std::move(args)), bridge(bridge) { + : Vst3PlugFrameProxy(std::move(args)), bridge_(bridge) { // The lifecycle of this object is managed together with that of the plugin // object instance this host context got passed to } @@ -29,8 +29,9 @@ Vst3PlugFrameProxyImpl::Vst3PlugFrameProxyImpl( tresult PLUGIN_API Vst3PlugFrameProxyImpl::queryInterface(const Steinberg::TUID _iid, void** obj) { const tresult result = Vst3PlugFrameProxy::queryInterface(_iid, obj); - bridge.logger.log_query_interface("In IPlugFrame::queryInterface()", result, - Steinberg::FUID::fromTUID(_iid)); + bridge_.logger_.log_query_interface("In IPlugFrame::queryInterface()", + result, + Steinberg::FUID::fromTUID(_iid)); return result; } @@ -46,12 +47,12 @@ Vst3PlugFrameProxyImpl::resizeView(Steinberg::IPlugView* /*view*/, // Resize the editor wrapper window in advance. We will do another // resize automatically on `IPlugView::onSize()`, but this should make // resizes look a bit smoother. - bridge.maybe_resize_editor(owner_instance_id(), *newSize); + bridge_.maybe_resize_editor(owner_instance_id(), *newSize); // We have to use this special sending function here so we can handle // calls to `IPlugView::onSize()` from this same thread (the UI thread). // See the docstring for more information. - return bridge.send_mutually_recursive_message(YaPlugFrame::ResizeView{ + return bridge_.send_mutually_recursive_message(YaPlugFrame::ResizeView{ .owner_instance_id = owner_instance_id(), .new_size = *newSize}); } else { std::cerr diff --git a/src/wine-host/bridges/vst3-impls/plug-frame-proxy.h b/src/wine-host/bridges/vst3-impls/plug-frame-proxy.h index b055914b..c68241fc 100644 --- a/src/wine-host/bridges/vst3-impls/plug-frame-proxy.h +++ b/src/wine-host/bridges/vst3-impls/plug-frame-proxy.h @@ -35,5 +35,5 @@ class Vst3PlugFrameProxyImpl : public Vst3PlugFrameProxy { Steinberg::ViewRect* newSize) override; private: - Vst3Bridge& bridge; + Vst3Bridge& bridge_; }; diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 8cb7e7e5..9a514466 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -91,30 +91,30 @@ Vst3Bridge::Vst3Bridge(MainContext& main_context, std::string endpoint_base_dir, pid_t parent_pid) : HostBridge(main_context, plugin_dll_path, parent_pid), - logger(generic_logger), - sockets(main_context.context, endpoint_base_dir, false) { + logger_(generic_logger_), + sockets_(main_context.context_, endpoint_base_dir, false) { std::string error; - module = VST3::Hosting::Win32Module::create(plugin_dll_path, error); - if (!module) { + module_ = VST3::Hosting::Win32Module::create(plugin_dll_path, error); + if (!module_) { throw std::runtime_error("Could not load the VST3 module for '" + plugin_dll_path + "': " + error); } - sockets.connect(); + sockets_.connect(); // Fetch this instance's configuration from the plugin to finish the setup // process - config = sockets.vst_host_callback.send_message( + config_ = sockets_.vst_host_callback_.send_message( WantsConfiguration{.host_version = yabridge_git_version}, std::nullopt); // Allow this plugin to configure the main context's tick rate - main_context.update_timer_interval(config.event_loop_interval()); + main_context.update_timer_interval(config_.event_loop_interval()); } bool Vst3Bridge::inhibits_event_loop() noexcept { - std::shared_lock lock(object_instances_mutex); + std::shared_lock lock(object_instances_mutex_); - for (const auto& [instance_id, instance] : object_instances) { + for (const auto& [instance_id, instance] : object_instances_) { // HACK: IK Multimedia's T-RackS 5 will deadlock if it receives a timer // proc during offline processing, so we need to prevent that from // happening. @@ -129,17 +129,17 @@ bool Vst3Bridge::inhibits_event_loop() noexcept { void Vst3Bridge::run() { set_realtime_priority(true); - sockets.host_vst_control.receive_messages( + sockets_.host_vst_control_.receive_messages( std::nullopt, overload{ [&](const Vst3PluginFactoryProxy::Construct&) -> Vst3PluginFactoryProxy::Construct::Response { return Vst3PluginFactoryProxy::ConstructArgs( - module->getFactory().get()); + module_->getFactory().get()); }, [&](const Vst3PlugViewProxy::Destruct& request) -> Vst3PlugViewProxy::Destruct::Response { - main_context + main_context_ .run_in_context([&]() -> void { // When the pointer gets dropped by the host, we want to // drop it here as well, along with the `IPlugFrame` @@ -169,7 +169,7 @@ void Vst3Bridge::run() { // immediatly starts timers or something (even though it // shouldn't) Steinberg::IPtr object = - main_context + main_context_ .run_in_context( [&]() -> Steinberg::IPtr { Steinberg::IPtr result; @@ -185,7 +185,7 @@ void Vst3Bridge::run() { case Vst3PluginProxy::Construct::Interface:: IComponent: result = - module->getFactory() + module_->getFactory() .createInstance< Steinberg::Vst::IComponent>( cid); @@ -193,7 +193,7 @@ void Vst3Bridge::run() { case Vst3PluginProxy::Construct::Interface:: IEditController: result = - module->getFactory() + module_->getFactory() .createInstance< Steinberg::Vst:: IEditController>(cid); @@ -390,7 +390,7 @@ void Vst3Bridge::run() { return instance.registered_context_menus .at(request.context_menu_id) .get() - .context_menu_targets[request.target_tag] + .context_menu_targets_[request.target_tag] ->executeMenuItem(request.tag); }, [&](YaEditController::SetComponentState& request) @@ -507,7 +507,7 @@ void Vst3Bridge::run() { -> YaEditController::CreateView::Response { // Instantiate the object from the GUI thread const auto plug_view_args = - main_context + main_context_ .run_in_context( [&]() -> std::optional< Vst3PlugViewProxy::ConstructArgs> { @@ -581,7 +581,7 @@ void Vst3Bridge::run() { // Melodyne wants to immediately update the GUI upon receiving // certain channel context data, so this has to be run from the // main thread - return main_context + return main_context_ .run_in_context([&]() -> tresult { const auto& [instance, _] = get_instance(request.instance_id); @@ -786,10 +786,11 @@ void Vst3Bridge::run() { // Creating the window and having the plugin embed in it should // be done in the main UI thread - return main_context + return main_context_ .run_in_context([&, &instance = instance]() -> tresult { Editor& editor_instance = instance.editor.emplace( - main_context, config, generic_logger, x11_handle); + main_context_, config_, generic_logger_, + x11_handle); const tresult result = instance.plug_view_instance->plug_view->attached( editor_instance.get_win32_handle(), @@ -815,7 +816,7 @@ void Vst3Bridge::run() { }, [&](const YaPlugView::Removed& request) -> YaPlugView::Removed::Response { - return main_context + return main_context_ .run_in_context([&]() -> tresult { const auto& [instance, _] = get_instance(request.owner_instance_id); @@ -833,7 +834,7 @@ void Vst3Bridge::run() { -> YaPlugView::OnWheel::Response { // Since all of these `IPlugView::on*` functions can cause a // redraw, they all have to be called from the UI thread - return main_context + return main_context_ .run_in_context([&]() -> tresult { const auto& [instance, _] = get_instance(request.owner_instance_id); @@ -845,7 +846,7 @@ void Vst3Bridge::run() { }, [&](const YaPlugView::OnKeyDown& request) -> YaPlugView::OnKeyDown::Response { - return main_context + return main_context_ .run_in_context([&]() -> tresult { const auto& [instance, _] = get_instance(request.owner_instance_id); @@ -858,7 +859,7 @@ void Vst3Bridge::run() { }, [&](const YaPlugView::OnKeyUp& request) -> YaPlugView::OnKeyUp::Response { - return main_context + return main_context_ .run_in_context([&]() -> tresult { const auto& [instance, _] = get_instance(request.owner_instance_id); @@ -920,7 +921,7 @@ void Vst3Bridge::run() { }, [&](const YaPlugView::OnFocus& request) -> YaPlugView::OnFocus::Response { - return main_context + return main_context_ .run_in_context([&]() -> tresult { const auto& [instance, _] = get_instance(request.owner_instance_id); @@ -935,7 +936,7 @@ void Vst3Bridge::run() { // This likely doesn't have to be run from the GUI thread, but // since 80% of the `IPlugView` functions have to be we'll do it // here anyways - return main_context + return main_context_ .run_in_context([&]() -> tresult { const auto& [instance, _] = get_instance(request.owner_instance_id); @@ -988,7 +989,7 @@ void Vst3Bridge::run() { [&](YaPlugViewContentScaleSupport::SetContentScaleFactor& request) -> YaPlugViewContentScaleSupport::SetContentScaleFactor:: Response { - if (config.vst3_no_scaling) { + if (config_.vst3_no_scaling) { std::cerr << "The host requested the editor GUI to " "be scaled by a factor of " << request.factor @@ -997,7 +998,7 @@ void Vst3Bridge::run() { << std::endl; return Steinberg::kNotImplemented; } else { - return main_context + return main_context_ .run_in_context([&]() -> tresult { const auto& [instance, _] = get_instance(request.owner_instance_id); @@ -1014,7 +1015,7 @@ void Vst3Bridge::run() { // Since plugins might want to start timers in // `IPlugView::{initialize,terminate}`, we'll run these // functions from the main GUI thread - return main_context + return main_context_ .run_in_context([&]() -> Vst3PluginProxy::InitializeResponse { const auto& [instance, _] = @@ -1066,7 +1067,7 @@ void Vst3Bridge::run() { }, [&](const YaPluginBase::Terminate& request) -> YaPluginBase::Terminate::Response { - return main_context + return main_context_ .run_in_context([&]() -> tresult { const auto& [instance, _] = get_instance(request.instance_id); @@ -1137,18 +1138,18 @@ void Vst3Bridge::run() { }, [&](YaPluginFactory3::SetHostContext& request) -> YaPluginFactory3::SetHostContext::Response { - plugin_factory_host_context = + plugin_factory_host_context_ = Steinberg::owned(new Vst3HostContextProxyImpl( *this, std::move(request.host_context_args))); Steinberg::FUnknownPtr factory_3( - module->getFactory().get()); + module_->getFactory().get()); assert(factory_3); // This static cast is required to upcast to `FUnknown*` return factory_3->setHostContext( static_cast( - plugin_factory_host_context)); + plugin_factory_host_context_)); }, [&](const YaUnitInfo::GetUnitCount& request) -> YaUnitInfo::GetUnitCount::Response { @@ -1327,19 +1328,19 @@ void Vst3Bridge::unregister_context_menu( } void Vst3Bridge::close_sockets() { - sockets.close(); + sockets_.close(); } size_t Vst3Bridge::generate_instance_id() noexcept { - return current_instance_id.fetch_add(1); + return current_instance_id_.fetch_add(1); } std::pair> Vst3Bridge::get_instance(size_t instance_id) noexcept { - std::shared_lock lock(object_instances_mutex); + std::shared_lock lock(object_instances_mutex_); return std::pair>( - object_instances.at(instance_id), std::move(lock)); + object_instances_.at(instance_id), std::move(lock)); } AudioShmBuffer::Config Vst3Bridge::setup_shared_audio_buffers( @@ -1403,7 +1404,7 @@ AudioShmBuffer::Config Vst3Bridge::setup_shared_audio_buffers( // when this request returns we'll do the same thing on the native plugin // side AudioShmBuffer::Config buffer_config{ - .name = sockets.base_dir.filename().string() + "-" + + .name = sockets_.base_dir_.filename().string() + "-" + std::to_string(instance_id), .size = buffer_size, .input_offsets = std::move(input_bus_offsets), @@ -1439,7 +1440,7 @@ AudioShmBuffer::Config Vst3Bridge::setup_shared_audio_buffers( set_bus_pointers( instance.process_buffers_input_pointers, - instance.process_buffers->config.input_offsets, + instance.process_buffers->config_.input_offsets, [&, &instance = instance](uint32_t bus, uint32_t channel) -> void* { if (double_precision) { return instance.process_buffers->input_channel_ptr( @@ -1451,7 +1452,7 @@ AudioShmBuffer::Config Vst3Bridge::setup_shared_audio_buffers( }); set_bus_pointers( instance.process_buffers_output_pointers, - instance.process_buffers->config.output_offsets, + instance.process_buffers->config_.output_offsets, [&, &instance = instance](uint32_t bus, uint32_t channel) -> void* { if (double_precision) { return instance.process_buffers->output_channel_ptr( @@ -1467,19 +1468,19 @@ AudioShmBuffer::Config Vst3Bridge::setup_shared_audio_buffers( size_t Vst3Bridge::register_object_instance( Steinberg::IPtr object) { - std::unique_lock lock(object_instances_mutex); + std::unique_lock lock(object_instances_mutex_); const size_t instance_id = generate_instance_id(); - object_instances.emplace(instance_id, std::move(object)); + object_instances_.emplace(instance_id, std::move(object)); // If the object supports `IComponent` or `IAudioProcessor`, // then we'll set up a dedicated thread for function calls for // those interfaces. - if (object_instances.at(instance_id).interfaces.audio_processor || - object_instances.at(instance_id).interfaces.component) { + if (object_instances_.at(instance_id).interfaces.audio_processor || + object_instances_.at(instance_id).interfaces.component) { std::promise socket_listening_latch; - object_instances.at(instance_id) + object_instances_.at(instance_id) .audio_processor_handler = Win32Thread([&, instance_id]() { set_realtime_priority(true); @@ -1491,7 +1492,7 @@ size_t Vst3Bridge::register_object_instance( "audio-" + std::to_string(instance_id); pthread_setname_np(pthread_self(), thread_name.c_str()); - sockets.add_audio_processor_and_listen( + sockets_.add_audio_processor_and_listen( instance_id, socket_listening_latch, overload{ [&](YaAudioProcessor::SetBusArrangements& request) @@ -1755,7 +1756,7 @@ void Vst3Bridge::unregister_object_instance(size_t instance_id) { // created one while handling `Vst3PluginProxy::Construct` if (const auto& [instance, _] = get_instance(instance_id); instance.interfaces.audio_processor || instance.interfaces.component) { - sockets.remove_audio_processor(instance_id); + sockets_.remove_audio_processor(instance_id); } // Remove the instance from within the main IO context so @@ -1766,10 +1767,10 @@ void Vst3Bridge::unregister_object_instance(size_t instance_id) { // Win32 timer in between where the above closure is being // executed and when the actual host application context on // the plugin side gets deallocated. - main_context + main_context_ .run_in_context([&, instance_id]() -> void { - std::unique_lock lock(object_instances_mutex); - object_instances.erase(instance_id); + std::unique_lock lock(object_instances_mutex_); + object_instances_.erase(instance_id); }) .wait(); } diff --git a/src/wine-host/bridges/vst3.h b/src/wine-host/bridges/vst3.h index b2af2c6a..b962bda3 100644 --- a/src/wine-host/bridges/vst3.h +++ b/src/wine-host/bridges/vst3.h @@ -328,12 +328,12 @@ class Vst3Bridge : public HostBridge { public: /** * Send a callback message to the host return the response. This is a - * shorthand for `sockets.vst_host_callback.send_message` for use in VST3 + * shorthand for `sockets.vst_host_callback_.send_message` for use in VST3 * interface implementations. */ template typename T::Response send_message(const T& object) { - return sockets.vst_host_callback.send_message(object, std::nullopt); + return sockets_.vst_host_callback_.send_message(object, std::nullopt); } /** @@ -373,11 +373,11 @@ class Vst3Bridge : public HostBridge { */ template typename T::Response send_mutually_recursive_message(const T& object) { - if (main_context.is_gui_thread()) { - return mutual_recursion.fork( + if (main_context_.is_gui_thread()) { + return mutual_recursion_.fork( [&]() { return send_message(object); }); } else { - return audio_thread_mutual_recursion.fork( + return audio_thread_mutual_recursion_.fork( [&]() { return send_message(object); }); } } @@ -388,7 +388,7 @@ class Vst3Bridge : public HostBridge { * functions on the GUI thread. If another thread is currently calling that * function (from the UI thread), then we'll execute `fn` from the UI thread * using the IO context started in the above function. Otherwise `f` will be - * run on the UI thread through `main_context` as usual. + * run on the UI thread through `main_context_` as usual. * * @see Vst3Bridge::send_mutually_recursive_message */ @@ -398,10 +398,10 @@ class Vst3Bridge : public HostBridge { // then we'll call `fn` from that same thread. Otherwise we'll just // submit it to the main IO context. if (const auto result = - mutual_recursion.maybe_handle(std::forward(fn))) { + mutual_recursion_.maybe_handle(std::forward(fn))) { return *result; } else { - return main_context.run_in_context(std::forward(fn)).get(); + return main_context_.run_in_context(std::forward(fn)).get(); } } @@ -413,11 +413,11 @@ class Vst3Bridge : public HostBridge { */ template std::invoke_result_t do_mutual_recursion_on_off_thread(F&& fn) { - if (const auto result = audio_thread_mutual_recursion.maybe_handle( + if (const auto result = audio_thread_mutual_recursion_.maybe_handle( std::forward(fn))) { return *result; } else { - return mutual_recursion.handle(std::forward(fn)); + return mutual_recursion_.handle(std::forward(fn)); } } @@ -429,7 +429,7 @@ class Vst3Bridge : public HostBridge { * This only has to be used instead of directly writing to `std::cerr` when * the message should be hidden on lower verbosity levels. */ - Vst3Logger logger; + Vst3Logger logger_; private: /** @@ -458,15 +458,15 @@ class Vst3Bridge : public HostBridge { const Steinberg::Vst::ProcessSetup& setup); /** - * Assign a unique identifier to an object and add it to `object_instances`. - * This will also set up listeners for `IAudioProcessor` and `IComponent` - * function calls. + * Assign a unique identifier to an object and add it to + * `object_instances_`. This will also set up listeners for + * `IAudioProcessor` and `IComponent` function calls. */ size_t register_object_instance( Steinberg::IPtr object); /** - * Remove an object from `object_instances`. Will also tear down the + * Remove an object from `object_instances_`. Will also tear down the * `IAudioProcessor`/`IComponent` socket if it had one. */ void unregister_object_instance(size_t instance_id); @@ -476,9 +476,9 @@ class Vst3Bridge : public HostBridge { * that got loaded by the host. This configuration gets loaded on the plugin * side, and then sent over to the Wine host as part of the startup process. */ - Configuration config; + Configuration config_; - std::shared_ptr module; + std::shared_ptr module_; /** * All sockets used for communicating with this specific plugin. @@ -487,7 +487,7 @@ class Vst3Bridge : public HostBridge { * sockets will be closed first, and we can then safely wait for the * threads to exit. */ - Vst3Sockets sockets; + Vst3Sockets sockets_; /** * Used to assign unique identifiers to instances created for @@ -495,13 +495,13 @@ class Vst3Bridge : public HostBridge { * * @related enerate_instance_id */ - std::atomic_size_t current_instance_id; + std::atomic_size_t current_instance_id_; /** * The host context proxy object if we got passed a host context during a * call to `IPluginFactory3::setHostContext()` by the host. */ - Steinberg::IPtr plugin_factory_host_context; + Steinberg::IPtr plugin_factory_host_context_; /** * These are all the objects we have created through the Windows VST3 @@ -512,7 +512,7 @@ class Vst3Bridge : public HostBridge { * will cause all pointers to it to get dropped and the object to be cleaned * up. */ - std::unordered_map object_instances; + std::unordered_map object_instances_; /** * In theory all object handling is safe iff the host also doesn't do * anything weird even without locks. The only time a data race can occur is @@ -526,7 +526,7 @@ class Vst3Bridge : public HostBridge { * `get_instance()` never yields to the scheduler during audio * processing, but it's still something we should avoid at all costs. */ - std::shared_mutex object_instances_mutex; + std::shared_mutex object_instances_mutex_; /** * Used in `send_mutually_recursive_message()` to be able to execute @@ -535,7 +535,7 @@ class Vst3Bridge : public HostBridge { * `do_mutual_recursion_on_off_thread()`) while we're waiting for a * response. */ - MutualRecursionHelper mutual_recursion; + MutualRecursionHelper mutual_recursion_; /** * The same thing as above, but just for the pair of @@ -553,5 +553,5 @@ class Vst3Bridge : public HostBridge { * mutexes), but they may not interfere with the GUI thread if * `IComponentHandler::performEdit()` wasn't called from there. */ - MutualRecursionHelper audio_thread_mutual_recursion; + MutualRecursionHelper audio_thread_mutual_recursion_; }; diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index 3e24c4a4..c102728e 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -57,7 +57,7 @@ constexpr size_t idle_timer_id = 1337; /** * The X11 event mask for the host window, which in most DAWs except for Ardour - * and REAPER will be the same as `parent_window`. + * and REAPER will be the same as `parent_window_`. */ constexpr uint32_t host_event_mask = XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_VISIBILITY_CHANGE; @@ -65,7 +65,7 @@ constexpr uint32_t host_event_mask = /** * The X11 event mask for the parent window. We'll use this for input focus * grabbing (we'll receive the `EnterNotify` and `LeaveNotify` events for - * `wrapper_window`). We also need this structure notify here as well to detect + * `wrapper_window_`). We also need this structure notify here as well to detect * reparents. */ constexpr uint32_t parent_event_mask = @@ -93,8 +93,8 @@ constexpr uint32_t wrapper_event_mask = XCB_EVENT_MASK_STRUCTURE_NOTIFY | constexpr char active_window_property_name[] = "_NET_ACTIVE_WINDOW"; /** - * We'll use this property to filter windows for `host_window`. Like `xprop` and - * `xwininfo`, we'll only consider windows with this property set. + * We'll use this property to filter windows for `host_window_`. Like `xprop` + * and `xwininfo`, we'll only consider windows with this property set. */ constexpr char wm_state_property_name[] = "WM_STATE"; @@ -120,7 +120,7 @@ static const HCURSOR arrow_cursor = LoadCursor(nullptr, IDC_ARROW); /** * Find the the ancestors for the given window. This returns a list of window - * IDs that starts wit h`starting_at`, and then iteratively contains the parent + * IDs that starts with `starting_at`, and then iteratively contains the parent * of the previous window in the list until we reach the root window. The * topmost window (i.e. the window closest to the root in the window stack) will * be the last window in this list. @@ -136,9 +136,9 @@ boost::container::small_vector find_ancestor_windows( xcb_window_t starting_at); /** - * Figure out which window is used by the host to embed `parent_window` in. In - * most cases this will be the same as `parent_window`, but for instance Ardour - * and REAPER will have `parent_window` embedded inside of another window. It's + * Figure out which window is used by the host to embed `parent_window_` in. In + * most cases this will be the same as `parent_window_`, but for instance Ardour + * and REAPER will have `parent_window_` embedded inside of another window. It's * sadly not as easy as just taking the topmost window from * `find_ancestor_windows()`, as the topmost window may not be a 'normal' window * that shows up the window manager. For validity we'll simply look for @@ -198,9 +198,9 @@ DeferredWin32Window::DeferredWin32Window( MainContext& main_context, std::shared_ptr x11_connection, HWND window) noexcept - : handle(window), - main_context(main_context), - x11_connection(x11_connection) {} + : handle_(window), + main_context_(main_context), + x11_connection_(x11_connection) {} DeferredWin32Window::~DeferredWin32Window() noexcept { // NOTE: For some rason, Wine will sometimes try to delete a window twice if @@ -210,10 +210,10 @@ DeferredWin32Window::~DeferredWin32Window() noexcept { // error every time you close such a plugin's editor, and in other // DAWs I've also seen it happen from time to time. try { - const xcb_window_t wine_window = get_x11_handle(handle); + const xcb_window_t wine_window = get_x11_handle(handle_); const xcb_window_t root_window = - get_root_window(*x11_connection, wine_window); - xcb_reparent_window(x11_connection.get(), wine_window, root_window, 0, + get_root_window(*x11_connection_, wine_window); + xcb_reparent_window(x11_connection_.get(), wine_window, root_window, 0, 0); } catch (const std::runtime_error& error) { // If we can't reparent the window (or, well, fetch the root window), @@ -229,28 +229,28 @@ DeferredWin32Window::~DeferredWin32Window() noexcept { // worlds solution that works as expected in every host I've tested. try { std::shared_ptr destroy_timer = - std::make_shared(main_context.context); + std::make_shared(main_context_.context_); destroy_timer->expires_after(1s); // Note that we capture a copy of `destroy_timer` here. This way we // don't have to manage the timer instance ourselves as it will just // clean itself up after this lambda gets called. - destroy_timer->async_wait([destroy_timer, handle = this->handle, - x11_connection = this->x11_connection]( - const boost::system::error_code& error) { - if (error.failed()) { - return; - } + destroy_timer->async_wait( + [destroy_timer, handle = handle_, x11_connection = x11_connection_]( + const boost::system::error_code& error) { + if (error.failed()) { + return; + } - // This is the flush for the reparent done above. We'll also do this - // as late as possible to prevent the window from being drawn in the - // meantime, as that would cause flickering. - xcb_flush(x11_connection.get()); + // This is the flush for the reparent done above. We'll also do + // this as late as possible to prevent the window from being + // drawn in the meantime, as that would cause flickering. + xcb_flush(x11_connection.get()); - // The actual destroying will happen as part of the Win32 message - // loop - PostMessage(handle, WM_CLOSE, 0, 0); - }); + // The actual destroying will happen as part of the Win32 + // message loop + PostMessage(handle, WM_CLOSE, 0, 0); + }); } catch (const std::bad_alloc&) { // If we can't allocate the timer, then we probably have bigger worries // than not cleaning up a window @@ -262,62 +262,62 @@ Editor::Editor(MainContext& main_context, Logger& logger, const size_t parent_window_handle, std::optional> timer_proc) - : use_coordinate_hack(config.editor_coordinate_hack), - use_xembed(config.editor_xembed), - logger(logger), - x11_connection(xcb_connect(nullptr, nullptr), xcb_disconnect), - dnd_proxy_handle(WineXdndProxy::get_handle()), - client_area(get_maximum_screen_dimensions(*x11_connection)), + : use_coordinate_hack_(config.editor_coordinate_hack), + use_xembed_(config.editor_xembed), + logger_(logger), + x11_connection_(xcb_connect(nullptr, nullptr), xcb_disconnect), + dnd_proxy_handle_(WineXdndProxy::get_handle()), + client_area_(get_maximum_screen_dimensions(*x11_connection_)), // Create a window without any decoratiosn for easy embedding. The // combination of `WS_EX_TOOLWINDOW` and `WS_POPUP` causes the window to // be drawn without any decorations (making resizes behave as you'd // expect) and also causes mouse coordinates to be relative to the window // itself. - win32_window(main_context, - x11_connection, - CreateWindowEx(WS_EX_TOOLWINDOW, - reinterpret_cast(get_window_class()), - "yabridge plugin", - WS_POPUP, - // NOTE: With certain DEs/WMs (notably, - // Cinnamon), Wine does not render the - // window at all when using a primary - // display that's positioned to the - // right of another display. Presumably - // it tries to manually clip the client - // rendered client area to the physical - // display. During the reparenting and - // `fix_local_coordinates()` the window - // will be moved to `(0, 0)` anyways, - // but setting its initial position - // according to the primary display - // fixes these rendering issues. - GetSystemMetrics(SM_XVIRTUALSCREEN), - GetSystemMetrics(SM_YVIRTUALSCREEN), - client_area.width, - client_area.height, - nullptr, - nullptr, - GetModuleHandle(nullptr), - this)), - idle_timer( - Win32Timer(win32_window.handle, + win32_window_(main_context, + x11_connection_, + CreateWindowEx(WS_EX_TOOLWINDOW, + reinterpret_cast(get_window_class()), + "yabridge plugin", + WS_POPUP, + // NOTE: With certain DEs/WMs (notably, + // Cinnamon), Wine does not render the + // window at all when using a primary + // display that's positioned to the + // right of another display. Presumably + // it tries to manually clip the client + // rendered client area to the physical + // display. During the reparenting and + // `fix_local_coordinates()` the window + // will be moved to `(0, 0)` anyways, + // but setting its initial position + // according to the primary display + // fixes these rendering issues. + GetSystemMetrics(SM_XVIRTUALSCREEN), + GetSystemMetrics(SM_YVIRTUALSCREEN), + client_area_.width, + client_area_.height, + nullptr, + nullptr, + GetModuleHandle(nullptr), + this)), + idle_timer_( + Win32Timer(win32_window_.handle_, idle_timer_id, std::chrono::duration_cast( config.event_loop_interval()) .count())), - idle_timer_proc([this, timer_proc = std::move(timer_proc)]() mutable { + idle_timer_proc_([this, timer_proc = std::move(timer_proc)]() mutable { handle_x11_events(); if (timer_proc) { (*timer_proc)(); } }), - xcb_wm_state_property( - get_atom_by_name(*x11_connection, wm_state_property_name)), - parent_window(parent_window_handle), - wrapper_window( - x11_connection, - [parent_window = parent_window]( + xcb_wm_state_property_( + get_atom_by_name(*x11_connection_, wm_state_property_name)), + parent_window_(parent_window_handle), + wrapper_window_( + x11_connection_, + [parent_window = parent_window_]( std::shared_ptr x11_connection, xcb_window_t window) { xcb_generic_error_t* error = nullptr; @@ -333,29 +333,31 @@ Editor::Editor(MainContext& main_context, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr); }), - wine_window(get_x11_handle(win32_window.handle)), - host_window(find_host_window(*x11_connection, - parent_window, - xcb_wm_state_property) - .value_or(parent_window)) { - logger.log_editor_trace( - [&]() { return "DEBUG: host_window: " + std::to_string(host_window); }); + wine_window_(get_x11_handle(win32_window_.handle_)), + host_window_(find_host_window(*x11_connection_, + parent_window_, + xcb_wm_state_property_) + .value_or(parent_window_)) { logger.log_editor_trace([&]() { - return "DEBUG: parent_window: " + std::to_string(parent_window); + return "DEBUG: host_window: " + std::to_string(host_window_); + }); + logger.log_editor_trace([&]() { + return "DEBUG: parent_window: " + std::to_string(parent_window_); }); logger.log_editor_trace([&]() { return "DEBUG: wrapper_window: " + - std::to_string(wrapper_window.window); + std::to_string(wrapper_window_.window_); + }); + logger.log_editor_trace([&]() { + return "DEBUG: wine_window: " + std::to_string(wine_window_); }); - logger.log_editor_trace( - [&]() { return "DEBUG: wine_window: " + std::to_string(wine_window); }); // Used for input focus grabbing to only grab focus when the window is // active. In case the atom does not exist or the WM does not support this // hint, we'll print a warning and fall back to grabbing focus when the user // clicks on the window (which should trigger a `WM_PARENTNOTIFY`). - active_window_property = - get_atom_by_name(*x11_connection, active_window_property_name); + active_window_property_ = + get_atom_by_name(*x11_connection_, active_window_property_name); if (!supports_ewmh_active_window()) { std::cerr << "WARNING: The current window manager does not support the" << std::endl; @@ -366,22 +368,23 @@ Editor::Editor(MainContext& main_context, } // If the `editor_force_dnd` option is set, we'll strip `XdndAware` from all - // of `wine_window`'s ancestors (including `parent_window`) to forcefully + // of `wine_window_`'s ancestors (including `parent_window_`) to forcefully // enable drag-and-drop support in REAPER. See the docstring on // `Configuration::editor_force_dnd` and the option description in the // readme for more information. if (config.editor_force_dnd) { const xcb_atom_t xcb_xdnd_aware_property = - get_atom_by_name(*x11_connection, xdnd_aware_property_name); + get_atom_by_name(*x11_connection_, xdnd_aware_property_name); for (const xcb_window_t& window : - find_ancestor_windows(*x11_connection, parent_window)) { - xcb_delete_property(x11_connection.get(), window, + find_ancestor_windows(*x11_connection_, parent_window_)) { + xcb_delete_property(x11_connection_.get(), window, xcb_xdnd_aware_property); } } // When using XEmbed we'll need the atoms for the corresponding properties - xcb_xembed_message = get_atom_by_name(*x11_connection, xembed_message_name); + xcb_xembed_message_ = + get_atom_by_name(*x11_connection_, xembed_message_name); // When not using XEmbed, Wine will interpret any local coordinates as // global coordinates. To work around this we'll tell the Wine window it's @@ -394,24 +397,24 @@ Editor::Editor(MainContext& main_context, // release input focus as necessary. And lastly we'll look out for // reparents, so we can make sure that the window does not get stolen by the // window manager and that we correctly handle the host reparenting - // `parent_window` themselves. + // `parent_window_` themselves. // If we do enable XEmbed support, we'll also listen for visibility changes // and trigger the embedding when the window becomes visible - xcb_change_window_attributes(x11_connection.get(), host_window, + xcb_change_window_attributes(x11_connection_.get(), host_window_, XCB_CW_EVENT_MASK, &host_event_mask); - xcb_change_window_attributes(x11_connection.get(), parent_window, + xcb_change_window_attributes(x11_connection_.get(), parent_window_, XCB_CW_EVENT_MASK, &parent_event_mask); - xcb_change_window_attributes(x11_connection.get(), wrapper_window.window, + xcb_change_window_attributes(x11_connection_.get(), wrapper_window_.window_, XCB_CW_EVENT_MASK, &wrapper_event_mask); - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); // First reparent our dumb wrapper window to the host's window, and then // embed the Wine window into our wrapper window - do_reparent(wrapper_window.window, parent_window); - xcb_map_window(x11_connection.get(), wrapper_window.window); - xcb_flush(x11_connection.get()); + do_reparent(wrapper_window_.window_, parent_window_); + xcb_map_window(x11_connection_.get(), wrapper_window_.window_); + xcb_flush(x11_connection_.get()); - if (use_xembed) { + if (use_xembed_) { // This call alone doesn't do anything. We need to call this function a // second time on visibility change because Wine's XEmbed implementation // does not work properly (which is why we remvoed XEmbed support in the @@ -422,14 +425,14 @@ Editor::Editor(MainContext& main_context, // of using the XEmbed protocol, we'll register a few events and manage // the child window ourselves. This is a hack to work around the issue's // described in `Editor`'s docstring'. - do_reparent(wine_window, wrapper_window.window); + do_reparent(wine_window_, wrapper_window_.window_); - ShowWindow(win32_window.handle, SW_SHOWNORMAL); + ShowWindow(win32_window_.handle_, SW_SHOWNORMAL); } } void Editor::resize(uint16_t width, uint16_t height) { - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: Resizing wrapper window to " + std::to_string(width) + "x" + std::to_string(height); }); @@ -437,9 +440,9 @@ void Editor::resize(uint16_t width, uint16_t height) { const uint16_t value_mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; const std::array values{width, height}; - xcb_configure_window(x11_connection.get(), wrapper_window.window, + xcb_configure_window(x11_connection_.get(), wrapper_window_.window_, value_mask, values.data()); - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); // When the `editor_coordinate_hack` option is enabled, we will make sure // that the window is actually placed at (0, 0) coordinates. Otherwise some @@ -448,11 +451,11 @@ void Editor::resize(uint16_t width, uint16_t height) { // because they look at the (top level) window's screen coordinates instead // of their own relative coordinates. We don't do by default as this also // interferes with resize handles. - if (use_coordinate_hack) { - logger.log_editor_trace([]() { + if (use_coordinate_hack_) { + logger_.log_editor_trace([]() { return "DEBUG: Resetting Wine window position back to (0, 0)"; }); - SetWindowPos(win32_window.handle, nullptr, 0, 0, 0, 0, + SetWindowPos(win32_window_.handle_, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOOWNERZORDER | SWP_DEFERERASE); @@ -467,12 +470,12 @@ void Editor::resize(uint16_t width, uint16_t height) { void Editor::handle_x11_events() noexcept { // NOTE: Ardour will unmap the window instead of closing the editor. When - // the window is unmapped `wine_window` doesn't exist and any X11 + // the window is unmapped `wine_window_` doesn't exist and any X11 // function calls involving it will fail. All functions called from // here should be able to handle that cleanly. try { std::unique_ptr generic_event; - while (generic_event.reset(xcb_poll_for_event(x11_connection.get())), + while (generic_event.reset(xcb_poll_for_event(x11_connection_.get())), generic_event != nullptr) { const uint8_t event_type = generic_event->response_type & xcb_event_type_mask; @@ -481,17 +484,17 @@ void Editor::handle_x11_events() noexcept { switch (event_type) { // NOTE: When reopening a closed editor window in REAPER, REAPER // will initialize the editor first, and only then will it - // reparent `parent_window` to a new FX window. This means - // that `host_window` will be the same as `parent_window` - // in REAPER if you reopen a plugin GUI, which breaks our - // input focus handling. To work around this, we will just - // check if the host's window has changed whenever the - // parent window gets reparented. + // reparent `parent_window_` to a new FX window. This + // means that `host_window_` will be the same as + // `parent_window_` in REAPER if you reopen a plugin GUI, + // which breaks our input focus handling. To work around + // this, we will just check if the host's window has + // changed whenever the parent window gets reparented. case XCB_REPARENT_NOTIFY: { const auto event = reinterpret_cast( generic_event.get()); - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: ReparentNotify for window " + std::to_string(event->window) + " to new parent " + @@ -505,8 +508,8 @@ void Editor::handle_x11_events() noexcept { // We're listening for `ConfigureNotify` events on the host's // window (i.e. the window that's actually going to get dragged // around the by the user). In most cases this is the same as - // `parent_window`. When either this window gets moved, or when - // the user moves his mouse over our window, the local + // `parent_window_`. When either this window gets moved, or + // when the user moves his mouse over our window, the local // coordinates should be updated. The additional `EnterWindow` // check is sometimes necessary for using multiple editor // windows within a single plugin group. @@ -514,15 +517,15 @@ void Editor::handle_x11_events() noexcept { const auto event = reinterpret_cast( generic_event.get()); - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: ConfigureNotify for window " + std::to_string(event->window); }); - if (event->window == host_window || - event->window == parent_window || - event->window == wrapper_window.window) { - if (!use_xembed) { + if (event->window == host_window_ || + event->window == parent_window_ || + event->window == wrapper_window_.window_) { + if (!use_xembed_) { fix_local_coordinates(); } } @@ -534,14 +537,14 @@ void Editor::handle_x11_events() noexcept { const auto event = reinterpret_cast( generic_event.get()); - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: VisibilityNotify for window " + std::to_string(event->window); }); - if (event->window == host_window || - event->window == parent_window) { - if (use_xembed) { + if (event->window == host_window_ || + event->window == parent_window_) { + if (use_xembed_) { do_xembed(); } } @@ -564,7 +567,7 @@ void Editor::handle_x11_events() noexcept { : reinterpret_cast( generic_event.get()) ->event; - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: "s + (event_type == XCB_ENTER_NOTIFY ? "EnterNotify" : "FocusIn") + @@ -575,9 +578,9 @@ void Editor::handle_x11_events() noexcept { ")"; }); - if (window == parent_window || - window == wrapper_window.window) { - if (!use_xembed) { + if (window == parent_window_ || + window == wrapper_window_.window_) { + if (!use_xembed_) { fix_local_coordinates(); } @@ -617,14 +620,14 @@ void Editor::handle_x11_events() noexcept { // // This function is sadly not exposed, so instead we // will get the root window cursor position, and then - // add to that the difference between `wine_window`'s + // add to that the difference between `wine_window_`'s // root-relative X11 position and its Win32 position. // The alternative is sleeping for 100 milliseconds, // but this is faster. const std::optional windows_pointer_pos = get_current_pointer_position(); - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { std::ostringstream message; message << "DEBUG: LeaveNotify for window " << event->child; @@ -660,7 +663,7 @@ void Editor::handle_x11_events() noexcept { // with an actual Win32 dropdown menu). Without this check // these fake dropdowns would immediately close when // hovering over them. - if (event->child == wrapper_window.window && + if (event->child == wrapper_window_.window_ && supports_ewmh_active_window() && is_wine_window_active() && !is_cursor_in_wine_window(windows_pointer_pos)) { @@ -680,7 +683,7 @@ void Editor::handle_x11_events() noexcept { xcb_key_release_event_t>); const auto event = reinterpret_cast( generic_event.get()); - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: "s + (is_synthetic_event ? "synthetic " : "") + (event_type == XCB_KEY_PRESS ? "KeyPress" @@ -691,7 +694,7 @@ void Editor::handle_x11_events() noexcept { }); if (is_synthetic_event && - event->event == wrapper_window.window) { + event->event == wrapper_window_.window_) { const uint32_t event_mask = event_type == XCB_KEY_PRESS ? XCB_EVENT_MASK_KEY_PRESS @@ -703,16 +706,16 @@ void Editor::handle_x11_events() noexcept { // needed, but it feels like the right thing to do. All // other fields can stay the same. event->response_type = event_type; - event->event = wine_window; + event->event = wine_window_; - xcb_send_event(x11_connection.get(), true, wine_window, - event_mask, + xcb_send_event(x11_connection_.get(), true, + wine_window_, event_mask, reinterpret_cast(event)); - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); } } break; default: { - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: Unhandled X11 event " + std::to_string(event_type); }); @@ -725,11 +728,11 @@ void Editor::handle_x11_events() noexcept { } HWND Editor::get_win32_handle() const noexcept { - return win32_window.handle; + return win32_window_.handle_; } void Editor::fix_local_coordinates() const { - if (use_xembed) { + if (use_xembed_) { return; } @@ -744,7 +747,7 @@ void Editor::fix_local_coordinates() const { // window created by the plugin itself. In this case it doesn't matter that // the Win32 window is larger than the part of the client area the plugin // draws to since any excess will be clipped off by the parent window. - const xcb_window_t root = get_root_window(*x11_connection, parent_window); + const xcb_window_t root = get_root_window(*x11_connection_, parent_window_); // We can't directly use the `event.x` and `event.y` coordinates because the // parent window may also be embedded inside another window. @@ -752,41 +755,41 @@ void Editor::fix_local_coordinates() const { // plugins they forgot to add a separate parent window that's already // offset correctly. Instead, they'll have the plugin embed itself // inside directly inside of the dialog, and Waveform then moves the - // window 27 pixels down. That's why we cannot use `parent_window` + // window 27 pixels down. That's why we cannot use `parent_window_` // here. xcb_generic_error_t* error = nullptr; const xcb_translate_coordinates_cookie_t translate_cookie = - xcb_translate_coordinates(x11_connection.get(), wrapper_window.window, - root, 0, 0); + xcb_translate_coordinates(x11_connection_.get(), + wrapper_window_.window_, root, 0, 0); const std::unique_ptr translated_coordinates(xcb_translate_coordinates_reply( - x11_connection.get(), translate_cookie, &error)); + x11_connection_.get(), translate_cookie, &error)); THROW_X11_ERROR(error); xcb_configure_notify_event_t translated_event{}; translated_event.response_type = XCB_CONFIGURE_NOTIFY; - translated_event.event = wine_window; - translated_event.window = wine_window; + translated_event.event = wine_window_; + translated_event.window = wine_window_; // This should be set to the same sizes the window was created on. Since // we're not using `SetWindowPos` to resize the Window, Wine can get a bit // confused when we suddenly report a different client area size. Without // this certain plugins (such as those by Valhalla DSP) would break. - translated_event.width = client_area.width; - translated_event.height = client_area.height; + translated_event.width = client_area_.width; + translated_event.height = client_area_.height; translated_event.x = translated_coordinates->dst_x; translated_event.y = translated_coordinates->dst_y; - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: Spoofing local coordinates to (" + std::to_string(translated_event.x) + ", " + std::to_string(translated_event.y) + ")"; }); xcb_send_event( - x11_connection.get(), false, wine_window, + x11_connection_.get(), false, wine_window_, XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY, reinterpret_cast(&translated_event)); - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); } void Editor::set_input_focus(bool grab) const { @@ -798,36 +801,36 @@ void Editor::set_input_focus(bool grab) const { // properly, as they don't grab input focus themselves. const xcb_window_t focus_target = grab ? (get_active_modifiers().value_or(0) & XCB_MOD_MASK_SHIFT - ? wine_window - : parent_window) - : host_window; + ? wine_window_ + : parent_window_) + : host_window_; xcb_generic_error_t* error = nullptr; const xcb_get_input_focus_cookie_t focus_cookie = - xcb_get_input_focus(x11_connection.get()); + xcb_get_input_focus(x11_connection_.get()); const std::unique_ptr focus_reply( - xcb_get_input_focus_reply(x11_connection.get(), focus_cookie, &error)); + xcb_get_input_focus_reply(x11_connection_.get(), focus_cookie, &error)); THROW_X11_ERROR(error); // Calling `set_input_focus(true)` can trigger another `FocusIn` event, // which will then once again call `set_input_focus(true)`. To work around // this we prevent unnecessary repeat keyboard focus grabs. One thing that // slightly complicates this is the use of unmapped input proxy windows. - // When `host_window` gets foccused, some hosts will reassign input focus to - // such a proxy window. To avoid fighting over focus, when grabbing focus we - // don't just check whether `current_focus` and `focus_target` are the same - // window but we'll also allow `current_focus` to be a child of + // When `host_window_` gets foccused, some hosts will reassign input focus + // to such a proxy window. To avoid fighting over focus, when grabbing focus + // we don't just check whether `current_focus` and `focus_target` are the + // same window but we'll also allow `current_focus` to be a child of // `focus_target`. const xcb_window_t current_focus = focus_reply->focus; if (current_focus == focus_target || - (grab && is_child_window_or_same(*x11_connection, current_focus, + (grab && is_child_window_or_same(*x11_connection_, current_focus, focus_target))) { - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { std::string reason = "unknown reason"; if (current_focus == focus_target) { reason = "already focused"; } else if (grab && - is_child_window_or_same(*x11_connection, current_focus, + is_child_window_or_same(*x11_connection_, current_focus, focus_target)) { reason = "current focus " + std::to_string(current_focus) + " is a child of " + std::to_string(focus_target); @@ -841,7 +844,7 @@ void Editor::set_input_focus(bool grab) const { } // Explicitly request input focus when the user interacts with the window. - // Without this, `host_window` will capture all keyboard events in most + // Without this, `host_window_` will capture all keyboard events in most // hosts. Ideally we would just do this whenever the child window calls // `SetFocus()` (or no handling should be necessary), but as far as I'm // aware there is no way to do this. Right now we will grab input focus when @@ -854,33 +857,33 @@ void Editor::set_input_focus(bool grab) const { // `IPlugView::onKey{Down,Up}` should handle all keyboard events. But // in practice a lot of hosts don't use that, so we still need to grab // focus ourselves. - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: Setting input focus to window " + std::to_string(focus_target); }); - xcb_set_input_focus(x11_connection.get(), XCB_INPUT_FOCUS_PARENT, + xcb_set_input_focus(x11_connection_.get(), XCB_INPUT_FOCUS_PARENT, focus_target, XCB_CURRENT_TIME); - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); } void Editor::run_timer_proc() { - idle_timer_proc(); + idle_timer_proc_(); } std::optional Editor::get_active_modifiers() const noexcept { xcb_generic_error_t* error = nullptr; const xcb_query_pointer_cookie_t query_pointer_cookie = - xcb_query_pointer(x11_connection.get(), wine_window); + xcb_query_pointer(x11_connection_.get(), wine_window_); const std::unique_ptr query_pointer_reply( - xcb_query_pointer_reply(x11_connection.get(), query_pointer_cookie, + xcb_query_pointer_reply(x11_connection_.get(), query_pointer_cookie, &error)); if (error) { free(error); return std::nullopt; } - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: Active keyboard modifiers: " + std::to_string(query_pointer_reply->mask); }); @@ -891,9 +894,9 @@ std::optional Editor::get_active_modifiers() const noexcept { std::optional Editor::get_current_pointer_position() const noexcept { xcb_generic_error_t* error = nullptr; const xcb_query_pointer_cookie_t query_pointer_cookie = - xcb_query_pointer(x11_connection.get(), wine_window); + xcb_query_pointer(x11_connection_.get(), wine_window_); const std::unique_ptr query_pointer_reply( - xcb_query_pointer_reply(x11_connection.get(), query_pointer_cookie, + xcb_query_pointer_reply(x11_connection_.get(), query_pointer_cookie, &error)); if (error) { free(error); @@ -901,19 +904,19 @@ std::optional Editor::get_current_pointer_position() const noexcept { } // We know the mouse coordinates relative to the root window, and we know - // the mouse coordinates relative to `wine_window`, so we can skip a request - // by calculating Wine window's coordinates ourself. + // the mouse coordinates relative to `wine_window_`, so we can skip a + // request by calculating Wine window's coordinates ourself. const uint16_t x11_x_pos = query_pointer_reply->root_x - query_pointer_reply->win_x; const uint16_t x11_y_pos = query_pointer_reply->root_y - query_pointer_reply->win_y; // We need to offset the root-relative pointer position with the difference - // between `wine_window`'s X11 and Win32 coordinates. Wine sadly does not + // between `wine_window_`'s X11 and Win32 coordinates. Wine sadly does not // expose a function that just lets us translate X11 coordinates into // Windows coordinates. RECT win32_pos{}; - if (!GetWindowRect(win32_window.handle, &win32_pos)) { + if (!GetWindowRect(win32_window_.handle_, &win32_pos)) { return std::nullopt; } @@ -932,85 +935,87 @@ bool Editor::is_wine_window_active() const { // change when the window gets moved to another screen, so we won't cache // this). const xcb_window_t root_window = - get_root_window(*x11_connection, wine_window); + get_root_window(*x11_connection_, wine_window_); xcb_generic_error_t* error = nullptr; const xcb_get_property_cookie_t property_cookie = - xcb_get_property(x11_connection.get(), false, root_window, - active_window_property, XCB_ATOM_WINDOW, 0, 1); + xcb_get_property(x11_connection_.get(), false, root_window, + active_window_property_, XCB_ATOM_WINDOW, 0, 1); const std::unique_ptr property_reply( - xcb_get_property_reply(x11_connection.get(), property_cookie, &error)); + xcb_get_property_reply(x11_connection_.get(), property_cookie, &error)); THROW_X11_ERROR(error); const xcb_window_t active_window = *static_cast( xcb_get_property_value(property_reply.get())); - return is_child_window_or_same(*x11_connection, wine_window, active_window); + return is_child_window_or_same(*x11_connection_, wine_window_, + active_window); } void Editor::redetect_host_window() noexcept { const xcb_window_t new_host_window = - find_host_window(*x11_connection, parent_window, xcb_wm_state_property) - .value_or(parent_window); - if (new_host_window == host_window) { + find_host_window(*x11_connection_, parent_window_, + xcb_wm_state_property_) + .value_or(parent_window_); + if (new_host_window == host_window_) { return; } - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: new host_window: " + std::to_string(new_host_window); }); // We need to readjust the event masks for the new host window, keeping the // (very probable) possibility in mind that the old host window is the same // as the parent window or that the parent window now is the host window. - if (host_window != parent_window) { + if (host_window_ != parent_window_) { constexpr uint32_t no_event_mask = XCB_EVENT_MASK_NO_EVENT; - xcb_change_window_attributes(x11_connection.get(), host_window, + xcb_change_window_attributes(x11_connection_.get(), host_window_, XCB_CW_EVENT_MASK, &no_event_mask); } - if (new_host_window == parent_window) { - xcb_change_window_attributes(x11_connection.get(), new_host_window, + if (new_host_window == parent_window_) { + xcb_change_window_attributes(x11_connection_.get(), new_host_window, XCB_CW_EVENT_MASK, &parent_event_mask); } else { - xcb_change_window_attributes(x11_connection.get(), new_host_window, + xcb_change_window_attributes(x11_connection_.get(), new_host_window, XCB_CW_EVENT_MASK, &host_event_mask); } - host_window = new_host_window; - xcb_flush(x11_connection.get()); + host_window_ = new_host_window; + xcb_flush(x11_connection_.get()); } bool Editor::supports_ewmh_active_window() const { - if (supports_ewmh_active_window_cache) { - return *supports_ewmh_active_window_cache; + if (supports_ewmh_active_window_cache_) { + return *supports_ewmh_active_window_cache_; } // It could be that the `_NET_ACTIVE_WINDOW` atom exists (because it was // created by another application) but that the root window does not have // the property - if (active_window_property == XCB_ATOM_NONE) { - supports_ewmh_active_window_cache = false; + if (active_window_property_ == XCB_ATOM_NONE) { + supports_ewmh_active_window_cache_ = false; return false; } const xcb_window_t root_window = - get_root_window(*x11_connection, wine_window); + get_root_window(*x11_connection_, wine_window_); // If the `_NET_ACTIVE_WINDOW` property does not exist on the root window, // the returned property type will be `XCB_ATOM_NONE` as specified in the // X11 manual xcb_generic_error_t* error = nullptr; const xcb_get_property_cookie_t property_cookie = - xcb_get_property(x11_connection.get(), false, root_window, - active_window_property, XCB_ATOM_WINDOW, 0, 1); + xcb_get_property(x11_connection_.get(), false, root_window, + active_window_property_, XCB_ATOM_WINDOW, 0, 1); const std::unique_ptr property_reply( - xcb_get_property_reply(x11_connection.get(), property_cookie, &error)); + xcb_get_property_reply(x11_connection_.get(), property_cookie, &error)); THROW_X11_ERROR(error); const bool active_window_property_exists = property_reply->type != XCB_ATOM_NONE; - supports_ewmh_active_window_cache = active_window_property_exists; + supports_ewmh_active_window_cache_ = active_window_property_exists; return active_window_property_exists; } @@ -1023,7 +1028,7 @@ void Editor::send_xembed_message(xcb_window_t window, uint32_t data2) const noexcept { xcb_client_message_event_t event{}; event.response_type = XCB_CLIENT_MESSAGE; - event.type = xcb_xembed_message; + event.type = xcb_xembed_message_; event.window = window; event.format = 32; event.data.data32[0] = XCB_CURRENT_TIME; @@ -1032,15 +1037,15 @@ void Editor::send_xembed_message(xcb_window_t window, event.data.data32[3] = data1; event.data.data32[4] = data2; - xcb_send_event(x11_connection.get(), false, window, XCB_EVENT_MASK_NO_EVENT, - reinterpret_cast(&event)); + xcb_send_event(x11_connection_.get(), false, window, + XCB_EVENT_MASK_NO_EVENT, reinterpret_cast(&event)); } void Editor::do_reparent(xcb_window_t child, xcb_window_t new_parent) const { const xcb_void_cookie_t reparent_cookie = xcb_reparent_window_checked( - x11_connection.get(), child, new_parent, 0, 0); + x11_connection_.get(), child, new_parent, 0, 0); if (std::unique_ptr reparent_error( - xcb_request_check(x11_connection.get(), reparent_cookie)); + xcb_request_check(x11_connection_.get(), reparent_cookie)); reparent_error) { // When the reparent fails, we always want to log this, regardless of // whether or not `YABRIDGE_DEBUG_LEVEL` contains `+editor` @@ -1057,9 +1062,9 @@ void Editor::do_reparent(xcb_window_t child, xcb_window_t new_parent) const { // fail according to the spec in advance xcb_generic_error_t* error = nullptr; const xcb_query_pointer_cookie_t query_pointer_cookie = - xcb_query_pointer(x11_connection.get(), child); + xcb_query_pointer(x11_connection_.get(), child); const std::unique_ptr query_pointer_reply( - xcb_query_pointer_reply(x11_connection.get(), query_pointer_cookie, + xcb_query_pointer_reply(x11_connection_.get(), query_pointer_cookie, &error)); if (error) { free(error); @@ -1076,37 +1081,37 @@ void Editor::do_reparent(xcb_window_t child, xcb_window_t new_parent) const { } } } else { - logger.log_editor_trace([&]() { + logger_.log_editor_trace([&]() { return "DEBUG: Reparenting " + std::to_string(child) + " to " + std::to_string(new_parent) + " succeeded"; }); } - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); } void Editor::do_xembed() const { - if (!use_xembed) { + if (!use_xembed_) { return; } // If we're embedding using XEmbed, then we'll have to go through the whole // XEmbed dance here. See the spec for more information on how this works: // https://specifications.freedesktop.org/xembed-spec/xembed-spec-latest.html#lifecycle - do_reparent(wine_window, wrapper_window.window); + do_reparent(wine_window_, wrapper_window_.window_); // Let the Wine window know it's being embedded into the parent window - send_xembed_message(wine_window, xembed_embedded_notify_msg, 0, - wrapper_window.window, xembed_protocol_version); - send_xembed_message(wine_window, xembed_focus_in_msg, xembed_focus_first, 0, - 0); - send_xembed_message(wine_window, xembed_window_activate_msg, 0, 0, 0); - xcb_flush(x11_connection.get()); + send_xembed_message(wine_window_, xembed_embedded_notify_msg, 0, + wrapper_window_.window_, xembed_protocol_version); + send_xembed_message(wine_window_, xembed_focus_in_msg, xembed_focus_first, + 0, 0); + send_xembed_message(wine_window_, xembed_window_activate_msg, 0, 0, 0); + xcb_flush(x11_connection_.get()); - xcb_map_window(x11_connection.get(), wine_window); - xcb_flush(x11_connection.get()); + xcb_map_window(x11_connection_.get(), wine_window_); + xcb_flush(x11_connection_.get()); - ShowWindow(win32_window.handle, SW_SHOWNORMAL); + ShowWindow(win32_window_.handle_, SW_SHOWNORMAL); } LRESULT CALLBACK window_proc(HWND handle, @@ -1137,7 +1142,7 @@ LRESULT CALLBACK window_proc(HWND handle, case WM_WINDOWPOSCHANGING: { auto editor = reinterpret_cast( GetWindowLongPtr(handle, GWLP_USERDATA)); - if (!editor || editor->use_xembed) { + if (!editor || editor->use_xembed_) { break; } @@ -1190,7 +1195,7 @@ LRESULT CALLBACK window_proc(HWND handle, } } break; // NOTE: Needed for our `is_cursor_in_wine_window()` implementation. Our - // `win32_window` extends way past the visible plugin GUI. And + // `win32_window_` extends way past the visible plugin GUI. And // even though it will appear nicely clipped on screen, // `WindowFromPoint()` would still return our window when hovering // to the right or bottom of a plugin GUI, even if there's another diff --git a/src/wine-host/editor.h b/src/wine-host/editor.h index c072f4c4..f5275b7b 100644 --- a/src/wine-host/editor.h +++ b/src/wine-host/editor.h @@ -43,7 +43,7 @@ constexpr uint8_t xcb_event_type_mask = 0b0111'1111; /** * The name of the X11 property that indicates whether a window supports * drag-and-drop. If the `editor_force_dnd` option is enabled we'll remove this - * property from all of `parent_window`'s ancestors to work around a bug in + * property from all of `parent_window_`'s ancestors to work around a bug in * REAPER. */ constexpr char xdnd_aware_property_name[] = "XdndAware"; @@ -108,16 +108,16 @@ class DeferredWin32Window { HWND window) noexcept; /** - * Post a `WM_CLOSE` message to the `handle`'s message queue as described + * Post a `WM_CLOSE` message to the `handle_`'s message queue as described * above. */ ~DeferredWin32Window() noexcept; - const HWND handle; + const HWND handle_; private: - MainContext& main_context; - std::shared_ptr x11_connection; + MainContext& main_context_; + std::shared_ptr x11_connection_; }; /** @@ -141,7 +141,7 @@ class DeferredWin32Window { * because of the issues mentioned above. * * In yabridge 3.5.0 we added another layer to the embedding structure. This is - * to prevent the host from directly using the size of `wine_window`, which has + * to prevent the host from directly using the size of `wine_window_`, which has * a client area the size of the entire root window so the window can resized * and fullscreened at will. Some hosts, like Carla 2.3.1 (this didn't happen in * earlier versions), may directly resize their editor window depending on the @@ -179,7 +179,7 @@ class Editor { * plugins to periodically call `effEditIdle` from the message loop * thread, even when the GUI is blocked. * - * @see win32_window + * @see win32_window_ */ Editor( MainContext& main_context, @@ -189,7 +189,7 @@ class Editor { std::optional> timer_proc = std::nullopt); /** - * Resize the `wrapper_window` to this new size. We need to manually call + * Resize the `wrapper_window_` to this new size. We need to manually call * this whenever the plugin requests a resize, or when the host resizes the * window (using the plugin API). Before yabridge 3.5.0 this was implicit. */ @@ -232,8 +232,8 @@ class Editor { * * NOTE: There's a little bit of special behaviour in here. When the shift * key is held while grabbing input focus, then we'll focus - * `wine_window` directly instead of focussing `wrapper_window`. This - * allows you to temporarily override the default focus grabbing + * `wine_window_` directly instead of focussing `wrapper_window_`. + * This allows you to temporarily override the default focus grabbing * behaviour, allowing you to use the space key in plugins GUIs in * Bitwig and to enter text in Voxengo settings and license dialogs. * This can also help with plugins that use popups but still rely on @@ -241,7 +241,7 @@ class Editor { * popups. * * @param grab Whether to grab input focus (if `true`) or to give back input - * focus to `host_window` (if `false`). + * focus to `host_window_` (if `false`). */ void set_input_focus(bool grab) const; @@ -249,23 +249,23 @@ class Editor { * Run the X11 event loop plus the timer proc function passed to the * constructor, if one was passed. * - * @see idle_timer - * @see idle_timer_proc + * @see idle_timer_ + * @see idle_timer_proc_ */ void run_timer_proc(); /** - * Whether to reposition `win32_window` to (0, 0) every time the window + * Whether to reposition `win32_window_` to (0, 0) every time the window * resizes. This can help with buggy plugins that use the (top level) * window's screen coordinates when drawing their GUI. */ - const bool use_coordinate_hack = false; + const bool use_coordinate_hack_; /** * Whether to use XEmbed instead of yabridge's normal window embedded. Wine * with XEmbed tends to cause rendering issues, so it's disabled by default. */ - const bool use_xembed = false; + const bool use_xembed_; private: /** @@ -280,7 +280,7 @@ class Editor { * Get the current cursor position, in Win32 screen coordinates. This is * needed for our `LeaveNotify` handling because `GetCursorPos()` only * updates once every 100 ms. This takes the X11 mouse cursor position, and - * then adds to that the difference between `wine_window`'s X11 coordinates + * then adds to that the difference between `wine_window_`'s X11 coordinates * and its Win32 coordinates. This is kind of a workaround for Wine's * X11drv's `root_to_virtual_screen()` function not being exposed. * @@ -290,7 +290,7 @@ class Editor { /** * Returns `true` if the currently active window (as per - * `_NET_ACTIVE_WINDOW`) contains `wine_window`. If the window manager does + * `_NET_ACTIVE_WINDOW`) contains `wine_window_`. If the window manager does * not support this hint, this will always return false. * * @see Editor::supports_ewmh_active_window @@ -298,7 +298,7 @@ class Editor { bool is_wine_window_active() const; /** - * After `parent_window` gets reparented, we may need to redetect which + * After `parent_window_` gets reparented, we may need to redetect which * toplevel-ish window the host is using and adjust the events we're * subscribed to accordingly. */ @@ -322,7 +322,7 @@ class Editor { void do_reparent(xcb_window_t child, xcb_window_t new_parent) const; /** - * Start the XEmbed procedure when `use_xembed` is enabled. This should be + * Start the XEmbed procedure when `use_xembed_` is enabled. This should be * rerun whenever visibility changes. */ void do_xembed() const; @@ -330,18 +330,18 @@ class Editor { /** * The logger instance we will print debug tracing information to. */ - Logger& logger; + Logger& logger_; /** * Every editor window gets its own X11 connection. */ - std::shared_ptr x11_connection; + std::shared_ptr x11_connection_; /** * A handle for our Wine->X11 drag-and-drop proxy. We only have one of these * per process, and it gets freed again when the last handle gets dropped. */ - WineXdndProxy::Handle dnd_proxy_handle; + WineXdndProxy::Handle dnd_proxy_handle_; /** * The Wine window's client area, or the maximum size of that window. This @@ -352,61 +352,61 @@ class Editor { * the host resize the X11 parent window it's been embedded in instead, * resizing will feel smooth and native. */ - const Size client_area; + const Size client_area_; /** * The handle for the window created through Wine that the plugin uses to * embed itself in. */ - DeferredWin32Window win32_window; + DeferredWin32Window win32_window_; /** * A timer we'll use to periodically run the X11 event loop plus - * `idle_timer_proc`, if that is set. We handle X11 events from within the + * `idle_timer_proc_`, if that is set. We handle X11 events from within the * Win32 event loop because that allows us to still process those while the * GUI is blocked. Additionally for VST2 plugins we also need this - * `idle_timer_proc`, as they expected the host to periodically send an idle - * event. We used to just pass through the calls from the host before + * `idle_timer_proc_`, as they expected the host to periodically send an + * idle event. We used to just pass through the calls from the host before * yabridge 3.x, but doing it ourselves here makes things m much more * manageable and we'd still need a timer anyways for when the GUI is * blocked. */ - Win32Timer idle_timer; + Win32Timer idle_timer_; /** * A function to call when the Win32 timer procs. This is used to * periodically call `handle_x11_events()`, as well as `effEditIdle()` for * VST2 plugins even if the GUI is being blocked. */ - fu2::unique_function idle_timer_proc; + fu2::unique_function idle_timer_proc_; /** * The atom corresponding to `WM_STATE`. */ - xcb_atom_t xcb_wm_state_property; + xcb_atom_t xcb_wm_state_property_; /** * The window handle of the editor window created by the DAW. */ - const xcb_window_t parent_window; + const xcb_window_t parent_window_; /** - * A window that sits between `parent_window` and `wine_window`. The entire - * purpose of this is to prevent the host from responding to the - * `ConfigureNotify` events we send to `wine_window` when the host - * subscribes to `SubStructureNotify` events on `parent_window`. + * A window that sits between `parent_window_` and `wine_window_`. The + * entire purpose of this is to prevent the host from responding to the + * `ConfigureNotify` events we send to `wine_window_` when the host + * subscribes to `SubStructureNotify` events on `parent_window_`. */ - X11Window wrapper_window; + X11Window wrapper_window_; /** - * The X11 window handle of the window belonging to `win32_window`. + * The X11 window handle of the window belonging to `win32_window_`. */ - const xcb_window_t wine_window; + const xcb_window_t wine_window_; /** - * The toplevel X11 window `parent_window` is contained in, or - * `parent_window` if the host doesn't do any fancy window embedding. We'll - * find this by looking for the topmost ancestor window of `parent_window` + * The toplevel X11 window `parent_window_` is contained in, or + * `parent_window_` if the host doesn't do any fancy window embedding. We'll + * find this by looking for the topmost ancestor window of `parent_window_` * that has `WM_STATE` set. This is similar to how `xprop` and `xwininfo` * select windows. In most cases this is going to be the same as - * `parent_window`, but some DAWs (such as REAPER) embed `parent_window` + * `parent_window_`, but some DAWs (such as REAPER) embed `parent_window_` * into another window. We have to listen for configuration changes on this * topmost window to know when the window is being dragged around, and when * returning keyboard focus to the host we'll focus this window. @@ -420,21 +420,21 @@ class Editor { * reason REAPER will only process keyboard input for that window when * the mouse is within the window. */ - xcb_window_t host_window; + xcb_window_t host_window_; /** * The atom corresponding to `_NET_ACTIVE_WINDOW`. */ - xcb_atom_t active_window_property; + xcb_atom_t active_window_property_; /** * Whether the root window supports the `_NET_ACTIVE_WINDOW` hint. We'll * check this once and then cache the results in * `supports_ewmh_active_window()`. */ - mutable std::optional supports_ewmh_active_window_cache; + mutable std::optional supports_ewmh_active_window_cache_; /** * The atom corresponding to `_XEMBED`. */ - xcb_atom_t xcb_xembed_message; + xcb_atom_t xcb_xembed_message_; }; diff --git a/src/wine-host/utils.cpp b/src/wine-host/utils.cpp index 797689df..2e8638df 100644 --- a/src/wine-host/utils.cpp +++ b/src/wine-host/utils.cpp @@ -30,22 +30,22 @@ win32_thread_trampoline(fu2::unique_function* entry_point) { return 0; } -Win32Thread::Win32Thread() noexcept : handle(nullptr, nullptr) {} +Win32Thread::Win32Thread() noexcept : handle_(nullptr, nullptr) {} Win32Thread::~Win32Thread() noexcept { - if (handle) { - WaitForSingleObject(handle.get(), INFINITE); + if (handle_) { + WaitForSingleObject(handle_.get(), INFINITE); } } Win32Thread::Win32Thread(Win32Thread&& o) noexcept - : handle(std::move(o.handle)) { - o.handle.reset(); + : handle_(std::move(o.handle_)) { + o.handle_.reset(); } Win32Thread& Win32Thread::operator=(Win32Thread&& o) noexcept { - handle = std::move(o.handle); - o.handle.reset(); + handle_ = std::move(o.handle_); + o.handle_.reset(); return *this; } @@ -55,41 +55,41 @@ Win32Timer::Win32Timer() noexcept {} Win32Timer::Win32Timer(HWND window_handle, size_t timer_id, unsigned int interval_ms) noexcept - : window_handle(window_handle), timer_id(timer_id) { + : window_handle_(window_handle), timer_id_(timer_id) { SetTimer(window_handle, timer_id, interval_ms, nullptr); } Win32Timer::~Win32Timer() noexcept { - if (timer_id) { - KillTimer(window_handle, *timer_id); + if (timer_id_) { + KillTimer(window_handle_, *timer_id_); } } Win32Timer::Win32Timer(Win32Timer&& o) noexcept - : window_handle(o.window_handle), timer_id(std::move(o.timer_id)) { - o.timer_id.reset(); + : window_handle_(o.window_handle_), timer_id_(std::move(o.timer_id_)) { + o.timer_id_.reset(); } Win32Timer& Win32Timer::operator=(Win32Timer&& o) noexcept { - window_handle = o.window_handle; - timer_id = std::move(o.timer_id); - o.timer_id.reset(); + window_handle_ = o.window_handle_; + timer_id_ = std::move(o.timer_id_); + o.timer_id_.reset(); return *this; } MainContext::MainContext() - : context(), - events_timer(context), - watchdog_context(), - watchdog_timer(watchdog_context) {} + : context_(), + events_timer_(context_), + watchdog_context_(), + watchdog_timer_(watchdog_context_) {} void MainContext::run() { // We need to know which thread is the GUI thread because mutual recursion // in VST3 plugins needs to be handled differently depending on whether the // potentially mutually recursive function was called from an audio thread // or a GUI thread - gui_thread_id = GetCurrentThreadId(); + gui_thread_id_ = GetCurrentThreadId(); // NOTE: We allow disabling the watchdog timer to allow the Wine process to // be run from a separate namespace. This is not something you'd @@ -104,62 +104,62 @@ void MainContext::run() { // this we'll run the timer on a 30 second interval. async_handle_watchdog_timer(5s); - watchdog_handler = Win32Thread([&]() { + watchdog_handler_ = Win32Thread([&]() { pthread_setname_np(pthread_self(), "watchdog"); - watchdog_context.run(); + watchdog_context_.run(); }); } - context.run(); + context_.run(); // We only need to check if the host is still running while the main context // is also running. If a stop was requested, the entire application is // supposed to shut down. Otherwise `watchdog_handler` would just block on // the join as the watchdog timer is still active. - watchdog_context.stop(); + watchdog_context_.stop(); } void MainContext::stop() noexcept { - context.stop(); + context_.stop(); } void MainContext::update_timer_interval( std::chrono::steady_clock::duration new_interval) noexcept { - timer_interval = new_interval; + timer_interval_ = new_interval; } MainContext::WatchdogGuard::WatchdogGuard( HostBridge& bridge, std::unordered_set& watched_bridges, std::mutex& watched_bridges_mutex) - : bridge(&bridge), - watched_bridges(watched_bridges), - watched_bridges_mutex(watched_bridges_mutex) { + : bridge_(&bridge), + watched_bridges_(watched_bridges), + watched_bridges_mutex_(watched_bridges_mutex) { std::lock_guard lock(watched_bridges_mutex); watched_bridges.insert(&bridge); } MainContext::WatchdogGuard::~WatchdogGuard() noexcept { - if (is_active) { - std::lock_guard lock(watched_bridges_mutex.get()); - watched_bridges.get().erase(bridge); + if (is_active_) { + std::lock_guard lock(watched_bridges_mutex_.get()); + watched_bridges_.get().erase(bridge_); } } MainContext::WatchdogGuard::WatchdogGuard(WatchdogGuard&& o) noexcept - : bridge(std::move(o.bridge)), - watched_bridges(std::move(o.watched_bridges)), - watched_bridges_mutex(std::move(o.watched_bridges_mutex)) { - o.is_active = false; + : bridge_(std::move(o.bridge_)), + watched_bridges_(std::move(o.watched_bridges_)), + watched_bridges_mutex_(std::move(o.watched_bridges_mutex_)) { + o.is_active_ = false; } MainContext::WatchdogGuard& MainContext::WatchdogGuard::operator=( WatchdogGuard&& o) noexcept { - bridge = std::move(o.bridge); - watched_bridges = std::move(o.watched_bridges); - watched_bridges_mutex = std::move(o.watched_bridges_mutex); - o.is_active = false; + bridge_ = std::move(o.bridge_); + watched_bridges_ = std::move(o.watched_bridges_); + watched_bridges_mutex_ = std::move(o.watched_bridges_mutex_); + o.is_active_ = false; return *this; } @@ -167,15 +167,15 @@ MainContext::WatchdogGuard& MainContext::WatchdogGuard::operator=( MainContext::WatchdogGuard MainContext::register_watchdog(HostBridge& bridge) { // The guard's constructor and destructor will handle actually registering // and unregistering the bridge from `watched_bridges` - return WatchdogGuard(bridge, watched_bridges, watched_bridges_mutex); + return WatchdogGuard(bridge, watched_bridges_, watched_bridges_mutex_); } void MainContext::async_handle_watchdog_timer( std::chrono::steady_clock::duration interval) { // Try to keep a steady framerate, but add in delays to let other events // get handled if the GUI message handling somehow takes very long. - watchdog_timer.expires_at(std::chrono::steady_clock::now() + interval); - watchdog_timer.async_wait([&](const boost::system::error_code& error) { + watchdog_timer_.expires_at(std::chrono::steady_clock::now() + interval); + watchdog_timer_.async_wait([&](const boost::system::error_code& error) { if (error.failed()) { return; } @@ -184,8 +184,8 @@ void MainContext::async_handle_watchdog_timer( // bridge instance will be removed from `watched_bridges`. So if our // call to `HostBridge::shutdown_if_dangling()` shuts the plugin down, // the instance will be removed after this lambda exits. - std::lock_guard lock(watched_bridges_mutex); - for (auto& bridge : watched_bridges) { + std::lock_guard lock(watched_bridges_mutex_); + for (auto& bridge : watched_bridges_) { bridge->shutdown_if_dangling(); } diff --git a/src/wine-host/utils.h b/src/wine-host/utils.h index 7874c025..966a0143 100644 --- a/src/wine-host/utils.h +++ b/src/wine-host/utils.h @@ -81,24 +81,24 @@ class Win32Thread { */ template Win32Thread(Function fn, Args... args) - : handle(CreateThread( - nullptr, - 0, - reinterpret_cast( - win32_thread_trampoline), - // `std::function` does not support functions with move - // captures the function has to be copy-constructable. - // Function2's unique_function lets us capture and move our - // arguments to the lambda so we don't end up with dangling - // references. - new fu2::unique_function( - [f = std::move(fn), - ... args = std::move(args)]() mutable { - f(std::move(args)...); - }), - 0, - nullptr), - CloseHandle) {} + : handle_(CreateThread( + nullptr, + 0, + reinterpret_cast( + win32_thread_trampoline), + // `std::function` does not support functions with move + // captures the function has to be copy-constructable. + // Function2's unique_function lets us capture and move + // our arguments to the lambda so we don't end up with + // dangling references. + new fu2::unique_function( + [f = std::move(fn), + ... args = std::move(args)]() mutable { + f(std::move(args)...); + }), + 0, + nullptr), + CloseHandle) {} /** * Join (or wait on, since this is WIn32) the thread on shutdown, just like @@ -122,7 +122,7 @@ class Win32Thread { * class was constructed with the default constructor. */ std::unique_ptr, decltype(&CloseHandle)> - handle; + handle_; #pragma GCC diagnostic pop }; @@ -147,8 +147,8 @@ class Win32Timer { Win32Timer& operator=(Win32Timer&&) noexcept; private: - HWND window_handle; - std::optional timer_id; + HWND window_handle_; + std::optional timer_id_; }; /** @@ -176,7 +176,7 @@ class MainContext { /** * Drop all future work from the IO context. This does not necessarily mean - * that the thread that called `main_context.run()` immediatly returns. + * that the thread that called `main_context_.run()` immediatly returns. */ void stop() noexcept; @@ -209,19 +209,20 @@ class MainContext { /** * Used to facilitate moves. */ - bool is_active = true; + bool is_active_ = true; /** * The bridge that we will add to the watchdog list when this object * gets created, and that we'll remove from the list again when this * object gets destroyed. */ - HostBridge* bridge; + HostBridge* bridge_; // References to the same two fields on `MainContext`, so we don't have // to use `friend` - std::reference_wrapper> watched_bridges; - std::reference_wrapper watched_bridges_mutex; + std::reference_wrapper> + watched_bridges_; + std::reference_wrapper watched_bridges_mutex_; }; /** @@ -239,7 +240,7 @@ class MainContext { * that called `MainContext::run()`. */ inline bool is_gui_thread() const noexcept { - return GetCurrentThreadId() == gui_thread_id.value_or(0); + return GetCurrentThreadId() == gui_thread_id_.value_or(0); } /** @@ -253,7 +254,7 @@ class MainContext { std::packaged_task call_fn(std::forward(fn)); std::future result = call_fn.get_future(); - boost::asio::dispatch(context, std::move(call_fn)); + boost::asio::dispatch(context_, std::move(call_fn)); return result; } @@ -265,7 +266,7 @@ class MainContext { */ template void schedule_task(F&& fn) { - boost::asio::post(context, std::forward(fn)); + boost::asio::post(context_, std::forward(fn)); } /** @@ -289,10 +290,10 @@ class MainContext { void async_handle_events(F handler, P predicate) { // Try to keep a steady framerate, but add in delays to let other events // get handled if the GUI message handling somehow takes very long. - events_timer.expires_at( - std::max(events_timer.expiry() + timer_interval, - std::chrono::steady_clock::now() + timer_interval / 4)); - events_timer.async_wait( + events_timer_.expires_at( + std::max(events_timer_.expiry() + timer_interval_, + std::chrono::steady_clock::now() + timer_interval_ / 4)); + events_timer_.async_wait( [&, handler, predicate](const boost::system::error_code& error) { if (error.failed()) { return; @@ -310,7 +311,7 @@ class MainContext { * The raw IO context. Used to bind our sockets onto. Running things within * this IO context should be done with the functions above. */ - boost::asio::io_context context; + boost::asio::io_context context_; private: /** @@ -328,12 +329,12 @@ class MainContext { * The **Windows** thread ID the context is running on, which will be our * GUI thread. Will be a nullopt until `MainContext::run()` has been called. */ - std::optional gui_thread_id; + std::optional gui_thread_id_; /** * The timer used to periodically handle X11 events and Win32 messages. */ - boost::asio::steady_timer events_timer; + boost::asio::steady_timer events_timer_; /** * The time between timer ticks in `async_handle_events`. This gets @@ -342,13 +343,13 @@ class MainContext { * * @see update_timer_interval */ - std::chrono::steady_clock::duration timer_interval = + std::chrono::steady_clock::duration timer_interval_ = std::chrono::milliseconds(1000) / 60; /** * The IO context used for the watchdog described below. */ - boost::asio::io_context watchdog_context; + boost::asio::io_context watchdog_context_; /** * The timer used to periodically check if the host processes are still @@ -356,20 +357,20 @@ class MainContext { * itself) when the host has exited and the sockets are somehow not closed * yet.. */ - boost::asio::steady_timer watchdog_timer; + boost::asio::steady_timer watchdog_timer_; /** * All of the bridges we're watching as part of our watchdog. We're storing * pointers for efficiency's sake, since reference wrappers don't implement * any comparison operators. */ - std::unordered_set watched_bridges; - std::mutex watched_bridges_mutex; + std::unordered_set watched_bridges_; + std::mutex watched_bridges_mutex_; /** * The thread where we run our watchdog timer, to shut down plugins after * the native plugin host process they're supposed to be connected to has * died. */ - Win32Thread watchdog_handler; + Win32Thread watchdog_handler_; }; diff --git a/src/wine-host/xdnd-proxy.cpp b/src/wine-host/xdnd-proxy.cpp index 84bfb0a1..318941ad 100644 --- a/src/wine-host/xdnd-proxy.cpp +++ b/src/wine-host/xdnd-proxy.cpp @@ -90,31 +90,32 @@ std::optional find_escape_keycode( xcb_connection_t& x11_connection); X11Window::~X11Window() noexcept { - if (!is_moved) { - xcb_destroy_window(x11_connection.get(), window); - xcb_flush(x11_connection.get()); + if (!is_moved_) { + xcb_destroy_window(x11_connection_.get(), window_); + xcb_flush(x11_connection_.get()); } } X11Window::X11Window(X11Window&& o) noexcept - : x11_connection(std::move(o.x11_connection)), window(std::move(o.window)) { - o.is_moved = true; + : x11_connection_(std::move(o.x11_connection_)), + window_(std::move(o.window_)) { + o.is_moved_ = true; } X11Window& X11Window::operator=(X11Window&& o) noexcept { if (&o != this) { - x11_connection = std::move(o.x11_connection); - window = std::move(o.window); + x11_connection_ = std::move(o.x11_connection_); + window_ = std::move(o.window_); - o.is_moved = true; + o.is_moved_ = true; } return *this; } WineXdndProxy::WineXdndProxy() - : x11_connection(xcb_connect(nullptr, nullptr), xcb_disconnect), - proxy_window( - x11_connection, + : x11_connection_(xcb_connect(nullptr, nullptr), xcb_disconnect), + proxy_window_( + x11_connection_, [](std::shared_ptr x11_connection, xcb_window_t window) { const xcb_screen_t* screen = @@ -126,7 +127,7 @@ WineXdndProxy::WineXdndProxy() XCB_WINDOW_CLASS_INPUT_ONLY, XCB_COPY_FROM_PARENT, 0, nullptr); }), - hook_handle( + hook_handle_( SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_CREATE, nullptr, @@ -137,46 +138,47 @@ WineXdndProxy::WineXdndProxy() UnhookWinEvent) { // XDND uses a whole load of atoms for its messages, properties, and // selections - xcb_xdnd_selection = get_atom_by_name(*x11_connection, xdnd_selection_name); - xcb_xdnd_aware_property = - get_atom_by_name(*x11_connection, xdnd_aware_property_name); - xcb_xdnd_proxy_property = - get_atom_by_name(*x11_connection, xdnd_proxy_property_name); - xcb_xdnd_drop_message = - get_atom_by_name(*x11_connection, xdnd_drop_message_name); - xcb_xdnd_enter_message = - get_atom_by_name(*x11_connection, xdnd_enter_message_name); - xcb_xdnd_finished_message = - get_atom_by_name(*x11_connection, xdnd_finished_message_name); - xcb_xdnd_position_message = - get_atom_by_name(*x11_connection, xdnd_position_message_name); - xcb_xdnd_status_message = - get_atom_by_name(*x11_connection, xdnd_status_message_name); - xcb_xdnd_leave_message = - get_atom_by_name(*x11_connection, xdnd_leave_message_name); + xcb_xdnd_selection_ = + get_atom_by_name(*x11_connection_, xdnd_selection_name); + xcb_xdnd_aware_property_ = + get_atom_by_name(*x11_connection_, xdnd_aware_property_name); + xcb_xdnd_proxy_property_ = + get_atom_by_name(*x11_connection_, xdnd_proxy_property_name); + xcb_xdnd_drop_message_ = + get_atom_by_name(*x11_connection_, xdnd_drop_message_name); + xcb_xdnd_enter_message_ = + get_atom_by_name(*x11_connection_, xdnd_enter_message_name); + xcb_xdnd_finished_message_ = + get_atom_by_name(*x11_connection_, xdnd_finished_message_name); + xcb_xdnd_position_message_ = + get_atom_by_name(*x11_connection_, xdnd_position_message_name); + xcb_xdnd_status_message_ = + get_atom_by_name(*x11_connection_, xdnd_status_message_name); + xcb_xdnd_leave_message_ = + get_atom_by_name(*x11_connection_, xdnd_leave_message_name); - xcb_xdnd_copy_action = - get_atom_by_name(*x11_connection, xdnd_copy_action_name); + xcb_xdnd_copy_action_ = + get_atom_by_name(*x11_connection_, xdnd_copy_action_name); - xcb_mime_text_uri_list = - get_atom_by_name(*x11_connection, mime_text_uri_list_name); - xcb_mime_text_plain = - get_atom_by_name(*x11_connection, mime_text_plain_name); + xcb_mime_text_uri_list_ = + get_atom_by_name(*x11_connection_, mime_text_uri_list_name); + xcb_mime_text_plain_ = + get_atom_by_name(*x11_connection_, mime_text_plain_name); } -WineXdndProxy::Handle::Handle(WineXdndProxy* proxy) : proxy(proxy) {} +WineXdndProxy::Handle::Handle(WineXdndProxy* proxy) : proxy_(proxy) {} WineXdndProxy::Handle::~Handle() noexcept { if (instance_reference_count.fetch_sub(1) == 1) { - delete proxy; + delete proxy_; } } -WineXdndProxy::Handle::Handle(const Handle& o) noexcept : proxy(o.proxy) { +WineXdndProxy::Handle::Handle(const Handle& o) noexcept : proxy_(o.proxy_) { instance_reference_count += 1; } -WineXdndProxy::Handle::Handle(Handle&& o) noexcept : proxy(o.proxy) { +WineXdndProxy::Handle::Handle(Handle&& o) noexcept : proxy_(o.proxy_) { instance_reference_count += 1; } @@ -199,43 +201,44 @@ void WineXdndProxy::begin_xdnd(const boost::container::small_vector_base< // NOTE: Needed for a quirk in MT-PowerDrumkit bool expected = false; - if (!drag_active.compare_exchange_strong(expected, true)) { + if (!drag_active_.compare_exchange_strong(expected, true)) { throw std::runtime_error("A drag-and-drop operation is already active"); } - const xcb_setup_t* x11_setup = xcb_get_setup(x11_connection.get()); - root_window = xcb_setup_roots_iterator(x11_setup).data->root; + const xcb_setup_t* x11_setup = xcb_get_setup(x11_connection_.get()); + root_window_ = xcb_setup_roots_iterator(x11_setup).data->root; // When XDND starts, we need to start listening for mouse events so we can // react when the mouse cursor hovers over a target that supports XDND. The // actual file contents will be transferred over X11 selections. See the // spec for a description of the entire process: // https://www.freedesktop.org/wiki/Specifications/XDND/#atomsandproperties - xcb_set_selection_owner(x11_connection.get(), proxy_window.window, - xcb_xdnd_selection, XCB_CURRENT_TIME); + xcb_set_selection_owner(x11_connection_.get(), proxy_window_.window_, + xcb_xdnd_selection_, XCB_CURRENT_TIME); // Escape key presses are supposed to cancel the drag-and-drop operation, so // we will try to grab this key since Wine actually isn't doing that (they // only listen for key pressed on their own windows). If we can't grab the // keyboard, then it's not a huge deal. Oh and we also need to figure out // what keycode the escape key corresponds to first. - if (!escape_keycode) { - escape_keycode = find_escape_keycode(*x11_connection); + if (!escape_keycode_) { + escape_keycode_ = find_escape_keycode(*x11_connection_); } - if (escape_keycode) { - xcb_grab_key(x11_connection.get(), false, root_window, XCB_GRAB_ANY, - *escape_keycode, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); + if (escape_keycode_) { + xcb_grab_key(x11_connection_.get(), false, root_window_, XCB_GRAB_ANY, + *escape_keycode_, XCB_GRAB_MODE_ASYNC, + XCB_GRAB_MODE_ASYNC); } - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); // We will transfer the files in `text/uri-list` format, so a string of URIs // separated by line feeds. When the target window requests the selection to // be converted, they will ask us to write this to a property on their // window constexpr char file_protocol[] = "file://"; - dragged_files_uri_list.clear(); - dragged_files_uri_list.reserve(std::accumulate( + dragged_files_uri_list_.clear(); + dragged_files_uri_list_.reserve(std::accumulate( file_paths.begin(), file_paths.end(), 0, [](size_t size, const auto& path) { // Account for the protocol, the trailing line feed, and URL @@ -244,9 +247,9 @@ void WineXdndProxy::begin_xdnd(const boost::container::small_vector_base< static_cast(static_cast(path.size()) * 1.2); })); for (const auto& path : file_paths) { - dragged_files_uri_list.append(file_protocol); - dragged_files_uri_list.append(url_encode_path(path.string())); - dragged_files_uri_list.push_back('\n'); + dragged_files_uri_list_.append(file_protocol); + dragged_files_uri_list_.append(url_encode_path(path.string())); + dragged_files_uri_list_.push_back('\n'); } // Normally at this point you would grab the mouse pointer and track what @@ -255,20 +258,20 @@ void WineXdndProxy::begin_xdnd(const boost::container::small_vector_base< // the left mouse button gets released. Because Wine is also blocking the // GUI thread, we need to do our XDND polling from another thread. Luckily // the X11 API is thread safe. - this->tracker_window = tracker_window; - xdnd_handler = Win32Thread([&]() { run_xdnd_loop(); }); + tracker_window_ = tracker_window; + xdnd_handler_ = Win32Thread([&]() { run_xdnd_loop(); }); } void WineXdndProxy::end_xdnd() { - if (escape_keycode) { - xcb_ungrab_key(x11_connection.get(), *escape_keycode, root_window, + if (escape_keycode_) { + xcb_ungrab_key(x11_connection_.get(), *escape_keycode_, root_window_, XCB_GRAB_ANY); } - xcb_set_selection_owner(x11_connection.get(), XCB_NONE, xcb_xdnd_selection, - XCB_CURRENT_TIME); - xcb_flush(x11_connection.get()); + xcb_set_selection_owner(x11_connection_.get(), XCB_NONE, + xcb_xdnd_selection_, XCB_CURRENT_TIME); + xcb_flush(x11_connection_.get()); - drag_active = false; + drag_active_ = false; } // FIXME: For some reason you get a -Wmaybe-uninitialized false positive with @@ -298,25 +301,25 @@ void WineXdndProxy::run_xdnd_loop() { auto maybe_leave_last_window = [&]() { if (last_xdnd_window) { - send_xdnd_message(*last_xdnd_window, xcb_xdnd_leave_message, 0, 0, + send_xdnd_message(*last_xdnd_window, xcb_xdnd_leave_message_, 0, 0, 0, 0); next_position_message_position.reset(); last_window_accepted_status = false; waiting_for_status_message = false; - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); } }; auto maybe_send_spooled_position_message = [&]() { if (next_position_message_position && !waiting_for_status_message) { - send_xdnd_message(*last_xdnd_window, xcb_xdnd_position_message, 0, + send_xdnd_message(*last_xdnd_window, xcb_xdnd_position_message_, 0, *next_position_message_position, XCB_CURRENT_TIME, - xcb_xdnd_copy_action); + xcb_xdnd_copy_action_); next_position_message_position.reset(); waiting_for_status_message = true; - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); } }; @@ -374,7 +377,7 @@ void WineXdndProxy::run_xdnd_loop() { std::this_thread::sleep_for(1ms); std::unique_ptr generic_event; - while (generic_event.reset(xcb_poll_for_event(x11_connection.get())), + while (generic_event.reset(xcb_poll_for_event(x11_connection_.get())), generic_event != nullptr) { const uint8_t event_type = generic_event->response_type & xcb_event_type_mask; @@ -385,7 +388,7 @@ void WineXdndProxy::run_xdnd_loop() { const auto event = reinterpret_cast( generic_event.get()); - if (escape_keycode && event->detail == *escape_keycode) { + if (escape_keycode_ && event->detail == *escape_keycode_) { escape_pressed = true; } } break; @@ -399,7 +402,7 @@ void WineXdndProxy::run_xdnd_loop() { reinterpret_cast( generic_event.get()); - if (event->type == xcb_xdnd_status_message) { + if (event->type == xcb_xdnd_status_message_) { handle_xdnd_status_message(*event); } } break; @@ -417,7 +420,7 @@ void WineXdndProxy::run_xdnd_loop() { // separately, as we still need to keep track of the pointer // coordinates. const std::unique_ptr xdnd_window_query = - query_xdnd_aware_window_at_pointer(root_window); + query_xdnd_aware_window_at_pointer(root_window_); if (!xdnd_window_query) { continue; } @@ -469,10 +472,10 @@ void WineXdndProxy::run_xdnd_loop() { // the spec dates from 2002, but JUCE only supports version 3. // We'll just pretend no other changes are required. send_xdnd_message( - xdnd_window_query->child, xcb_xdnd_enter_message, + xdnd_window_query->child, xcb_xdnd_enter_message_, std::clamp(static_cast(*supported_xdnd_version), 3, 5) << 24, - xcb_mime_text_uri_list, xcb_mime_text_plain, XCB_NONE); + xcb_mime_text_uri_list_, xcb_mime_text_plain_, XCB_NONE); } // When the pointer is being moved inside of a window, we should @@ -486,8 +489,8 @@ void WineXdndProxy::run_xdnd_loop() { (xdnd_window_query->root_x << 16) | xdnd_window_query->root_y; if (!waiting_for_status_message) { send_xdnd_message(xdnd_window_query->child, - xcb_xdnd_position_message, 0, position, - XCB_CURRENT_TIME, xcb_xdnd_copy_action); + xcb_xdnd_position_message_, 0, position, + XCB_CURRENT_TIME, xcb_xdnd_copy_action_); waiting_for_status_message = true; } else { next_position_message_position = position; @@ -495,7 +498,7 @@ void WineXdndProxy::run_xdnd_loop() { // For efficiency's sake we'll only flush all of the client messages // we're sending once at the end of every cycle - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); last_xdnd_window = xdnd_window_query->child; } @@ -531,7 +534,7 @@ void WineXdndProxy::run_xdnd_loop() { std::this_thread::sleep_for(1ms); std::unique_ptr generic_event; - while (generic_event.reset(xcb_poll_for_event(x11_connection.get())), + while (generic_event.reset(xcb_poll_for_event(x11_connection_.get())), generic_event != nullptr) { const uint8_t event_type = generic_event->response_type & xcb_event_type_mask; @@ -546,11 +549,11 @@ void WineXdndProxy::run_xdnd_loop() { reinterpret_cast( generic_event.get()); - if (event->type == xcb_xdnd_status_message) { + if (event->type == xcb_xdnd_status_message_) { // We may have to wait for the last `XdndStatus` to be // sent by the target window handle_xdnd_status_message(*event); - } else if (event->type == xcb_xdnd_finished_message) { + } else if (event->type == xcb_xdnd_finished_message_) { // At this point we're done here, and we can clean up // and terminate this thread drop_finished = true; @@ -566,14 +569,14 @@ void WineXdndProxy::run_xdnd_loop() { // window accepts or denies the drop if (!waiting_for_status_message) { if (last_window_accepted_status) { - send_xdnd_message(*last_xdnd_window, xcb_xdnd_drop_message, 0, + send_xdnd_message(*last_xdnd_window, xcb_xdnd_drop_message_, 0, XCB_CURRENT_TIME, 0, 0); } else { maybe_leave_last_window(); drop_finished = true; } - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); // We obviously don't want to spam the other client waiting_for_status_message = true; @@ -583,7 +586,7 @@ void WineXdndProxy::run_xdnd_loop() { // Make sure the Windows drag-and-drop operation doesn't get stuck for // whatever reason (it shouldn't but who knows) if (drop_finished) { - PostMessageW(tracker_window, WM_KEYDOWN, VK_ESCAPE, 0); + PostMessageW(tracker_window_, WM_KEYDOWN, VK_ESCAPE, 0); } end_xdnd(); @@ -598,9 +601,9 @@ WineXdndProxy::query_xdnd_aware_window_at_pointer( xcb_query_pointer_cookie_t query_pointer_cookie; std::unique_ptr query_pointer_reply = nullptr; while (true) { - query_pointer_cookie = xcb_query_pointer(x11_connection.get(), window); + query_pointer_cookie = xcb_query_pointer(x11_connection_.get(), window); query_pointer_reply.reset(xcb_query_pointer_reply( - x11_connection.get(), query_pointer_cookie, &error)); + x11_connection_.get(), query_pointer_cookie, &error)); if (error) { free(error); break; @@ -626,10 +629,10 @@ std::optional WineXdndProxy::is_xdnd_aware( xcb_generic_error_t* error = nullptr; const xcb_get_property_cookie_t property_cookie = - xcb_get_property(x11_connection.get(), false, window, - xcb_xdnd_aware_property, XCB_ATOM_ATOM, 0, 1); + xcb_get_property(x11_connection_.get(), false, window, + xcb_xdnd_aware_property_, XCB_ATOM_ATOM, 0, 1); const std::unique_ptr property_reply( - xcb_get_property_reply(x11_connection.get(), property_cookie, &error)); + xcb_get_property_reply(x11_connection_.get(), property_cookie, &error)); if (error) { free(error); return std::nullopt; @@ -649,10 +652,10 @@ std::optional WineXdndProxy::get_xdnd_proxy( xcb_window_t window) const noexcept { xcb_generic_error_t* error = nullptr; const xcb_get_property_cookie_t property_cookie = - xcb_get_property(x11_connection.get(), false, window, - xcb_xdnd_proxy_property, XCB_ATOM_WINDOW, 0, 1); + xcb_get_property(x11_connection_.get(), false, window, + xcb_xdnd_proxy_property_, XCB_ATOM_WINDOW, 0, 1); const std::unique_ptr property_reply( - xcb_get_property_reply(x11_connection.get(), property_cookie, &error)); + xcb_get_property_reply(x11_connection_.get(), property_cookie, &error)); if (error) { free(error); return std::nullopt; @@ -689,14 +692,14 @@ void WineXdndProxy::send_xdnd_message(xcb_window_t window, event.window = window; event.format = 32; // THis is the source window, so the other side cna reply - event.data.data32[0] = proxy_window.window; + event.data.data32[0] = proxy_window_.window_; event.data.data32[1] = data1; event.data.data32[2] = data2; event.data.data32[3] = data3; event.data.data32[4] = data4; // Make sure to respect `XdndProxy` only here, as explaiend in the spec - xcb_send_event(x11_connection.get(), false, + xcb_send_event(x11_connection_.get(), false, get_xdnd_proxy(window).value_or(window), XCB_EVENT_MASK_NO_EVENT, reinterpret_cast(&event)); } @@ -705,22 +708,22 @@ void WineXdndProxy::send_xdnd_message(xcb_window_t window, void WineXdndProxy::handle_convert_selection( const xcb_selection_request_event_t& event) { - xcb_change_property(x11_connection.get(), XCB_PROP_MODE_REPLACE, + xcb_change_property(x11_connection_.get(), XCB_PROP_MODE_REPLACE, event.requestor, event.property, event.target, 8, - dragged_files_uri_list.size(), - dragged_files_uri_list.c_str()); - xcb_flush(x11_connection.get()); + dragged_files_uri_list_.size(), + dragged_files_uri_list_.c_str()); + xcb_flush(x11_connection_.get()); xcb_selection_notify_event_t selection_notify_event{}; selection_notify_event.response_type = XCB_SELECTION_NOTIFY; selection_notify_event.requestor = event.requestor; - selection_notify_event.selection = xcb_xdnd_selection; + selection_notify_event.selection = xcb_xdnd_selection_; selection_notify_event.target = event.target; selection_notify_event.property = event.property; - xcb_send_event(x11_connection.get(), false, event.requestor, XCB_NONE, + xcb_send_event(x11_connection_.get(), false, event.requestor, XCB_NONE, reinterpret_cast(&selection_notify_event)); - xcb_flush(x11_connection.get()); + xcb_flush(x11_connection_.get()); } /** diff --git a/src/wine-host/xdnd-proxy.h b/src/wine-host/xdnd-proxy.h index 34ba0b3e..49b4d15c 100644 --- a/src/wine-host/xdnd-proxy.h +++ b/src/wine-host/xdnd-proxy.h @@ -48,9 +48,9 @@ class X11Window { template , xcb_window_t> F> X11Window(std::shared_ptr x11_connection, F&& create_window_fn) - : x11_connection(x11_connection), - window(xcb_generate_id(x11_connection.get())) { - create_window_fn(x11_connection, window); + : x11_connection_(x11_connection), + window_(xcb_generate_id(x11_connection.get())) { + create_window_fn(x11_connection, window_); xcb_flush(x11_connection.get()); } @@ -66,13 +66,13 @@ class X11Window { X11Window& operator=(X11Window&&) noexcept; private: - std::shared_ptr x11_connection; + std::shared_ptr x11_connection_; public: - xcb_window_t window; + xcb_window_t window_; private: - bool is_moved = false; + bool is_moved_ = false; }; /** @@ -106,8 +106,8 @@ class WineXdndProxy { public: /** - * Reduces the reference count by one, and frees `proxy` if this was the - * last handle. + * Reduces the reference count by one, and frees `proxy_` if this was + * the last handle. */ ~Handle() noexcept; @@ -118,7 +118,7 @@ class WineXdndProxy { Handle& operator=(Handle&&) noexcept = default; private: - WineXdndProxy* proxy; + WineXdndProxy* proxy_; friend WineXdndProxy; }; @@ -231,19 +231,19 @@ class WineXdndProxy { * that created the window. So we cannot just reuse the connection from the * editor. */ - std::shared_ptr x11_connection; + std::shared_ptr x11_connection_; /** * We need an unmapped 1x1 proxy window to send and receive client messages * for the XDND protocol. */ - X11Window proxy_window; + X11Window proxy_window_; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wignored-attributes" std::unique_ptr, std::decay_t> - hook_handle; + hook_handle_; #pragma GCC diagnostic pop /** @@ -251,13 +251,13 @@ class WineXdndProxy { * cancels it, and then immediately starts a new one. We need to make sure * that we only handle a single drag-and-drop operation at a time. */ - std::atomic_bool drag_active = false; + std::atomic_bool drag_active_ = false; /** * The files that are currently being dragged, stored as in `text/uri-list` * format (i.e. a list of URIs, each ending with a line feed) */ - std::string dragged_files_uri_list; + std::string dragged_files_uri_list_; /** * Wine's tracker window for tracking the drag-and-drop operation. When the @@ -265,45 +265,45 @@ class WineXdndProxy { * potential for weird race conditions where the plugin may still think * we're doing drag-and-drop. */ - HWND tracker_window; + HWND tracker_window_; /** * We need to poll for mouse position changes from another thread, because * when the drag-and-drop operation starts Wine will be blocking the GUI * thread, so we cannot rely on the normal event loop. */ - Win32Thread xdnd_handler; + Win32Thread xdnd_handler_; /** * The X11 root window. */ - xcb_window_t root_window; + xcb_window_t root_window_; /** * The X11 keycode for the escape key. We need to figure this out once when * the first drag-and-drop operation happens. */ - std::optional escape_keycode; + std::optional escape_keycode_; // These are the atoms used for the XDND protocol, as described by // https://www.freedesktop.org/wiki/Specifications/XDND/#atomsandproperties - xcb_atom_t xcb_xdnd_selection; - xcb_atom_t xcb_xdnd_aware_property; - xcb_atom_t xcb_xdnd_proxy_property; - xcb_atom_t xcb_xdnd_drop_message; - xcb_atom_t xcb_xdnd_enter_message; - xcb_atom_t xcb_xdnd_finished_message; - xcb_atom_t xcb_xdnd_position_message; - xcb_atom_t xcb_xdnd_status_message; - xcb_atom_t xcb_xdnd_leave_message; + xcb_atom_t xcb_xdnd_selection_; + xcb_atom_t xcb_xdnd_aware_property_; + xcb_atom_t xcb_xdnd_proxy_property_; + xcb_atom_t xcb_xdnd_drop_message_; + xcb_atom_t xcb_xdnd_enter_message_; + xcb_atom_t xcb_xdnd_finished_message_; + xcb_atom_t xcb_xdnd_position_message_; + xcb_atom_t xcb_xdnd_status_message_; + xcb_atom_t xcb_xdnd_leave_message_; // XDND specifies various actions for drag-and-drop, but since the file is // technically still owned by the plugin we'll just stick with copies to be // safe - xcb_atom_t xcb_xdnd_copy_action; + xcb_atom_t xcb_xdnd_copy_action_; // Mime types for use in XDND, we'll only support dragging links since that // is the foramt the Windows OLE drag-and-drop provides us - xcb_atom_t xcb_mime_text_uri_list; - xcb_atom_t xcb_mime_text_plain; + xcb_atom_t xcb_mime_text_uri_list_; + xcb_atom_t xcb_mime_text_plain_; };