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));
}