From b89b8d585e3da04e45e8e6fe04b1728100e9071c Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 8 Apr 2024 18:10:09 +1000 Subject: [PATCH] oops - restore assets modification to load scripts --- source/base/StarAssets.cpp | 8 +++++--- source/base/StarMixer.cpp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp index b334b31..357fca0 100644 --- a/source/base/StarAssets.cpp +++ b/source/base/StarAssets.cpp @@ -147,8 +147,10 @@ Assets::Assets(Settings settings, StringList assetSources) { pushGlobalContext("assets", makeBaseAssetCallbacks()); auto decorateLuaContext = [&](LuaContext& context, MemoryAssetSourcePtr newFiles) { - auto callbacks = makeBaseAssetCallbacks(); if (newFiles) { + // re-add the assets callbacks with more functions + context.remove("assets"); + auto callbacks = makeBaseAssetCallbacks(); callbacks.registerCallback("add", [&newFiles](LuaEngine& engine, String const& path, LuaValue const& data) { ByteArray bytes; if (auto str = engine.luaMaybeTo(data)) @@ -184,9 +186,9 @@ Assets::Assets(Settings settings, StringList assetSources) { m_filesByExtension[AssetPath::extension(path).toLower()].erase(path); return erased; }); - } - context.setCallbacks("assets", callbacks); + context.setCallbacks("assets", callbacks); + } }; auto addSource = [&](String const& sourcePath, AssetSourcePtr source) { diff --git a/source/base/StarMixer.cpp b/source/base/StarMixer.cpp index 2e52afc..72a6cd6 100644 --- a/source/base/StarMixer.cpp +++ b/source/base/StarMixer.cpp @@ -231,6 +231,7 @@ void Mixer::stopAll(float rampTime) { void Mixer::read(int16_t* outBuffer, size_t frameCount, ExtraMixFunction extraMixFunction) { // Make this method as least locky as possible by copying all the needed // member data before the expensive audio / effect stuff. + float speed; unsigned sampleRate; unsigned channels; float volume; @@ -240,6 +241,7 @@ void Mixer::read(int16_t* outBuffer, size_t frameCount, ExtraMixFunction extraMi { MutexLocker locker(m_mutex); + speed = m_speed; sampleRate = m_sampleRate; channels = m_channels; volume = m_volume.value; @@ -266,8 +268,6 @@ void Mixer::read(int16_t* outBuffer, size_t frameCount, ExtraMixFunction extraMi for (size_t i = 0; i < bufferSize; ++i) outBuffer[i] = 0; - float speed = m_speed; - { MutexLocker locker(m_queueMutex); // Mix all active sounds