Skip to content

Commit e0ad4c0

Browse files
authored
Merge pull request Sofie-Automation#1710 from evs-broadcast/fix/abPlaybackLookaheads
Fix for AB playback lookahead player assignment
2 parents 02b352b + 6d1e709 commit e0ad4c0

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

packages/job-worker/src/playout/abPlayback/__tests__/abPlaybackResolver.spec.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,56 @@ describe('resolveAbAssignmentsFromRequests', () => {
639639
expectGotPlayer(res, 'd', undefined)
640640
})
641641

642+
test('Autonext lookahead assignment with more clips than players', () => {
643+
const requests: SessionRequest[] = [
644+
// first part
645+
{
646+
id: 'a',
647+
name: 'a',
648+
start: 1000,
649+
end: 5000,
650+
playerId: 1,
651+
pieceNames: ['p1'],
652+
},
653+
// second part
654+
{
655+
id: 'b',
656+
name: 'b',
657+
start: 5000,
658+
end: 10000,
659+
playerId: 2,
660+
pieceNames: ['p2'],
661+
},
662+
// third part
663+
{
664+
id: 'c',
665+
name: 'c',
666+
start: 10000,
667+
end: 15000,
668+
playerId: 1,
669+
pieceNames: ['p3'],
670+
},
671+
// lookaheads (in order of future use)
672+
{
673+
id: 'z',
674+
name: 'z',
675+
start: 0,
676+
end: 100,
677+
lookaheadRank: 1,
678+
pieceNames: [],
679+
},
680+
]
681+
682+
const res = resolveAbAssignmentsFromRequests(resolverOptions, TWO_SLOTS, requests, 5100)
683+
expect(res).toBeTruthy()
684+
expect(res.failedOptional).toEqual([])
685+
expect(res.failedRequired).toEqual([])
686+
expectGotPlayer(res, 'a', 1)
687+
expectGotPlayer(res, 'b', 2)
688+
expectGotPlayer(res, 'c', 1)
689+
expectGotPlayer(res, 'z', 2)
690+
})
691+
642692
test('Preserve on-air optional over a required', () => {
643693
const requests: SessionRequest[] = [
644694
// current part

packages/job-worker/src/playout/abPlayback/abPlaybackResolver.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ function assignPlayersForLookahead(
361361
Array.from(lastSessionPerSlot.entries()),
362362
(session) => session[1] < safeNow
363363
)
364+
// We want to assign the ones that are clear soonest first, as they are more likely to be ready in time
365+
playersClearSoon.sort((endA, endB) => endA[1] - endB[1])
364366

365367
// Assign the players which are clear right now
366368
const playersClearNowIds = new Set(playersClearNow.map((p) => p[0]))

0 commit comments

Comments
 (0)