MLB-LED-Scoreboard / mlb-led-scoreboard

An LED scoreboard for Major League Baseball :baseball:
GNU General Public License v3.0
582 stars 105 forks source link

Add ability to buffer game updates for syncing with TV #442

Closed WardBrian closed 1 year ago

WardBrian commented 1 year ago

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: