mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Implement effSetChunk
This commit is contained in:
@@ -17,13 +17,6 @@ There are a few things that should be done before making this public, including:
|
|||||||
thing.
|
thing.
|
||||||
- Fix `processReplacing` forwarding.
|
- Fix `processReplacing` forwarding.
|
||||||
- Implement GUIs.
|
- Implement GUIs.
|
||||||
- Chunks. For `effSetChunk` we can now just use the strings. For `effGetChunk`
|
|
||||||
we need to find a clean way to 1. make the returned string exactly `n` bytes
|
|
||||||
long, where `n` is the value returned by the VST plugin's `dispatch()`
|
|
||||||
function (could be an option for `WritableBuffer`), and 2. store the returned
|
|
||||||
data in a `std::vector<uint8_t>` on the `HostBridge` struct and write back a
|
|
||||||
pointer to that instead. That might involve extending `DefaultDataConverter`
|
|
||||||
to also handle writing back values.
|
|
||||||
- Check if we need special handling for the `effGetChunk` and `effSetChunk`
|
- Check if we need special handling for the `effGetChunk` and `effSetChunk`
|
||||||
events.
|
events.
|
||||||
- Mention precompiled binaries and building from source in the installation
|
- Mention precompiled binaries and building from source in the installation
|
||||||
|
|||||||
@@ -116,7 +116,9 @@ inline T read_object(Socket& socket) {
|
|||||||
*/
|
*/
|
||||||
class DefaultDataConverter {
|
class DefaultDataConverter {
|
||||||
public:
|
public:
|
||||||
EventPayload read(const int /*opcode*/, const void* data) {
|
virtual ~DefaultDataConverter() {};
|
||||||
|
|
||||||
|
virtual EventPayload read(const int /*opcode*/, const intptr_t /*value*/, const void* data) {
|
||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -130,7 +132,7 @@ class DefaultDataConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(const int /*opcode*/, void* data, const EventResult& response) {
|
virtual void write(const int /*opcode*/, void* data, const EventResult& response) {
|
||||||
if (response.data.has_value()) {
|
if (response.data.has_value()) {
|
||||||
char* output = static_cast<char*>(data);
|
char* output = static_cast<char*>(data);
|
||||||
|
|
||||||
@@ -173,7 +175,7 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
|
|||||||
std::optional<std::pair<Logger&, bool>> logging) {
|
std::optional<std::pair<Logger&, bool>> logging) {
|
||||||
// Encode the right payload type for this event. Check the documentation for
|
// Encode the right payload type for this event. Check the documentation for
|
||||||
// `EventPayload` for more information.
|
// `EventPayload` for more information.
|
||||||
const EventPayload payload = data_converter.read(opcode, data);
|
const EventPayload payload = data_converter.read(opcode, value, data);
|
||||||
|
|
||||||
if (logging.has_value()) {
|
if (logging.has_value()) {
|
||||||
auto [logger, is_dispatch] = *logging;
|
auto [logger, is_dispatch] = *logging;
|
||||||
|
|||||||
@@ -142,18 +142,24 @@ class DispatchDataConverter : DefaultDataConverter {
|
|||||||
DispatchDataConverter(std::vector<uint8_t>& chunk_data)
|
DispatchDataConverter(std::vector<uint8_t>& chunk_data)
|
||||||
: chunk(chunk_data) {}
|
: chunk(chunk_data) {}
|
||||||
|
|
||||||
EventPayload read(const int opcode, const void* data) {
|
EventPayload read(const int opcode, const intptr_t value, const void* data) {
|
||||||
// There are some events that need specific structs that we can't simply
|
// There are some events that need specific structs that we can't simply
|
||||||
// serialize as a string because they might contain null bytes
|
// serialize as a string because they might contain null bytes
|
||||||
// TODO: More of these structs
|
// TODO: More of these structs
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case effGetChunk:
|
case effGetChunk:
|
||||||
return WantsChunkBuffer();
|
return WantsChunkBuffer();
|
||||||
|
break;
|
||||||
|
case effSetChunk:
|
||||||
|
// When the host passes a chunk it will use the value parameter
|
||||||
|
// to tell us its length
|
||||||
|
return std::string(static_cast<const char*>(data), value);
|
||||||
|
break;
|
||||||
case effProcessEvents:
|
case effProcessEvents:
|
||||||
return DynamicVstEvents(*static_cast<const VstEvents*>(data));
|
return DynamicVstEvents(*static_cast<const VstEvents*>(data));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return DefaultDataConverter::read(opcode, data);
|
return DefaultDataConverter::read(opcode, value, data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user