Rename the Event struct to Vst2Event

This commit is contained in:
Robbert van der Helm
2021-05-20 15:50:09 +02:00
parent 0bc91443b0
commit b1c9d75112
5 changed files with 19 additions and 19 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ intptr_t DefaultDataConverter::return_value(const int /*opcode*/,
EventResult DefaultDataConverter::send_event( EventResult DefaultDataConverter::send_event(
boost::asio::local::stream_protocol::socket& socket, boost::asio::local::stream_protocol::socket& socket,
const Event& event) const { const Vst2Event& event) const {
write_object(socket, event); write_object(socket, event);
return read_object<EventResult>(socket); return read_object<EventResult>(socket);
} }
+14 -14
View File
@@ -85,7 +85,7 @@ class DefaultDataConverter {
*/ */
virtual EventResult send_event( virtual EventResult send_event(
boost::asio::local::stream_protocol::socket& socket, boost::asio::local::stream_protocol::socket& socket,
const Event& event) const; const Vst2Event& event) const;
}; };
/** /**
@@ -185,12 +185,12 @@ class Vst2EventHandler : public AdHocSocketHandler<Thread> {
value_payload); value_payload);
} }
const Event event{.opcode = opcode, const Vst2Event event{.opcode = opcode,
.index = index, .index = index,
.value = value, .value = value,
.option = option, .option = option,
.payload = payload, .payload = payload,
.value_payload = value_payload}; .value_payload = value_payload};
// A socket only handles a single request at a time as to prevent // A socket only handles a single request at a time as to prevent
// messages from arriving out of order. `AdHocSocketHandler::send()` // messages from arriving out of order. `AdHocSocketHandler::send()`
@@ -223,10 +223,10 @@ class Vst2EventHandler : public AdHocSocketHandler<Thread> {
* then start a blocking loop that handles events from the primary `socket`. * then start a blocking loop that handles events from the primary `socket`.
* *
* The specified function will be used to create an `EventResult` from an * The specified function will be used to create an `EventResult` from an
* `Event`. This is almost always uses `passthrough_event()`, which converts * `Vst2Event`. This is almost always uses `passthrough_event()`, which
* a `EventPayload` into the format used by VST2, calls either `dispatch()` * converts a `EventPayload` into the format used by VST2, calls either
* or `audioMaster()` depending on the context, and then serializes the * `dispatch()` or `audioMaster()` depending on the context, and then
* result back into an `EventResultPayload`. * serializes the result back into an `EventResultPayload`.
* *
* @param logging A pair containing a logger instance and whether or not * @param logging A pair containing a logger instance and whether or not
* this is for sending `dispatch()` events or host callbacks. Optional * this is for sending `dispatch()` events or host callbacks. Optional
@@ -237,7 +237,7 @@ class Vst2EventHandler : public AdHocSocketHandler<Thread> {
* @relates Vst2EventHandler::send_event * @relates Vst2EventHandler::send_event
* @relates passthrough_event * @relates passthrough_event
*/ */
template <invocable_returning<EventResult, Event&, bool> F> template <invocable_returning<EventResult, Vst2Event&, bool> F>
void receive_events(std::optional<std::pair<Vst2Logger&, bool>> logging, void receive_events(std::optional<std::pair<Vst2Logger&, bool>> logging,
F&& callback) { F&& callback) {
// Reading, processing, and writing back event data from the sockets // Reading, processing, and writing back event data from the sockets
@@ -245,7 +245,7 @@ class Vst2EventHandler : public AdHocSocketHandler<Thread> {
const auto process_event = const auto process_event =
[&](boost::asio::local::stream_protocol::socket& socket, [&](boost::asio::local::stream_protocol::socket& socket,
bool on_main_thread) { bool on_main_thread) {
auto event = read_object<Event>(socket); auto event = read_object<Vst2Event>(socket);
if (logging) { if (logging) {
auto [logger, is_dispatch] = *logging; auto [logger, is_dispatch] = *logging;
logger.log_event(is_dispatch, event.opcode, event.index, logger.log_event(is_dispatch, event.opcode, event.index,
@@ -406,7 +406,7 @@ class Vst2Sockets : public Sockets {
*/ */
template < template <
invocable_returning<intptr_t, AEffect*, int, int, intptr_t, void*, float> F> invocable_returning<intptr_t, AEffect*, int, int, intptr_t, void*, float> F>
EventResult passthrough_event(AEffect* plugin, F&& callback, Event& event) { EventResult passthrough_event(AEffect* plugin, F&& callback, Vst2Event& event) {
// This buffer is used to write strings and small objects to. We'll // This buffer is used to write strings and small objects to. We'll
// initialize the beginning with null values to both prevent it from being // initialize the beginning with null values to both prevent it from being
// read as some arbitrary C-style string, and to make sure that // read as some arbitrary C-style string, and to make sure that
+1 -1
View File
@@ -388,7 +388,7 @@ void serialize(S& s, EventPayload& payload) {
* the VST host process running under Wine. The fields here mirror those * the VST host process running under Wine. The fields here mirror those
* arguments sent to the `AEffect::dispatch` function. * arguments sent to the `AEffect::dispatch` function.
*/ */
struct Event { struct Vst2Event {
int opcode; int opcode;
int index; int index;
native_intptr_t value; native_intptr_t value;
+1 -1
View File
@@ -76,7 +76,7 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback)
sockets.vst_host_callback.receive_events( sockets.vst_host_callback.receive_events(
std::pair<Vst2Logger&, bool>(logger, false), std::pair<Vst2Logger&, bool>(logger, false),
[&](Event& event, bool /*on_main_thread*/) { [&](Vst2Event& event, bool /*on_main_thread*/) {
switch (event.opcode) { switch (event.opcode) {
// MIDI events sent from the plugin back to the host are // MIDI events sent from the plugin back to the host are
// a special case here. They have to sent during the // a special case here. They have to sent during the
+2 -2
View File
@@ -353,7 +353,7 @@ bool Vst2Bridge::inhibits_event_loop() noexcept {
void Vst2Bridge::run() { void Vst2Bridge::run() {
sockets.host_vst_dispatch.receive_events( sockets.host_vst_dispatch.receive_events(
std::nullopt, [&](Event& event, bool /*on_main_thread*/) { std::nullopt, [&](Vst2Event& event, bool /*on_main_thread*/) {
if (event.opcode == effProcessEvents) { if (event.opcode == effProcessEvents) {
// For 99% of the plugins we can just call // For 99% of the plugins we can just call
// `effProcessReplacing()` and be done with it, but a select few // `effProcessReplacing()` and be done with it, but a select few
@@ -629,7 +629,7 @@ class HostCallbackDataConverter : public DefaultDataConverter {
} }
EventResult send_event(boost::asio::local::stream_protocol::socket& socket, EventResult send_event(boost::asio::local::stream_protocol::socket& socket,
const Event& event) const override { const Vst2Event& event) const override {
if (mutually_recursive_callbacks.contains(event.opcode)) { if (mutually_recursive_callbacks.contains(event.opcode)) {
return mutual_recursion.fork([&]() { return mutual_recursion.fork([&]() {
return DefaultDataConverter::send_event(socket, event); return DefaultDataConverter::send_event(socket, event);