Commit Graph

65 Commits

Author SHA1 Message Date
Robbert van der Helm 93e01dacef Explicitly close all sockets on shutdown
This way we're sure to break out of any blocking loops.
2020-10-28 20:38:01 +01:00
Robbert van der Helm 28886e7073 Replace all threads with Win32Thread in Wine host 2020-10-27 18:29:38 +01:00
Robbert van der Helm 5b00ddb0c4 Fall back to waiting when socket is not yet ready
This can happen with plugin groups.
2020-10-27 11:13:39 +01:00
Robbert van der Helm e12a56978d Reintroduce the additional IO contexts
Having these bound to the main context was not a good idea since that
would prevent sockets from being accepted on the Wine side while the
message loop is running.

Partial revert of ac17539ef3
2020-10-26 20:39:16 +01:00
Robbert van der Helm ca2b95e7aa Handle dispatch() directly during event handling
When the message loop is active and we get an incoming dispatch() event,
we'll just handle it directly. In practice this would only be needed
when the event is a response to an `audioMaster()` call made during the
event loop, but we can't know that. This allows the `getProgram()`
during `audioMasterUpdateDisplay()` in REAPER and Renoise to work
correctly. Hopefully this doesn't cause random rare breakage.
2020-10-26 20:03:54 +01:00
Robbert van der Helm e067bbbfbc Don't stop the whole IO context
This would break plugin groups since the different plugins share a
single IO context.
2020-10-26 17:44:34 +01:00
Robbert van der Helm ac17539ef3 Drop all additional IO contexts
Not really needed (since the only other thing happening in the IO
context is processing stdio from the Wine process) and it was causing
some impossible to debug malloc failures in Boost.Asio.
2020-10-26 17:32:37 +01:00
Robbert van der Helm cde7b4ec67 Properly move the sockets to the handler threads
At times like this you really wish you were writing Rust right now.
2020-10-26 15:48:57 +01:00
Robbert van der Helm 8d7826f1df Handle incoming events from off-threads separately
On the Wine side we want to handle most events on the main UI thread.
We'll assume any events coming in from a secondary socket are safe and
can be handled directly.
2020-10-26 13:45:37 +01:00
Robbert van der Helm 81efa6febe Listen for incoming secondary event requests 2020-10-26 12:58:03 +01:00
Robbert van der Helm 2f6883977f Create secondary sockets for sending nested events 2020-10-26 12:13:27 +01:00
Robbert van der Helm 74c3cab046 Move event handling logic to a dedicated class
Now all pieces are in place to allow handling events over multiple
socket connections.
2020-10-26 11:40:38 +01:00
Robbert van der Helm 54ed69c408 Merge events.h into communication.h 2020-10-25 21:37:04 +01:00
Robbert van der Helm 4b53342514 💥 Encapsulate and rework all socket logic
This is a pretty huge change that will be important for being able to
handle nested or mutually recursive `dispatch()` and `audioMaster()`
calls. This sadly all had to be done in a single commit, so here's a
summary:

- `src/common/sockets.h:Sockets` contains all sockets on both the plugin
  and the Wine host side, and is used to both listen on and connect to
  the sockets.
- Sockets and other temporary files respect `$XDG_RUNTIME_DIR` instead
  of being dumped in `/tmp`.
- All sockets now have a unique endpoint in
  `/run/user/<uid>/yabridge-<plugin_name>-<random_id>/`. This is
  important for when we want to have multiple socket connections for
  handling `dispatch()` and `audioMaster()`.
- Because of the above, we no longer clean up the socket endpoint files
  after the connection gets established during initialization. Instead
  we'll remove the socket base directory when shutting down.
2020-10-25 21:24:56 +01:00
Robbert van der Helm c2fceb6e4a Add a thread safety warning to write_object() 2020-05-19 11:33:34 +02:00
Robbert van der Helm ba91971829 Simplify object reading
No longer needs to read into an existing object after the last change,
and reusing that function here too makes it less error prone.
2020-05-10 13:10:58 +02:00
Robbert van der Helm 2e9adbe310 Always write message sizes in 64-bit integers
This will make sure the sizes match on both the 32 and 64 bit host
applications. This way only the 32-bit application will have to convert
between 32 and 64 bit integers.
2020-04-30 12:32:27 +02:00
Robbert van der Helm e69d08c503 Add assertion for bytes written while sending
To avoid problems like 13dcb2f74a in the
future.
2020-04-27 18:00:01 +02:00
Robbert van der Helm 13dcb2f74a Fix handling of large chunk data 2020-04-27 16:41:55 +02:00
Robbert van der Helm aa31665666 Move event handling its own file 2020-03-11 14:42:09 +01:00
Robbert van der Helm 7f2eab476d Clarify the return value override 2020-03-11 01:12:40 +01:00
Robbert van der Helm 5cdfb90a9b Implement audioMasterGetTime,fixing playback
Midi and audio now work!
2020-03-11 00:34:58 +01:00
Robbert van der Helm af94fe80d8 Filter out unsupported aduioMaster* events
Not sure if this is the correct approach, but these seem to not really
do anything and they sometimes crash the host.
2020-03-10 14:21:27 +01:00
Robbert van der Helm 54966a36f2 Implement effSetChunk 2020-03-10 12:57:53 +01:00
Robbert van der Helm e89ddfe7b1 Correct reading chunks
They're not actually stored in `data`, but in `*data`.
2020-03-10 00:36:34 +01:00
Robbert van der Helm 7fcf5abaf2 Handle effGetChunk correctly 2020-03-09 23:53:36 +01:00
Robbert van der Helm 7e75f913fa Add the ability to override writing back data 2020-03-09 23:36:54 +01:00
Robbert van der Helm ec96064cc1 Implement another EventPayload for binary data 2020-03-09 23:24:10 +01:00
Robbert van der Helm 8dad15b597 Always use resizable buffers
It was a slight problem for audio buffers, but events can apparently
also have an arbitrary size because of chunks.
2020-03-09 21:32:49 +01:00
Robbert van der Helm adf33e84a8 Use a template argument for serializing behaviour
This keeps it a bit more readable.
2020-03-09 20:13:08 +01:00
Robbert van der Helm 69008e97a4 Serialize midi events using vectors
Easier than to implement C-style arrays in Bitsery and this way we also
don't have to worry about cleanup.

Serum still segfaults with multiple events so something is still off.
2020-03-09 15:31:35 +01:00
Robbert van der Helm 40142f801e Pass throug the VstEvents struct 2020-03-08 20:29:40 +01:00
Robbert van der Helm c5ea1e5153 Add serialization for midi events 2020-03-08 20:02:24 +01:00
Robbert van der Helm 5523871fd8 Pass a marker struct instead of an empty array 2020-03-08 18:51:16 +01:00
Robbert van der Helm d8e39ed16a Fix returning buffers from std::visit
Last time I tried it references somehow didn't work.
2020-03-08 18:40:16 +01:00
Robbert van der Helm 2326a92c62 Improve event passing clarity 2020-03-08 18:33:01 +01:00
Robbert van der Helm ff89d12c1a Use std::avriant to encode event payloads
It's a bit more complicated this way, but nwo we can easily add support
for the opcode specific structs.
2020-03-08 17:47:09 +01:00
Robbert van der Helm d434bcf682 Move data types and serializers to their own file 2020-03-08 14:32:15 +01:00
Robbert van der Helm b46488ac28 Add a description of communication.h 2020-03-08 14:25:15 +01:00
Robbert van der Helm f1901de62b Add an updated version of the aeffectx.h header
From the Audacity project.
2020-03-08 13:48:09 +01:00
Robbert van der Helm 6373c38663 Correct VeSTige header name to aeffectx.h 2020-03-08 13:27:17 +01:00
Robbert van der Helm 3bfb6cf38b Disable logging on the Wine side
It was incredibly verbose, and for debugging the networking part you
could still use stdout.
2020-03-07 23:36:30 +01:00
Robbert van der Helm 35b0174b9e Add log messages everywhere 2020-03-07 23:10:07 +01:00
Robbert van der Helm 54d62c6a66 Split src/common/* into headers and definitions 2020-03-06 19:18:27 +01:00
Robbert van der Helm 7d0bf3e3c4 Further clean up the Boost hacks
This way we can also finally split up the src/common/* files into
headers and implementations.
2020-03-06 18:44:47 +01:00
Robbert van der Helm 46b08530ae Pass through processReplacing
Should work, almost does.
2020-03-05 22:18:06 +01:00
Robbert van der Helm 54b5395c5e Use a statically allocated array for audio buffers
We wouldn't know the right size on the receiving end in advance.
2020-03-05 20:59:27 +01:00
Robbert van der Helm 9d68493af1 Shorten buffer_type to buffer_t 2020-03-05 19:47:31 +01:00
Robbert van der Helm 9754909930 Allow reusing buffers when reading and writing 2020-03-05 19:18:34 +01:00
Robbert van der Helm 620ba5b756 Define a buffer size for each type 2020-03-05 19:03:48 +01:00