Allow overriding sending behaviour for VST2 events

Now we can implement mutual recursion for VST2 plugins. Wish we didn't
have to.
This commit is contained in:
Robbert van der Helm
2021-05-20 14:46:10 +02:00
parent ccfda51a69
commit 3e6bf3adfd
2 changed files with 23 additions and 3 deletions
+16 -3
View File
@@ -76,6 +76,16 @@ class DefaultDataConverter {
*/
virtual intptr_t return_value(const int opcode,
const intptr_t original) const;
/**
* Send an event over the socket. The default implementation will just send
* the event over the socket, and then wait for the response to be sent
* back. This can be overridden to use `MutualRecursionHelper::fork()` for
* specific opcodes to allow mutually recursive calling sequences.
*/
virtual EventResult send_event(
boost::asio::local::stream_protocol::socket& socket,
const Event& event) const;
};
/**
@@ -185,11 +195,14 @@ class Vst2EventHandler : public AdHocSocketHandler<Thread> {
// A socket only handles a single request at a time as to prevent
// messages from arriving out of order. `AdHocSocketHandler::send()`
// will either use a long-living primary socket, or if that's currently
// in use it will spawn a new socket for us.
// in use it will spawn a new socket for us. We'll then use
// `DefaultDataConverter::send_event()` to actually write and read data
// from the socket, so we can override this for specific function calls
// that potentially need to have their responses handled on the same
// calling thread (i.e. mutual recursion).
const EventResult response = this->send(
[&](boost::asio::local::stream_protocol::socket& socket) {
write_object(socket, event);
return read_object<EventResult>(socket);
return data_converter.send_event(socket, event);
});
if (logging) {