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

Fix stalling on discontinuity with audio track #2919

Merged
merged 3 commits into from Jul 26, 2020

Conversation

robwalch
Copy link
Collaborator

@robwalch robwalch commented Jul 24, 2020

This PR will...

Improve the handling of audio-stream-controller waitingFrag by:

  • Always removing the waiting fragment from the fragment tracker when clearing it before it's appended
  • Use fragment-finders fragmentWithinToleranceTest in audio-stream-controller
  • Parse waiting fragment when fragment cc initPTS is known (so that we establish sync with video)
  • Drop waiting fragment when:
    • video cc has changed since waiting fragment was set but not to the cc needed to parse waiting cc
    • The waiting fragment is no longer the audio fragment that needs to be buffered

Why is this Pull Request needed?

The audio-stream-controller got stuck on discontinuities for because the waiting was not used when it should be and it's status was not managed correctly:

  1. videoTrackCC is only updated once initPTS[waitingFragCC] is available, which caused the waiting fragment to be cleared before onInitPtsFound could fire. Using videoTrackCC to see if we still needed the waiting fragment simply did not work.
  2. waitingFrag was set to null in several places, requiring that fragment to be reloaded, but without clearing it's status from the fragment-tracker, so it would not reload.

Are there any points in the code the reviewer needs to double check?

Resolves issues:

Resolved #2913, #2545
Related to #2832

Checklist

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • API or design changes are documented in API.md

// Ensure we don't get stuck in the WAITING_INIT_PTS state if the waiting frag CC doesn't match any initPTS
const waitingFrag = this.waitingFragment;
if (waitingFrag) {
const waitingFragCC = waitingFrag.frag.cc;
if (videoTrackCC !== waitingFragCC) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We're actually waiting for videoTrackCC to increment so this is not a good check.

@@ -320,26 +297,24 @@ class AudioStreamController extends BaseStreamController {
}
break;
case State.WAITING_INIT_PTS:
const videoTrackCC = this.videoTrackCC;
if (this.initPTS[videoTrackCC] === undefined) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

videoTrackCC is set in onInitPTS so I don't see how this check would ever be true.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What we really want to know here is stream-controller current fragment - which fragment cc and start time is being loaded and whether that is close to or precedes our waiting fragment without any audio buffer gaps in between.

@robwalch robwalch force-pushed the bugfix/audio-waiting-fragment branch from 0b4c12f to a3c587c Compare July 24, 2020 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Playback stalls with unmuxed content when discontinuities are encountered
1 participant