Browse Source

Ensure Playout Builder preserves entire state before creating a new context

pull/2682/head
Carson Kompon 8 months ago committed by Jason Dove
parent
commit
503f04af10
No known key found for this signature in database
  1. 40
      ErsatzTV.Core/Scheduling/YamlScheduling/SequentialPlayoutBuilder.cs

40
ErsatzTV.Core/Scheduling/YamlScheduling/SequentialPlayoutBuilder.cs

@ -317,7 +317,7 @@ public class SequentialPlayoutBuilder(
// Switch to the new schedule // Switch to the new schedule
currentSchedule = newSchedule; currentSchedule = newSchedule;
// Get the new schedule's instructions // Get the new schedule's instructions
List<YamlPlayoutInstruction> newPlayoutInstructions; List<YamlPlayoutInstruction> newPlayoutInstructions;
if (newSchedule != null) if (newSchedule != null)
@ -366,19 +366,49 @@ public class SequentialPlayoutBuilder(
newFlattenCount++; newFlattenCount++;
} }
// Preserve existing items and history, create new context with new definition // Preserve existing state before creating new context
var previousAddedItems = context.AddedItems.ToList(); var previousAddedItems = context.AddedItems.ToList();
var previousAddedHistory = context.AddedHistory.ToList(); var previousAddedHistory = context.AddedHistory.ToList();
var previousPreRollSequence = context.GetPreRollSequence();
var previousPostRollSequence = context.GetPostRollSequence();
var previousMidRollSequence = context.GetMidRollSequence();
var previousWatermarkIds = context.GetChannelWatermarkIds();
var previousGraphicsElements = context.GetGraphicsElements();
context = new YamlPlayoutContext(playout, effectiveDefinition, 1) context = new YamlPlayoutContext(playout, effectiveDefinition, 1)
{ {
CurrentTime = context.CurrentTime, CurrentTime = context.CurrentTime,
InstructionIndex = 0 // Start from beginning of new schedule InstructionIndex = 0 // Start from beginning of new schedule
}; };
// Restore the items and history // Restore all preserved state
context.AddedItems.AddRange(previousAddedItems); context.AddedItems.AddRange(previousAddedItems);
context.AddedHistory.AddRange(previousAddedHistory); context.AddedHistory.AddRange(previousAddedHistory);
foreach (string preRoll in previousPreRollSequence)
{
context.SetPreRollSequence(preRoll);
}
foreach (string postRoll in previousPostRollSequence)
{
context.SetPostRollSequence(postRoll);
}
foreach (var midRoll in previousMidRollSequence)
{
context.SetMidRollSequence(midRoll);
}
foreach (int watermarkId in previousWatermarkIds)
{
context.SetChannelWatermarkId(watermarkId);
}
foreach (var (graphicsId, variablesJson) in previousGraphicsElements)
{
context.SetGraphicsElement(graphicsId, variablesJson);
}
} }
if (context.InstructionIndex >= effectiveDefinition.Playout.Count) if (context.InstructionIndex >= effectiveDefinition.Playout.Count)

Loading…
Cancel
Save