Skip to content

Commit

Permalink
Attempt to realign audio with main when alignPlaylists finds no ove…
Browse files Browse the repository at this point in the history
…rlap in playlist updates

#6823
  • Loading branch information
robwalch committed Nov 21, 2024
1 parent e9fd578 commit 50c9957
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/controller/audio-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { ElementaryStreamTypes, isMediaFragment } from '../loader/fragment';
import { Level } from '../types/level';
import { PlaylistContextType, PlaylistLevelType } from '../types/loader';
import { ChunkMetadata } from '../types/transmuxer';
import { alignMediaPlaylistByPDT } from '../utils/discontinuities';
import {
alignDiscontinuities,
alignMediaPlaylistByPDT,
} from '../utils/discontinuities';
import { mediaAttributesIdentical } from '../utils/media-option-attributes';
import type { FragmentTracker } from './fragment-tracker';
import type Hls from '../hls';
Expand Down Expand Up @@ -546,22 +549,23 @@ class AudioStreamController
if (newDetails.deltaUpdateFailed || !mainDetails) {
return;
}
if (
!track.details &&
newDetails.hasProgramDateTime &&
mainDetails.hasProgramDateTime
) {
// Make sure our audio rendition is aligned with the "main" rendition, using
// pdt as our reference times.
alignMediaPlaylistByPDT(newDetails, mainDetails);
sliding = newDetails.fragmentStart;
} else {

if (track.details) {
sliding = this.alignPlaylists(
newDetails,
track.details,
this.levelLastLoaded?.details,
);
}
if (!newDetails.alignedSliding) {
// Make sure our audio rendition is aligned with the "main" rendition, using
// pdt as our reference times.
alignDiscontinuities(newDetails, mainDetails);
if (!newDetails.alignedSliding) {
alignMediaPlaylistByPDT(newDetails, mainDetails);
}
sliding = newDetails.fragmentStart;
}
}
track.details = newDetails;
this.levelLastLoaded = track;
Expand Down

0 comments on commit 50c9957

Please sign in to comment.