#include "RuntimeServiceLiveBridge.h" #include "RenderEngine.h" #include "RuntimeServices.h" #include namespace { void DrainServiceEvents(RuntimeServices& runtimeServices, RenderEngine& renderEngine) { std::vector appliedOscUpdates; std::vector completedOscCommits; std::string oscError; if (!runtimeServices.ApplyPendingOscUpdates(appliedOscUpdates, oscError) && !oscError.empty()) OutputDebugStringA(("OSC apply failed: " + oscError + "\n").c_str()); runtimeServices.ConsumeCompletedOscCommits(completedOscCommits); std::vector overlayUpdates; overlayUpdates.reserve(appliedOscUpdates.size()); for (const RuntimeServices::AppliedOscUpdate& update : appliedOscUpdates) { overlayUpdates.push_back({ update.routeKey, update.layerKey, update.parameterKey, update.targetValue }); } std::vector overlayCommitCompletions; overlayCommitCompletions.reserve(completedOscCommits.size()); for (const RuntimeServices::CompletedOscCommit& completedCommit : completedOscCommits) { overlayCommitCompletions.push_back({ completedCommit.routeKey, completedCommit.generation }); } renderEngine.UpdateOscOverlayState(overlayUpdates, overlayCommitCompletions); } void QueueServiceCommitRequests( RuntimeServices& runtimeServices, const std::vector& commitRequests) { for (const RenderEngine::OscOverlayCommitRequest& commitRequest : commitRequests) { std::string commitError; if (!runtimeServices.QueueOscCommit( commitRequest.routeKey, commitRequest.layerKey, commitRequest.parameterKey, commitRequest.value, commitRequest.generation, commitError) && !commitError.empty()) { OutputDebugStringA(("OSC commit queue failed: " + commitError + "\n").c_str()); } } } } bool RuntimeServiceLiveBridge::PrepareLiveRenderLayerStates( RuntimeServices& runtimeServices, RenderEngine& renderEngine, bool useCommittedLayerStates, unsigned renderWidth, unsigned renderHeight, double oscSmoothing, std::vector& layerStates) { DrainServiceEvents(runtimeServices, renderEngine); std::vector commitRequests; const bool resolved = renderEngine.ResolveRenderLayerStates( useCommittedLayerStates, renderWidth, renderHeight, oscSmoothing, &commitRequests, layerStates); QueueServiceCommitRequests(runtimeServices, commitRequests); return resolved; }