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. 34
      ErsatzTV.Core/Scheduling/YamlScheduling/SequentialPlayoutBuilder.cs

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

@ -366,9 +366,14 @@ public class SequentialPlayoutBuilder( @@ -366,9 +366,14 @@ public class SequentialPlayoutBuilder(
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 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)
{
@ -376,9 +381,34 @@ public class SequentialPlayoutBuilder( @@ -376,9 +381,34 @@ public class SequentialPlayoutBuilder(
InstructionIndex = 0 // Start from beginning of new schedule
};
// Restore the items and history
// Restore all preserved state
context.AddedItems.AddRange(previousAddedItems);
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)

Loading…
Cancel
Save