@@ -28,11 +28,19 @@ import _ = require('underscore')
2828import { getPieceEnableInsidePart , transformPieceGroupAndObjects } from './piece'
2929import { logger } from '../../logging'
3030
31+ const DEFAULT_ABSOLUTE_PIECE_PREPARE_TIME = 30000
32+
3133/**
3234 * Some additional data used by the timeline generation process
3335 * Fields are populated as it progresses through generation, and consumed during the finalisation
3436 */
3537export interface RundownTimelineTimingContext {
38+ /**
39+ * How long an absolute timed piece should be on the timeline before it is played
40+ * This is a constant derived from the settings
41+ */
42+ readonly absolutePiecePrepareTime : number
43+
3644 currentPartGroup : TimelineObjGroupPart
3745 currentPartDuration : number | undefined
3846
@@ -140,10 +148,10 @@ export function buildTimelineObjsForRundown(
140148 const currentPartGroup = createPartGroup ( partInstancesInfo . current . partInstance , currentPartEnable )
141149
142150 const timingContext : RundownTimelineTimingContext = {
151+ absolutePiecePrepareTime :
152+ context . studio . settings . rundownGlobalPiecesPrepareTime || DEFAULT_ABSOLUTE_PIECE_PREPARE_TIME ,
143153 currentPartGroup,
144154 currentPartDuration : currentPartEnable . duration ,
145-
146- // regenerateTimelineAt: For future use
147155 }
148156
149157 // Start generating objects
@@ -280,19 +288,21 @@ function generateCurrentInfinitePieceObjects(
280288 return [ ]
281289 }
282290
283- const { pieceEnable, infiniteGroupEnable , nowInParent } = calculateInfinitePieceEnable (
291+ const pieceEnable = calculateInfinitePieceEnable (
284292 currentPartInfo ,
285293 timingContext ,
286294 pieceInstance ,
287295 currentTime ,
288296 currentPartInstanceTimings
289297 )
298+ // Not allowed to be generated
299+ if ( ! pieceEnable ) return [ ]
290300
291301 const { pieceInstanceWithUpdatedEndCap, cappedInfiniteGroupEnable } = applyInfinitePieceGroupEndCap (
292302 currentPartInfo ,
293303 timingContext ,
294304 pieceInstance ,
295- infiniteGroupEnable ,
305+ pieceEnable . infiniteGroupEnable ,
296306 currentPartInstanceTimings ,
297307 nextPartInstanceTimings ,
298308 nextPartInfinites . get ( pieceInstance . infinite . infiniteInstanceId )
@@ -317,9 +327,9 @@ function generateCurrentInfinitePieceObjects(
317327 ...transformPieceGroupAndObjects (
318328 activePlaylist . _id ,
319329 infiniteGroup ,
320- nowInParent ,
330+ pieceEnable . nowInParent ,
321331 pieceInstanceWithUpdatedEndCap ,
322- pieceEnable ,
332+ pieceEnable . pieceEnable ,
323333 0 ,
324334 groupClasses ,
325335 isInHold ,
@@ -355,6 +365,15 @@ function calculateInfinitePieceEnable(
355365 const infiniteGroupStart = pieceInstance . plannedStartedPlayback ?? pieceInstance . piece . enable . start
356366
357367 if ( typeof infiniteGroupStart === 'number' ) {
368+ if ( infiniteGroupStart > currentTime + timingContext . absolutePiecePrepareTime ) {
369+ // This piece is starting too far in the future, omit it from the timeline
370+ timingContext . regenerateTimelineAt = Math . min (
371+ timingContext . regenerateTimelineAt ?? Number . POSITIVE_INFINITY ,
372+ infiniteGroupStart - timingContext . absolutePiecePrepareTime
373+ )
374+ return null
375+ }
376+
358377 nowInParent = currentTime - infiniteGroupStart
359378 } else {
360379 // We should never hit this, but in case start is "now"
0 commit comments