-
Notifications
You must be signed in to change notification settings - Fork 221
[RFC] examples/ola_recorder: mitigate against drifting playback offset #1680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
b82b970
c8938be
9bdf9df
7ac4cc6
b25674b
2569a48
28256a2
dc605a9
1f783db
a8f5c23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,15 +216,18 @@ ShowLoader::State ShowPlayer::SeekTo(uint64_t seek_time) { | |
| break; | ||
| } | ||
| } | ||
| uint64_t timeout = playhead_time - seek_time; | ||
| m_playback_pos = playhead_time; | ||
| m_clock.CurrentTime(&m_start_ts); | ||
| m_start_playback_pos = m_playback_pos - timeout; | ||
|
|
||
| // Send data in the state it would be in at the given time | ||
| map<unsigned int, ShowEntry>::iterator entry_it; | ||
| for (entry_it = entries.begin(); entry_it != entries.end(); ++entry_it) { | ||
| SendFrame(entry_it->second); | ||
| } | ||
| // Adjust the timeout to handle landing in the middle of the entry's timeout | ||
| RegisterNextTimeout(playhead_time-seek_time); | ||
| RegisterNextTimeout(timeout); | ||
|
|
||
| return ShowLoader::OK; | ||
| } | ||
|
|
@@ -270,8 +273,26 @@ void ShowPlayer::SendEntry(const ShowEntry &entry) { | |
| SendFrame(entry); | ||
| m_playback_pos += entry.next_wait; | ||
|
|
||
| unsigned int timeout = entry.next_wait; | ||
| if (!m_simulate) { | ||
| // Using int64_t for target_delta here because | ||
| // we have to lose 1 bit anyway as InMilliSeconds() returns a signed | ||
| // 64-bit integer. | ||
shenghaoyang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ola::TimeStamp now; | ||
| m_clock.CurrentTime(&now); | ||
| int64_t target_delta = m_playback_pos - m_start_playback_pos; | ||
| int64_t current_delta = (now - m_start_ts).InMilliSeconds(); | ||
| int64_t delay = target_delta - current_delta; | ||
| if (delay < 0) { | ||
| OLA_WARN << "Frame at line " << m_loader.GetCurrentLineNumber() | ||
| << " was meant to have completed " << -delay << " ms ago." | ||
| << " System too slow?"; | ||
| delay = 0; | ||
| } | ||
| timeout = delay; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this could be simplified a bit by just writing the (more accurate delay) directly into the timeout variable, i.e. when we're in real time mode we can calculate the actual value, not an idealised simulate one.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The The idealized simulated one comes from Unless you mean to have the idealized calculation inside the branch instead?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was meaning something like this: Unless you were going to say add some debug level stats about how delay and ideal timeout compare each time, rather than just when it won't fit, then tracking them both independently seemed a bit irrelevant. Given they're essentially equivalent. Or you could possibly even do something like this (i.e. the non-simulate run corrects the idealised view):
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, That's why I needed to evaluate both If we subtract timeout by
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but m_playback_pos is where we should be when we've finished this delay (in relative time) and m_start_playback_pos is where in the showfile we started (relative). So
I don't follow, the maths is the same as your PR currently does, it's just I've reduced the number of variables and slightly tweaked how its laid out.
Looks like I made a typo before, it still needs a little bit of work but I think something along those lines should be possible.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you still remember how this works I think you could make that change? I didn't quite get what you meant last time, and unwinding everything now is even more... confusing 💀
peternewman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| // Set when next to send data | ||
| RegisterNextTimeout(entry.next_wait); | ||
| RegisterNextTimeout(timeout); | ||
| } | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.