Clarify the return value override

This commit is contained in:
Robbert van der Helm
2020-03-11 01:12:40 +01:00
parent 5cdfb90a9b
commit 7f2eab476d
3 changed files with 39 additions and 23 deletions
+14 -5
View File
@@ -221,22 +221,31 @@ class HostCallbackDataConverter : DefaultDataConverter {
}
}
std::optional<intptr_t> write(const int opcode,
void* data,
const EventResult& response) {
void write(const int opcode, void* data, const EventResult& response) {
switch (opcode) {
case audioMasterGetTime:
// Write the returned `VstTimeInfo` struct into a field and make
// the function return a poitner to it
// the function return a poitner to it in the function below
// TODO: Start a time to update this on the host bridge once
// it's been requested. Not sure if this is needed though!
time = *static_cast<const VstTimeInfo*>(
static_cast<const void*>(response.data->data()));
break;
default:
DefaultDataConverter::write(opcode, data, response);
break;
}
}
intptr_t return_value(const int opcode, const intptr_t original) {
switch (opcode) {
case audioMasterGetTime:
// Return a pointer to the `VstTimeInfo` object written in the
// function above
return reinterpret_cast<intptr_t>(&time);
break;
default:
return DefaultDataConverter::write(opcode, data, response);
return DefaultDataConverter::return_value(opcode, original);
break;
}
}