mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-13 20:09:59 +02:00
Finally implement eff{Set,Get}SpeakerConfiguration
As mentioned in #1. This also indirectly allows yabridge to work under Renoise.
This commit is contained in:
+29
-4
@@ -56,7 +56,17 @@ class DefaultDataConverter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the reponse back to the data pointer.
|
||||
* Read data from the `value` pointer into a an `EventPayload` value that
|
||||
* can be serialized and conveys the meaning of the event. This is only used
|
||||
* for the `effSetSpeakerArrangement` and `effGetSpeakerArrangement` events.
|
||||
*/
|
||||
virtual std::optional<EventPayload> read_value(const int /*opcode*/,
|
||||
const intptr_t /*value*/) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the reponse back to the `data` pointer.
|
||||
*/
|
||||
virtual void write(const int /*opcode*/,
|
||||
void* data,
|
||||
@@ -76,6 +86,14 @@ class DefaultDataConverter {
|
||||
response.payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the reponse back to the `value` pointer. This is only used during
|
||||
* the `effGetSpeakerArrangement` event.
|
||||
*/
|
||||
virtual void write_value(const int /*opcode*/,
|
||||
intptr_t /*value*/,
|
||||
const EventResult& /*response*/) {}
|
||||
|
||||
/**
|
||||
* This function can override a callback's return value based on the opcode.
|
||||
* This is used in one place to return a pointer to a `VstTime` object
|
||||
@@ -126,17 +144,21 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
|
||||
intptr_t value,
|
||||
void* data,
|
||||
float option) {
|
||||
// Encode the right payload type for this event. Check the documentation for
|
||||
// `EventPayload` for more information
|
||||
// Encode the right payload types for this event. Check the documentation
|
||||
// for `EventPayload` for more information. These types are converted to
|
||||
// C-style data structures in `passthrough_event()` so they can be passed to
|
||||
// a plugin or callback function.
|
||||
const EventPayload payload =
|
||||
data_converter.read(opcode, index, value, data);
|
||||
const std::optional<EventPayload> value_payload =
|
||||
data_converter.read_value(opcode, value);
|
||||
|
||||
if (logging.has_value()) {
|
||||
auto [logger, is_dispatch] = logging.value();
|
||||
logger.log_event(is_dispatch, opcode, index, value, payload, option);
|
||||
}
|
||||
|
||||
const Event event{opcode, index, value, option, payload};
|
||||
const Event event{opcode, index, value, option, payload, value_payload};
|
||||
|
||||
// Prevent two threads from writing over the socket at the same time and
|
||||
// messages getting out of order. This is needed because we can't prevent
|
||||
@@ -156,6 +178,7 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
|
||||
}
|
||||
|
||||
data_converter.write(opcode, data, response);
|
||||
data_converter.write_value(opcode, value, response);
|
||||
|
||||
return data_converter.return_value(opcode, response.return_value);
|
||||
}
|
||||
@@ -308,6 +331,8 @@ auto passthrough_event(AEffect* plugin, F callback) {
|
||||
|
||||
return nullptr;
|
||||
},
|
||||
[&](DynamicSpeakerArrangement& speaker_arrangement)
|
||||
-> EventResultPayload { return speaker_arrangement; },
|
||||
[&](WantsChunkBuffer&) -> EventResultPayload {
|
||||
// In this case the plugin will have written its data stored in
|
||||
// an array to which a pointer is stored in `data`, with the
|
||||
|
||||
@@ -84,3 +84,10 @@ VstSpeakerArrangement& DynamicSpeakerArrangement::as_c_speaker_arrangement() {
|
||||
|
||||
return *speaker_arrangement;
|
||||
}
|
||||
|
||||
std::vector<uint8_t>& DynamicSpeakerArrangement::as_raw_data() {
|
||||
// This will populate the buffer for us with the struct data
|
||||
as_c_speaker_arrangement();
|
||||
|
||||
return speaker_arrangement_buffer;
|
||||
}
|
||||
|
||||
@@ -230,11 +230,18 @@ class alignas(16) DynamicSpeakerArrangement {
|
||||
const VstSpeakerArrangement& speaker_arrangement);
|
||||
|
||||
/**
|
||||
* Construct a dynamically sized `VstSpeakerArrangement` struct based on
|
||||
* Construct a dynamically sized `VstSpeakerArrangement` object based on
|
||||
* this object.
|
||||
*/
|
||||
VstSpeakerArrangement& as_c_speaker_arrangement();
|
||||
|
||||
/**
|
||||
* Reconstruct the dynamically sized `VstSpeakerArrangement` object and
|
||||
* return the raw data buffer. Needed to write the results back to the host
|
||||
* since we can't just reassign the object.
|
||||
*/
|
||||
std::vector<uint8_t>& as_raw_data();
|
||||
|
||||
/**
|
||||
* The flags field from `VstSpeakerArrangement`
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user