Fix: HA & Demux - Audio Increment Not Respecting Position Diff-Threshold #301
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When dealing with source demuxed vods which have video segment lengths longer than the audio counterparts, the CE is to increment the media sequence for the audio playhead position so that it is always further into the content than video, ie "fast forwarding" in a sense.
eg. If the current playhead position for video is 296 secs and audio is 291.84 secs, then audio would need to increment further until the audio position is >= video position.
However, there is a diff threshold set to 0.250s. This means that if the difference between the positions is below 0.250, then the CE is happy with the current positions. The difference should be insignificant for most players and the video segment should be able to be paired with the audio segment.
The issue is though that CE still increments by 2 even though it should be happy with one. This is caused by a mistake in a do-while loop.
This PR fixes this by refactoring the audio increment loop, replacing it with a new function and
unit tests
to validate its expected behaviors. The new function will also be used to calculate the increment value for subtitles, given that the subtitle delta positions are correct.