Skip to content
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

VideoPlayerAudio: limit max allowed Out-Of-Sync for "self-learning" to 80 ms #25233

Merged
merged 1 commit into from
May 20, 2024

Conversation

thexai
Copy link
Member

@thexai thexai commented May 19, 2024

Description

VideoPlayerAudio: limit max allowed Out-Of-Sync for "self-learning" to 80 ms

Motivation and context

As commented in #25229 recently found that use high values for maxpassthroughoffsyncduration e.g. 96 ms breaks a/v sync corrections because AE cannot correct error bigger that 2 * frame time. And since current "self-learning" algo calculates this value based in first seconds of stream is very influenced by bad a/v sync at start (and not yet corrected) and noise in error calculations (system clock irregularities, etc.).

With all this is possible too large values (even max. 100 ms) that cause error is accumulated and never corrected or too small values (25/30 ms) that may cause accidental corrections if error is bigger later (or noise in error only).

Then is better replace self-learning with a frame time based value, obtaining much more predictable operation.

1.5 * frame_time seems good value and has been well tested. Higher values could be used and up to 1.95 * frame_time has been tested to work well (a/v corrections occur when necessary) but not has much sense use high values now because the main use case is TrueHD (due error oscillation) but now this is mitigated in #25229 and no visible frame skips/repeats with 62 ms.

In general high values produces worse a/v sync because allows bigger stationary error (never corrected).

Users still may use high values via advancedsettings but a log warning is printed if value is > 1.95 * frame_time.

If any cases are discovered where accidental corrections continue to occur, instead of raising the threshold, the root cause should be investigated and reduce the error or noise in error, etc.

How has this been tested?

Runtime Shield

What is the effect on users?

For users who did not use advancedsettings it's a significant improvement because it prevents random problems because the value used could be too large or too low in specific (random) cases.

For users who use advancedsettings nothing changes but it is encouraged to use "better" values.

Screenshots (if appropriate):

Two very different cases in which the value of 1.5 * frame time works well:

FreeGuy-62

Cars-62

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • Student submission (PR was done for educational purposes and will be treated as such)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@thexai thexai added Type: Fix non-breaking change which fixes an issue Type: Improvement non-breaking change which improves existing functionality Component: Audio v22 "P" labels May 19, 2024
@thexai thexai added this to the "P" 22.0 Alpha 1 milestone May 19, 2024
@thexai thexai requested a review from fritsch May 19, 2024 14:39
… 80 ms

i.e: values of 81 to 100 ms are too close to the 100 ms threshold and can
cause A/V sync not to work the way it was designed causing audio dropouts
on some TrueHD sources.
@thexai thexai changed the title VideoPlayerAudio: use a value based on video fps for max allowed Out-Of-Sync VideoPlayerAudio: limit max allowed Out-Of-Sync for "self-learning" to 80 ms May 20, 2024
@thexai
Copy link
Member Author

thexai commented May 20, 2024

For now only I want fix unwanted behavior with default settings, then only limit self-learning to 80 ms. This in conjunction with error compensation (0.45 factor) is enough for TrueHD.

And backport these very small fixes to Omega.

@thexai thexai added Backport: Needed and removed Type: Improvement non-breaking change which improves existing functionality labels May 20, 2024
Copy link
Member

@fritsch fritsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - small steps are good.

@thexai thexai merged commit 3b2688a into xbmc:master May 20, 2024
2 checks passed
@thexai thexai deleted the fix-self-learning branch May 20, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport: Done Component: Audio Type: Fix non-breaking change which fixes an issue v22 "P"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants