RFC: Timer-based CD audio sync
|Reported by:||eriktorbjorn||Owned by:||Kirben|
|Cc:||Game:||Monkey Island 1|
This is an experimental patch that uses a real timer to update the "MI1 timer", i.e. the timer that is responsible for keeping the game in sync with CD audio.
My reasoning for this is that it's hard for scummLoop() to keep the time on its own, what with things like screen effects causing unpredictable delays while the CD track just keeps running in the background.
At first I wanted to use the current position in the CD/MP3 track, but that turned out to be tricky, and it would still need a fallback mechanism in case the sound fails to play for whatever reason.
It isn't flawless. For one thing, keeping in sync with the Loom CD isn't an exact science. Another problem is that the timer keeps running even when the game is paused, which completely screws up the sync when the game is resumed. (Hmm... it didn't occur to me until now, but could the timer handler check for that condition somehow?) Reloading a saved game in the middle of a timed sequence might be a bit off, too, but it should make a reasonably dignified recovery.
But aside from that bug, and regardless of how we implement it, I don't think we'll ever be able to get better sync than what this patch provides.
I've tested this patch with the Loom CD, and the MI1 intro, and they currently require slightly different timing, so I'd be grateful if someone could test it with whatever other games there are that use CD audio. (Zak 256?)
Ticket imported from: #611997. Ticket imported from: patches/163.