This is the first implementation, might need a few iterations.
The basic idea is to use something kind of like a ring buffer for game updates, but one that has non-destructive reads.
This means that the first update (like when a game is first selected for display on start or when coming back from the rotation of other games from a inning break) happens in real time. But the second update is just added to the queue, and this update won't become the "live" displayed data until after the buffer is full and overwrites the first data that was fetched.
For a ring buffer of size 5, this will mean (5 -1) * (10 seconds/update) = 40 seconds of delay, which was what I needed to sync a stream of the Mets-Marlins game nearly perfectly in testing.
The ring buffer needs to be at least size 1, so I made the config start at 0 and I add 1 to it, which has the nice benefit of making the number in the config a divisor of the delay in the end
Notes:
This only has the chance to take effect in games which are receiving updates while they're displayed, which means basically only the "preferred" game. Games which are shown during the rotation of inning breaks are still giving you a live snapshot. Delaying those would require storing data for all live games, which I don't want to hammer the MLB API with
This does make the inning break rotation shorter by about the same length of the delay, since the transition from the preferred game to the rotation is delayed, but leaving the rotation at the end of the break is still in live-time
There was not an obvious place to put this in the config, and the name I chose for the option is probably bad.
Because we're just buffering updates, the delay can only be done in multiples of the update time (10 seconds)
I chose a default of 0 for the delay setting (corresponding to a ring buffer of size 1, which means basically a no-op/the existing behavior).
In my brief testing, a delay of 4 syncs up with online streams, YMMV on live tv
Closes #439.
This is the first implementation, might need a few iterations.
The basic idea is to use something kind of like a ring buffer for game updates, but one that has non-destructive reads.
This means that the first update (like when a game is first selected for display on start or when coming back from the rotation of other games from a inning break) happens in real time. But the second update is just added to the queue, and this update won't become the "live" displayed data until after the buffer is full and overwrites the first data that was fetched.
For a ring buffer of size 5, this will mean (5 -1) * (10 seconds/update) = 40 seconds of delay, which was what I needed to sync a stream of the Mets-Marlins game nearly perfectly in testing. The ring buffer needs to be at least size 1, so I made the config start at 0 and I add 1 to it, which has the nice benefit of making the number in the config a divisor of the delay in the end
Notes: