Skip to content

Commit

Permalink
fix: ensure pieces don't claim to have durations when their end has n…
Browse files Browse the repository at this point in the history
…ot yet been decided
  • Loading branch information
Julusian committed Sep 23, 2024
1 parent f4e61fa commit 250b5d7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/job-worker/src/playout/resolvedPieces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ export function getResolvedPiecesForPartInstancesOnTimeline(

const currentPartStarted = partInstancesInfo.current.partStarted ?? now
const nextPartStarted =
partInstancesInfo.current.partInstance.part.autoNext &&
partInstancesInfo.current.partInstance.part.expectedDuration !== undefined
? currentPartStarted + partInstancesInfo.current.partInstance.part.expectedDuration
: null

// Calculate the next part if needed
let nextResolvedPieces: ResolvedPieceInstance[] = []
if (partInstancesInfo.next && partInstancesInfo.current.partInstance.part.autoNext && nextPartStarted != null) {
if (partInstancesInfo.next && nextPartStarted != null) {
const nowInPart = partInstancesInfo.next.nowInPart
nextResolvedPieces = partInstancesInfo.next.pieceInstances.map((instance) =>
resolvePrunedPieceInstance(nowInPart, instance)
Expand Down
7 changes: 6 additions & 1 deletion packages/job-worker/src/playout/timeline/part.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ export function transformPartIntoTimeline(
}
break
case IBlueprintPieceType.Normal:
pieceEnable = getPieceEnableInsidePart(pieceInstance, partTimings, parentGroup.id)
pieceEnable = getPieceEnableInsidePart(
pieceInstance,
partTimings,
parentGroup.id,
parentGroup.enable.duration !== undefined || parentGroup.enable.end !== undefined
)
break
default:
assertNever(pieceInstance.piece.pieceType)
Expand Down
6 changes: 4 additions & 2 deletions packages/job-worker/src/playout/timeline/piece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export function transformPieceGroupAndObjects(
export function getPieceEnableInsidePart(
pieceInstance: ReadonlyDeep<PieceInstanceWithTimings>,
partTimings: PartCalculatedTimings,
partGroupId: string
partGroupId: string,
partHasEndTime: boolean
): TSR.Timeline.TimelineEnable {
const pieceEnable: TSR.Timeline.TimelineEnable = { ...pieceInstance.piece.enable }
if (typeof pieceEnable.start === 'number') {
Expand All @@ -103,7 +104,8 @@ export function getPieceEnableInsidePart(
}
}

if (partTimings.toPartPostroll) {
// If the part has an end time, we can consider post-roll
if (partHasEndTime && partTimings.toPartPostroll) {
if (!pieceEnable.duration) {
// make sure that the control object is shortened correctly
pieceEnable.duration = `#${partGroupId} - ${partTimings.toPartPostroll}`
Expand Down
4 changes: 3 additions & 1 deletion packages/job-worker/src/playout/timeline/rundown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ function generateCurrentInfinitePieceObjects(
const pieceEnable = getPieceEnableInsidePart(
pieceInstance,
currentPartInstanceTimings,
timingContext.currentPartGroup.id
timingContext.currentPartGroup.id,
timingContext.currentPartGroup.enable.end !== undefined ||
timingContext.currentPartGroup.enable.duration !== undefined
)

let nowInParent = currentPartInfo.nowInPart // Where is 'now' inside of the infiniteGroup?
Expand Down

0 comments on commit 250b5d7

Please sign in to comment.