pass 1
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m39s
CI / Windows Release Package (push) Successful in 2m45s

This commit is contained in:
Aiden
2026-05-11 01:12:24 +10:00
parent 53e78890a8
commit c4883d3413
16 changed files with 618 additions and 303 deletions

View File

@@ -9,10 +9,7 @@
ControlServices::ControlServices() :
mControlServer(std::make_unique<ControlServer>()),
mOscServer(std::make_unique<OscServer>()),
mPollRunning(false),
mRegistryChanged(false),
mReloadRequested(false),
mPollFailed(false)
mPollRunning(false)
{
}
@@ -34,9 +31,9 @@ bool ControlServices::Start(OpenGLComposite& composite, RuntimeStore& runtimeSto
return true;
}
void ControlServices::BeginPolling(RuntimeStore& runtimeStore)
void ControlServices::BeginPolling(RuntimeCoordinator& runtimeCoordinator)
{
StartPolling(runtimeStore);
StartPolling(runtimeCoordinator);
}
void ControlServices::Stop()
@@ -158,28 +155,23 @@ void ControlServices::ConsumeCompletedOscCommits(std::vector<CompletedOscCommit>
completedCommits.swap(mCompletedOscCommits);
}
RuntimePollEvents ControlServices::ConsumePollEvents()
void ControlServices::ConsumeRuntimeCoordinatorResults(std::vector<RuntimeCoordinatorServiceResult>& results)
{
RuntimePollEvents events;
events.registryChanged = mRegistryChanged.exchange(false);
events.reloadRequested = mReloadRequested.exchange(false);
events.failed = mPollFailed.exchange(false);
results.clear();
if (events.failed)
{
std::lock_guard<std::mutex> lock(mPollErrorMutex);
events.error = mPollError;
}
std::lock_guard<std::mutex> lock(mRuntimeCoordinatorResultMutex);
if (mRuntimeCoordinatorResults.empty())
return;
return events;
results.swap(mRuntimeCoordinatorResults);
}
void ControlServices::StartPolling(RuntimeStore& runtimeStore)
void ControlServices::StartPolling(RuntimeCoordinator& runtimeCoordinator)
{
if (mPollRunning.exchange(true))
return;
mPollThread = std::thread([this, &runtimeStore]() { PollLoop(runtimeStore); });
mPollThread = std::thread([this, &runtimeCoordinator]() { PollLoop(runtimeCoordinator); });
}
void ControlServices::StopPolling()
@@ -191,7 +183,7 @@ void ControlServices::StopPolling()
mPollThread.join();
}
void ControlServices::PollLoop(RuntimeStore& runtimeStore)
void ControlServices::PollLoop(RuntimeCoordinator& runtimeCoordinator)
{
while (mPollRunning)
{
@@ -202,46 +194,41 @@ void ControlServices::PollLoop(RuntimeStore& runtimeStore)
}
for (const auto& entry : pendingCommits)
{
std::string commitError;
if (runtimeStore.SetStoredParameterValueByControlKey(
const RuntimeCoordinatorResult result = runtimeCoordinator.CommitOscParameterByControlKey(
entry.second.layerKey,
entry.second.parameterKey,
entry.second.value,
false,
commitError))
entry.second.value);
if (result.accepted)
{
CompletedOscCommit completedCommit;
completedCommit.routeKey = entry.second.routeKey;
completedCommit.generation = entry.second.generation;
std::lock_guard<std::mutex> lock(mCompletedOscCommitMutex);
mCompletedOscCommits.push_back(std::move(completedCommit));
QueueRuntimeCoordinatorResult(result);
}
else if (!commitError.empty())
else if (!result.errorMessage.empty())
{
OutputDebugStringA(("OSC commit failed: " + commitError + "\n").c_str());
OutputDebugStringA(("OSC commit failed: " + result.errorMessage + "\n").c_str());
}
}
bool registryChanged = false;
bool reloadRequested = false;
std::string runtimeError;
if (!runtimeStore.PollStoredFileChanges(registryChanged, reloadRequested, runtimeError))
{
{
std::lock_guard<std::mutex> lock(mPollErrorMutex);
mPollError = runtimeError;
}
mPollFailed = true;
}
else
{
if (registryChanged)
mRegistryChanged = true;
if (reloadRequested)
mReloadRequested = true;
}
const RuntimeCoordinatorResult pollResult = runtimeCoordinator.PollRuntimeStoreChanges(registryChanged);
if (pollResult.runtimeStateBroadcastRequired || pollResult.shaderBuildRequested || pollResult.compileStatusChanged)
QueueRuntimeCoordinatorResult(pollResult, pollResult.compileStatusChanged && !pollResult.compileStatusSucceeded && !pollResult.compileStatusMessage.empty());
for (int i = 0; i < 25 && mPollRunning; ++i)
Sleep(10);
}
}
void ControlServices::QueueRuntimeCoordinatorResult(const RuntimeCoordinatorResult& result, bool failed)
{
RuntimeCoordinatorServiceResult serviceResult;
serviceResult.result = result;
serviceResult.failed = failed;
std::lock_guard<std::mutex> lock(mRuntimeCoordinatorResultMutex);
mRuntimeCoordinatorResults.push_back(std::move(serviceResult));
}

View File

@@ -1,6 +1,7 @@
#pragma once
#include "RuntimeJson.h"
#include "RuntimeCoordinator.h"
#include "ShaderTypes.h"
#include <atomic>
@@ -16,12 +17,10 @@ class OpenGLComposite;
class OscServer;
class RuntimeStore;
struct RuntimePollEvents
struct RuntimeCoordinatorServiceResult
{
bool registryChanged = false;
bool reloadRequested = false;
RuntimeCoordinatorResult result;
bool failed = false;
std::string error;
};
class ControlServices
@@ -45,7 +44,7 @@ public:
~ControlServices();
bool Start(OpenGLComposite& composite, RuntimeStore& runtimeStore, std::string& error);
void BeginPolling(RuntimeStore& runtimeStore);
void BeginPolling(RuntimeCoordinator& runtimeCoordinator);
void Stop();
void BroadcastState();
void RequestBroadcastState();
@@ -54,7 +53,7 @@ public:
bool QueueOscCommit(const std::string& routeKey, const std::string& layerKey, const std::string& parameterKey, const JsonValue& value, uint64_t generation, std::string& error);
void ClearOscState();
void ConsumeCompletedOscCommits(std::vector<CompletedOscCommit>& completedCommits);
RuntimePollEvents ConsumePollEvents();
void ConsumeRuntimeCoordinatorResults(std::vector<RuntimeCoordinatorServiceResult>& results);
private:
struct PendingOscUpdate
@@ -73,19 +72,17 @@ private:
uint64_t generation = 0;
};
void StartPolling(RuntimeStore& runtimeStore);
void StartPolling(RuntimeCoordinator& runtimeCoordinator);
void StopPolling();
void PollLoop(RuntimeStore& runtimeStore);
void PollLoop(RuntimeCoordinator& runtimeCoordinator);
void QueueRuntimeCoordinatorResult(const RuntimeCoordinatorResult& result, bool failed = false);
std::unique_ptr<ControlServer> mControlServer;
std::unique_ptr<OscServer> mOscServer;
std::thread mPollThread;
std::atomic<bool> mPollRunning;
std::atomic<bool> mRegistryChanged;
std::atomic<bool> mReloadRequested;
std::atomic<bool> mPollFailed;
std::mutex mPollErrorMutex;
std::string mPollError;
std::mutex mRuntimeCoordinatorResultMutex;
std::vector<RuntimeCoordinatorServiceResult> mRuntimeCoordinatorResults;
std::mutex mPendingOscMutex;
std::map<std::string, PendingOscUpdate> mPendingOscUpdates;
std::mutex mPendingOscCommitMutex;

View File

@@ -17,10 +17,10 @@ bool RuntimeServices::Start(OpenGLComposite& composite, RuntimeStore& runtimeSto
return mControlServices && mControlServices->Start(composite, runtimeStore, error);
}
void RuntimeServices::BeginPolling(RuntimeStore& runtimeStore)
void RuntimeServices::BeginPolling(RuntimeCoordinator& runtimeCoordinator)
{
if (mControlServices)
mControlServices->BeginPolling(runtimeStore);
mControlServices->BeginPolling(runtimeCoordinator);
}
void RuntimeServices::Stop()
@@ -79,7 +79,13 @@ void RuntimeServices::ConsumeCompletedOscCommits(std::vector<CompletedOscCommit>
mControlServices->ConsumeCompletedOscCommits(completedCommits);
}
RuntimePollEvents RuntimeServices::ConsumePollEvents()
void RuntimeServices::ConsumeRuntimeCoordinatorResults(std::vector<RuntimeCoordinatorServiceResult>& results)
{
return mControlServices ? mControlServices->ConsumePollEvents() : RuntimePollEvents{};
if (!mControlServices)
{
results.clear();
return;
}
mControlServices->ConsumeRuntimeCoordinatorResults(results);
}

View File

@@ -5,6 +5,7 @@
#include <memory>
#include <string>
class OpenGLComposite;
class RuntimeCoordinator;
class RuntimeStore;
class RuntimeServices
@@ -17,7 +18,7 @@ public:
~RuntimeServices();
bool Start(OpenGLComposite& composite, RuntimeStore& runtimeStore, std::string& error);
void BeginPolling(RuntimeStore& runtimeStore);
void BeginPolling(RuntimeCoordinator& runtimeCoordinator);
void Stop();
void BroadcastState();
void RequestBroadcastState();
@@ -26,7 +27,7 @@ public:
bool QueueOscCommit(const std::string& routeKey, const std::string& layerKey, const std::string& parameterKey, const JsonValue& value, uint64_t generation, std::string& error);
void ClearOscState();
void ConsumeCompletedOscCommits(std::vector<CompletedOscCommit>& completedCommits);
RuntimePollEvents ConsumePollEvents();
void ConsumeRuntimeCoordinatorResults(std::vector<RuntimeCoordinatorServiceResult>& results);
private:
std::unique_ptr<ControlServices> mControlServices;