diff --git a/core/src/al/miniaudio_context.cpp b/core/src/al/miniaudio_context.cpp index b46ff25c13..d6b2838625 100644 --- a/core/src/al/miniaudio_context.cpp +++ b/core/src/al/miniaudio_context.cpp @@ -1,5 +1,5 @@ #define MINIAUDIO_IMPLEMENTATION -#include +#include #include #include @@ -13,8 +13,11 @@ class MiniaudioBuffer : public impl::Buffer public: ma_decoder decoder; - MiniaudioBuffer(const void* data, size_t dataSize) + MiniaudioBuffer(const void* srcData, size_t dataSize) { + data = operator new(dataSize); + std::memcpy(data, srcData, dataSize); + if (ma_decoder_init_memory(data, dataSize, nullptr, &decoder) != MA_SUCCESS) { CUBOS_ERROR("Failed to initialize Decoder from data"); @@ -22,12 +25,14 @@ class MiniaudioBuffer : public impl::Buffer else { mValid = true; + CUBOS_INFO("Decoder for buffer initialized successfully"); } } ~MiniaudioBuffer() override { ma_decoder_uninit(&decoder); + operator delete(data); } float length() override @@ -52,6 +57,7 @@ class MiniaudioBuffer : public impl::Buffer private: bool mValid = false; + void* data; }; class MiniaudioListener : public impl::Listener