diff --git a/src/contrib/directsoundout/DirectSoundOut.cpp b/src/contrib/directsoundout/DirectSoundOut.cpp index e6f4a292c..296595321 100644 --- a/src/contrib/directsoundout/DirectSoundOut.cpp +++ b/src/contrib/directsoundout/DirectSoundOut.cpp @@ -70,6 +70,7 @@ class DrainBuffer : virtual void SetSamples(long samples) { this->samples = samples; } virtual long Bytes() const { return this->samples * sizeof(float); } virtual void OnBufferProcessed(IBuffer *buffer) { } + virtual void Destroy() { delete this; } private: int channels, samples, rate; diff --git a/src/core/audio/Buffer.h b/src/core/audio/Buffer.h index 130ad032d..d83dc546c 100644 --- a/src/core/audio/Buffer.h +++ b/src/core/audio/Buffer.h @@ -56,16 +56,17 @@ namespace musik { namespace core { namespace audio { virtual ~Buffer(); - virtual long SampleRate() const; - virtual void SetSampleRate(long sampleRate); - virtual int Channels() const; - virtual void SetChannels(int channels); - virtual float* BufferPointer() const; - virtual long Samples() const; - virtual void SetSamples(long samples); - virtual long Bytes() const; - virtual double Position() const; + virtual long SampleRate() const override; + virtual void SetSampleRate(long sampleRate) override; + virtual int Channels() const override; + virtual void SetChannels(int channels) override; + virtual float* BufferPointer() const override; + virtual long Samples() const override; + virtual void SetSamples(long samples) override; + virtual long Bytes() const override; + virtual void Destroy() override { delete this; } + double Position() const; void SetPosition(double position); void Copy(float* buffer, long samples); void Append(float* buffer, long samples); diff --git a/src/core/plugin/Plugins.cpp b/src/core/plugin/Plugins.cpp index adfb36afc..eef1cae20 100644 --- a/src/core/plugin/Plugins.cpp +++ b/src/core/plugin/Plugins.cpp @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -73,6 +74,14 @@ static class Environment : public IEnvironment { virtual IDecoder* GetDecoder(IDataStream* stream) override { return streams::GetDecoderForDataStream(stream); } + + virtual IBuffer* GetBuffer(size_t samples, size_t rate = 44100, size_t channels = 2) override { + musik::core::audio::Buffer* buffer = new Buffer(); + buffer->SetChannels(2); + buffer->SetSampleRate(rate); + buffer->SetSamples(samples); + return buffer; + } } environment; typedef void(*SetEnvironment)(IEnvironment*); diff --git a/src/core/sdk/IBuffer.h b/src/core/sdk/IBuffer.h index 457999dba..b27b5aa4a 100644 --- a/src/core/sdk/IBuffer.h +++ b/src/core/sdk/IBuffer.h @@ -46,6 +46,7 @@ namespace musik { namespace core { namespace sdk { virtual long Samples() const = 0; virtual void SetSamples(long samples) = 0; virtual long Bytes() const = 0; + virtual void Destroy() = 0; }; } } } diff --git a/src/core/sdk/IEnvironment.h b/src/core/sdk/IEnvironment.h index 6e25125ab..205105102 100644 --- a/src/core/sdk/IEnvironment.h +++ b/src/core/sdk/IEnvironment.h @@ -45,6 +45,7 @@ namespace musik { namespace core { namespace sdk { virtual size_t GetPath(PathType type, char* dst, int size) = 0; virtual IDataStream* GetDataStream(const char* uri) = 0; virtual IDecoder* GetDecoder(IDataStream* stream) = 0; + virtual IBuffer* GetBuffer(size_t samples, size_t rate = 44100, size_t channels = 2) = 0; }; } } } diff --git a/src/core/sdk/constants.h b/src/core/sdk/constants.h index 0c6cbf972..701f85a9c 100644 --- a/src/core/sdk/constants.h +++ b/src/core/sdk/constants.h @@ -133,5 +133,5 @@ namespace musik { static const char* ExternalId = "external_id"; } - static const int SdkVersion = 6; + static const int SdkVersion = 7; } } }