mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-15 21:15:51 +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:
@@ -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