mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-16 08:23:55 +02:00
Move VectorStream to a new YaBStream
We'll have to extend this with `IStreamAttributes` for VST 3.6.0 preset meta data.
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <pluginterfaces/base/ftypes.h>
|
||||
#include <pluginterfaces/base/funknown.h>
|
||||
#include <pluginterfaces/base/ibstream.h>
|
||||
#include <pluginterfaces/vst/vsttypes.h>
|
||||
|
||||
// Yet Another layer of includes, but these are some VST3-specific typedefs that
|
||||
@@ -165,67 +164,3 @@ class UniversalTResult {
|
||||
|
||||
Value universal_result;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
|
||||
/**
|
||||
* Serialize an `IBStream` into an `std::vector<uint8_t>`, and allow the
|
||||
* receiving side to use it as an `IBStream` again. `ISizeableStream` is defined
|
||||
* but then for whatever reason never used, but we'll implement it anyways.
|
||||
*/
|
||||
class VectorStream : public Steinberg::IBStream,
|
||||
public Steinberg::ISizeableStream {
|
||||
public:
|
||||
VectorStream();
|
||||
|
||||
/**
|
||||
* Read an existing stream.
|
||||
*
|
||||
* @throw std::runtime_error If we couldn't read from the stream.
|
||||
*/
|
||||
VectorStream(Steinberg::IBStream* stream);
|
||||
|
||||
virtual ~VectorStream();
|
||||
|
||||
DECLARE_FUNKNOWN_METHODS
|
||||
|
||||
/**
|
||||
* Write the vector buffer back to an IBStream. After writing the seek
|
||||
* position will be left at the end of the stream.
|
||||
*/
|
||||
tresult write_back(Steinberg::IBStream* stream) const;
|
||||
|
||||
/**
|
||||
* Return the buffer's, used in the logging messages.
|
||||
*/
|
||||
size_t size() const;
|
||||
|
||||
// From `IBstream`
|
||||
tresult PLUGIN_API read(void* buffer,
|
||||
int32 numBytes,
|
||||
int32* numBytesRead = nullptr) override;
|
||||
tresult PLUGIN_API write(void* buffer,
|
||||
int32 numBytes,
|
||||
int32* numBytesWritten = nullptr) override;
|
||||
tresult PLUGIN_API seek(int64 pos,
|
||||
int32 mode,
|
||||
int64* result = nullptr) override;
|
||||
tresult PLUGIN_API tell(int64* pos) override;
|
||||
|
||||
// From `ISizeableStream`
|
||||
tresult PLUGIN_API getStreamSize(int64& size) override;
|
||||
tresult PLUGIN_API setStreamSize(int64 size) override;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.container1b(buffer, max_vector_stream_size);
|
||||
// The seek position should always be initialized at 0
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> buffer;
|
||||
size_t seek_position = 0;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
Reference in New Issue
Block a user