Skip to content

Commit

Permalink
Fix remaining issue when playing lowlat w/o mse-in-worker
Browse files Browse the repository at this point in the history
  • Loading branch information
peaBerberian committed Sep 1, 2023
1 parent f7f8c7a commit d831576
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
19 changes: 14 additions & 5 deletions src/worker/media_source_interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,27 @@ export class SourceBufferInterface extends EventEmitter<ISourceBufferInterfaceEv
sourceBuffer.appendBuffer(data);
return;
} else {
const abData = data instanceof ArrayBuffer ?
data :
data.buffer;
// TODO are we forced to copy here?
let segmentBufferPushed : ArrayBuffer;
if (data instanceof ArrayBuffer) {
segmentBufferPushed = data;
} else if (data.byteLength === data.buffer.byteLength) {
segmentBufferPushed = data.buffer;
} else {
segmentBufferPushed = data.buffer.slice(
data.byteOffset,
data.byteLength + data.byteOffset
);
}
sendMessage({
type: "append-buffer",
mediaSourceId: this._state.mediaSourceId,
sourceBufferType: this.type,
value: {
data: abData,
data: segmentBufferPushed,
params,
},
}, [abData]);
}, [segmentBufferPushed]);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/worker/send_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export default function sendMessage(
} else {
// TypeScript made a mistake here, and 2busy2fix
/* eslint-disable-next-line */
// XXX TODO add transferables urgently
(postMessage as any)(msg);
(postMessage as any)(msg, transferables);
}
}

Expand Down

0 comments on commit d831576

Please sign in to comment.