mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 12:30:12 +02:00
Pass through host provided IBStream objects
So if the host supports IStreamAttributes, we can also provide objects that support the same itnerface to the plugin.
This commit is contained in:
@@ -113,9 +113,9 @@ bool Vst3Logger::log_request(bool is_host_vst,
|
||||
bool Vst3Logger::log_request(bool is_host_vst,
|
||||
const Vst3PluginProxy::GetState& request) {
|
||||
return log_request_base(is_host_vst, [&](auto& message) {
|
||||
message
|
||||
<< request.instance_id
|
||||
<< ": {IComponent,IEditController}::getState(state = <IBStream*>)";
|
||||
message << request.instance_id
|
||||
<< ": {IComponent,IEditController}::getState(state = "
|
||||
<< format_bstream(request.state) << ")";
|
||||
});
|
||||
}
|
||||
|
||||
@@ -618,7 +618,8 @@ bool Vst3Logger::log_request(bool is_host_vst,
|
||||
return log_request_base(is_host_vst, [&](auto& message) {
|
||||
message << "IProgramListData::getProgramData(listId = "
|
||||
<< request.list_id
|
||||
<< ", programIndex = " << request.program_index << ", &data)";
|
||||
<< ", programIndex = " << request.program_index
|
||||
<< ", data = " << format_bstream(request.data) << ")";
|
||||
});
|
||||
}
|
||||
|
||||
@@ -643,7 +644,7 @@ bool Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaUnitData::GetUnitData& request) {
|
||||
return log_request_base(is_host_vst, [&](auto& message) {
|
||||
message << "IUnitData::getUnitData(listId = " << request.unit_id
|
||||
<< ", &data)";
|
||||
<< ", data = " << format_bstream(request.data) << ")";
|
||||
});
|
||||
}
|
||||
|
||||
@@ -774,7 +775,8 @@ bool Vst3Logger::log_request(
|
||||
<< ": "
|
||||
"IXmlRepresentationController::getXmlRepresentationStream("
|
||||
"info = <RepresentationInfo for \""
|
||||
<< request.info.name << "\">, stream = <IBstream*>)";
|
||||
<< request.info.name
|
||||
<< "\">, stream = " << format_bstream(request.stream) << ")";
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1213,7 +1215,7 @@ void Vst3Logger::log_response(
|
||||
log_response_base(is_host_vst, [&](auto& message) {
|
||||
message << response.result.string();
|
||||
if (response.result == Steinberg::kResultOk) {
|
||||
message << ", " << format_bstream(response.updated_state);
|
||||
message << ", " << format_bstream(response.state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,25 +30,25 @@ YaBStream::YaBStream(Steinberg::IBStream* stream) {
|
||||
throw std::runtime_error("Null pointer passed to YaBStream()");
|
||||
}
|
||||
|
||||
if (stream->seek(0, Steinberg::IBStream::IStreamSeekMode::kIBSeekEnd) !=
|
||||
// Copy any existing contents, used for `IComponent::setState` and similar
|
||||
// methods
|
||||
if (stream->seek(0, Steinberg::IBStream::IStreamSeekMode::kIBSeekEnd) ==
|
||||
Steinberg::kResultOk) {
|
||||
throw std::runtime_error(
|
||||
"IBStream passed to YaBStream() does not suport seeking to end");
|
||||
// Now that we're at the end of the stream we know how large the buffer
|
||||
// should be
|
||||
int64 size;
|
||||
assert(stream->tell(&size) == Steinberg::kResultOk);
|
||||
|
||||
int32 num_bytes_read = 0;
|
||||
buffer.resize(size);
|
||||
assert(
|
||||
stream->seek(0, Steinberg::IBStream::IStreamSeekMode::kIBSeekSet) ==
|
||||
Steinberg::kResultOk);
|
||||
assert(stream->read(buffer.data(), size, &num_bytes_read) ==
|
||||
Steinberg::kResultOk);
|
||||
assert(num_bytes_read == 0 || num_bytes_read == size);
|
||||
}
|
||||
|
||||
// Now that we're at the end of the stream we know how large the buffer
|
||||
// should be
|
||||
int64 size;
|
||||
assert(stream->tell(&size) == Steinberg::kResultOk);
|
||||
|
||||
int32 num_bytes_read = 0;
|
||||
buffer.resize(size);
|
||||
assert(stream->seek(0, Steinberg::IBStream::IStreamSeekMode::kIBSeekSet) ==
|
||||
Steinberg::kResultOk);
|
||||
assert(stream->read(buffer.data(), size, &num_bytes_read) ==
|
||||
Steinberg::kResultOk);
|
||||
assert(num_bytes_read == 0 || num_bytes_read == size);
|
||||
|
||||
// Starting at VST 3.6.0 streams provided by the host may contain context
|
||||
// based meta data
|
||||
if (Steinberg::FUnknownPtr<Steinberg::Vst::IStreamAttributes>
|
||||
|
||||
@@ -39,6 +39,11 @@ class YaBStream : public Steinberg::IBStream,
|
||||
public Steinberg::ISizeableStream,
|
||||
public Steinberg::Vst::IStreamAttributes {
|
||||
public:
|
||||
/**
|
||||
* This constructor should only be used by bitsery for serialization. The
|
||||
* other constructor will check whether the `IBstream*` provided by the host
|
||||
* supports stream attributes and configures the object accordingly.
|
||||
*/
|
||||
YaBStream();
|
||||
|
||||
/**
|
||||
|
||||
@@ -225,31 +225,34 @@ class Vst3PluginProxy : public YaAudioPresentationLatency,
|
||||
|
||||
/**
|
||||
* The response code and written state for a call to
|
||||
* `{IComponent,IEditController}::getState(state)`.
|
||||
* `{IComponent,IEditController}::getState(&state)`.
|
||||
*/
|
||||
struct GetStateResponse {
|
||||
UniversalTResult result;
|
||||
YaBStream updated_state;
|
||||
YaBStream state;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.object(result);
|
||||
s.object(updated_state);
|
||||
s.object(state);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Message to pass through a call to
|
||||
* `{IComponent,IEditController}::getState(state)` to the Wine plugin host.
|
||||
* `{IComponent,IEditController}::getState(&state)` to the Wine plugin host.
|
||||
*/
|
||||
struct GetState {
|
||||
using Response = GetStateResponse;
|
||||
|
||||
native_size_t instance_id;
|
||||
|
||||
YaBStream state;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.object(state);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -111,12 +111,14 @@ class YaProgramListData : public Steinberg::Vst::IProgramListData {
|
||||
|
||||
Steinberg::Vst::ProgramListID list_id;
|
||||
int32 program_index;
|
||||
YaBStream data;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.value4b(list_id);
|
||||
s.value4b(program_index);
|
||||
s.object(data);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -108,11 +108,13 @@ class YaUnitData : public Steinberg::Vst::IUnitData {
|
||||
native_size_t instance_id;
|
||||
|
||||
Steinberg::Vst::UnitID unit_id;
|
||||
YaBStream data;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.value4b(unit_id);
|
||||
s.object(data);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -96,11 +96,13 @@ class YaXmlRepresentationController
|
||||
native_size_t instance_id;
|
||||
|
||||
Steinberg::Vst::RepresentationInfo info;
|
||||
YaBStream stream;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.object(info);
|
||||
s.object(stream);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user