Do not request video buffer flush or EOS when the main playlist is audio-only

This commit is contained in:
Rob Walch
2026-05-22 14:42:05 -07:00
committed by Rob Walch
parent 8dd7373bf3
commit 7f6ac1169d
5 changed files with 14 additions and 13 deletions
+1 -1
View File
@@ -808,7 +808,7 @@ export type BufferCreatedTrackSet = Partial<Record<SourceBufferName, BufferCreat
// @public (undocumented)
export interface BufferEOSData {
// (undocumented)
type?: SourceBufferName;
type: SourceBufferName | null;
}
// Warning: (ae-missing-release-tag) "BufferFlushedData" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+1 -1
View File
@@ -1179,7 +1179,7 @@ transfer tracks: ${stringify(transferredTracks, (key, value) => (key === 'initSe
}
// on BUFFER_EOS mark matching sourcebuffer(s) as "ending" and "ended" and queue endOfStream after remaining operations(s)
// an undefined data.type will mark all buffers as EOS.
// a nullish data.type will mark all buffers as EOS.
private onBufferEos(event: Events.BUFFER_EOS, data: BufferEOSData) {
this.sourceBuffers.forEach(([type]) => {
if (type) {
+10 -9
View File
@@ -270,10 +270,9 @@ export default class StreamController
const lastDetails = this.getLevelDetails();
if (lastDetails && this._streamEnded(bufferInfo, lastDetails)) {
const data: BufferEOSData = {};
if (this.altAudio === AlternateAudio.SWITCHED) {
data.type = 'video';
}
const data: BufferEOSData = {
type: this.targetBufferType(),
};
this.hls.trigger(Events.BUFFER_EOS, data);
this.state = State.ENDED;
@@ -489,11 +488,13 @@ export default class StreamController
}
protected flushMainBuffer(startOffset: number, endOffset: number) {
super.flushMainBuffer(
startOffset,
endOffset,
this.altAudio === AlternateAudio.SWITCHED ? 'video' : null,
);
super.flushMainBuffer(startOffset, endOffset, this.targetBufferType());
}
private targetBufferType(): 'video' | null {
return this.altAudio === AlternateAudio.SWITCHED && !this.audioOnly
? 'video'
: null;
}
protected onMediaAttached(
+1 -1
View File
@@ -106,7 +106,7 @@ export interface BufferAppendedData {
}
export interface BufferEOSData {
type?: SourceBufferName;
type: SourceBufferName | null;
}
export interface BufferFlushingData {
@@ -1092,7 +1092,7 @@ describe('BufferController with attached media', function () {
describe('onBufferEos', function () {
it('marks the ExtendedSourceBuffer as ended', function () {
// No type arg ends both SourceBuffers
hls.trigger(Events.BUFFER_EOS, {});
hls.trigger(Events.BUFFER_EOS, { type: null });
queueNames.forEach((type) => {
const track = getSourceBufferTrack(bufferController, type);
const buffer = track?.buffer;