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.
The last preload branch (#1407) is a good start for a preload API but is not yet finished and is already getting very big.
I noticed when working on it that several code updates made sense even without the Preload API.
So I decided to isolate those parts in a separate PR, where each commit details one type of update. The main theme is improving code readability:
Rename segment_buffer file into the new segment_sink name
We changed the name of classes from SegmentBuffer to SegmentSink but
didn't actually update the file names. This is now done.
Rely on compat version of TextTrack-related types in remove_cue.ts
Provide more precize typing for the SegmentSinksStore's SegmentSinks
ContentInit: Rename "settings" into "initSettings"
To avoid the confusion between several concepts named "settings" in the
MediaSourceContentInitializer
, the settings provided to itsconstructor is now renamed to
_initSettings
(aligns with_initCanceller
for its TaskCanceller initialized at instantiation).Rename and factorize some methods of the MediaSourceContentInitializer
Some private methods of the
MediaSourceContentInitializer
weredifficult to follow due to the heavy usage of inner functions with
unclear names (such as
recursivelyLoadOnMediaSource
).I now tried to isolate some of those and rename the different methods
called at content load so it makes more sense. Methods in order are:
Note:
_setupContentWithNewMediaSource
and_startLoadingContentOnMediaSource
are still similarly named, thoughthe former just has the task of setting up a reloading logic and then
calling the latter.
Note2:
_startLoadingContentOnMediaSource
is still a huge and complexmethod that we might improve on in the future.
Isolate HTMLTrackElement clearing in its own private method
This is a minor code update to make the NativeTextDisplayer's clean-up
easier to follow by isolating the DOM-related (TextTrack,
HTMLTrackElement, HTMLMediaElement) code inside its own private method.
Make MainSourceBufferInterface code more readable isolating inner functions
The callback called on the
"updateend"
and"error"
events on aSourceBuffer were previously declared as arrow functions inside the
constructor.
This allowed to keep a clear JS context for the
this
keyword, but itmade the
MainSourceBufferInterface
's constructor harder to read.I found it more readable to declare both callback as private methods
instead, with the drawback of having to bind the
this
explictely.Fix SyncOrAsync util syncValue transfer
Our
SyncOrAsync
util is used for cases where a task is >99% of the timesynchronous, yet <1% of the time asynchronous, and where we don't want to
incur any overhead/supplementary complexity of awaiting a Promise which
inherently schedule a microtask when the value is most probably already
there.
It worked well for most usages, but it turns out that a task that starts
as asynchronous would then always lead to the need to rely on Promises,
even once the task is finished (basically, if it started as an "async
value" it could never transform itself to a "sync value").
This does not create any issue but we could gain some minuscule advantage
(we could argue that
SyncOrAsync
's advantage is in itselfminuscule) here by just relying on the value synchronously once the task is
finished.