Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/base
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-04-08 18:10:09 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-04-08 18:10:09 +1000
commitb89b8d585e3da04e45e8e6fe04b1728100e9071c (patch)
treeadfc04f39d180856586252c50340c12cfb19b555 /source/base
parent4a3ffadecba57e64ebd8f6f6c4d15744c38e52b9 (diff)
oops - restore assets modification to load scripts
Diffstat (limited to 'source/base')
-rw-r--r--source/base/StarAssets.cpp8
-rw-r--r--source/base/StarMixer.cpp4
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<String>(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