mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-16 13:40:05 +02:00
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.
This commit is contained in:
@@ -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 <typename T>
|
||||
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 <typename T>
|
||||
inline void send(const T& object) {
|
||||
write_object(socket, object);
|
||||
write_object(socket_, object);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -471,7 +472,7 @@ class SocketHandler {
|
||||
*/
|
||||
template <typename T>
|
||||
inline T& receive_single(T& object, SerializationBufferBase& buffer) {
|
||||
return read_object<T>(socket, object, buffer);
|
||||
return read_object<T>(socket_, object, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,7 +483,7 @@ class SocketHandler {
|
||||
*/
|
||||
template <typename T>
|
||||
inline T receive_single() {
|
||||
return read_object<T>(socket);
|
||||
return read_object<T>(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<boost::asio::local::stream_protocol::acceptor> acceptor;
|
||||
std::optional<boost::asio::local::stream_protocol::acceptor> 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<boost::asio::local::stream_protocol::acceptor> acceptor;
|
||||
std::optional<boost::asio::local::stream_protocol::acceptor> 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;
|
||||
};
|
||||
|
||||
@@ -225,8 +225,9 @@ class Vst2EventHandler : public AdHocSocketHandler<Thread> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<Thread> {
|
||||
};
|
||||
|
||||
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 `<from>_<to>_<event>`. 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<Thread> host_vst_dispatch;
|
||||
Vst2EventHandler<Thread> host_vst_dispatch_;
|
||||
/**
|
||||
* The socket that forwards all `audioMaster()` calls from the Windows VST
|
||||
* plugin to the host.
|
||||
*/
|
||||
Vst2EventHandler<Thread> vst_host_callback;
|
||||
Vst2EventHandler<Thread> 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_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -264,10 +264,10 @@ class Vst3MessageHandler : public AdHocSocketHandler<Thread> {
|
||||
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<void>& 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<true>(std::nullopt,
|
||||
std::forward<F>(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<Thread, ControlRequest> host_vst_control;
|
||||
Vst3MessageHandler<Thread, ControlRequest> 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<Thread, CallbackRequest> vst_host_callback;
|
||||
Vst3MessageHandler<Thread, CallbackRequest> vst_host_callback_;
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -508,12 +508,12 @@ class Vst3Sockets final : public Sockets {
|
||||
std::optional<std::pair<Vst3Logger&, bool>> 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<size_t,
|
||||
Vst3MessageHandler<Thread, AudioProcessorRequest>>
|
||||
audio_processor_sockets;
|
||||
std::mutex audio_processor_sockets_mutex;
|
||||
audio_processor_sockets_;
|
||||
std::mutex audio_processor_sockets_mutex_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user