A decoder isn't created until a SPS and PPS NALs have been detected in the stream. The decoder will be initialised instead lazily later during the input process.
This is a partial revert of bug 1173657 (commit 80f9da7f0806). Not all decoders will properly handle draining when they have encountered an error and will never call DrainComplete().
The Gonk and Android decoder do not. So we just get around this.
MediaResource::ReadAt() requires to loop several times to ensure that all data has been read as it may return less data than requested.
This will allow to remove the handling of this particular shortcoming in MediaResources' users.
This functionality is now replaced with a dedicated new MediaResourceIndex class.
This allows for concurrent Read/Seek use of the MediaResource without having side effects.
In present codebase, the |mSuspendCount| would be accessed in main thread and state machine thread, and we use the lock mechanism to avoid the race condition.
However, we can use another more easier way to achieve it, that is using Atomic for the |mSuspendCount|.
--HG--
extra : transplant_source : %E7%80%93h%25%5D%24%CA%0C%19%1BDQ%60%08%BD%CB%9D%90%FC
The try machines do not have Service Pack 1 installed, the WMF decoder doesn't output frames until a full second of data has been added. Rendering those tests invalid.
We made the design decision that it was preferable to decode as much of what we had, even if that meant we couldn't decode some frames upon resume.
This can cause significant apparent stalls with some YouTube videos where keyframes are up to 4.2s appart (128 frames).
This is motivated by three separate but related problems:
1. Our concept of recursion depth is broken for things that run from AfterProcessNextEvent observers (e.g. Promises). We decrement the recursionDepth counter before firing observers, so a Promise callback running at the lowest event loop depth has a recursion depth of 0 (whereas a regular nsIRunnable would be 1). This is a problem because it's impossible to distinguish a Promise running after a sync XHR's onreadystatechange handler from a top-level event (since the former runs with depth 2 - 1 = 1, and the latter runs with just 1).
2. The nsIThreadObserver mechanism that is used by a lot of code to run "after" the current event is a poor fit for anything that runs script. First, the order the observers fire in is the order they were added, not anything fixed by spec. Additionally, running script can cause the event loop to spin, which is a big source of pain here (bholley has some nasty bug caused by this).
3. We run Promises from different points in the code for workers and main thread. The latter runs from XPConnect's nsIThreadObserver callbacks, while the former runs from a hardcoded call to run Promises in the worker event loop. What workers do is particularly problematic because it means we can't get the right recursion depth no matter what we do to nsThread.
The solve this, this patch does the following:
1. Consolidate some handling of microtasks and all handling of stable state from appshell and WorkerPrivate into CycleCollectedJSRuntime.
2. Make the recursionDepth counter only available to CycleCollectedJSRuntime (and its consumers) and remove it from the nsIThreadInternal and nsIThreadObserver APIs.
3. Adjust the recursionDepth counter so that microtasks run with the recursionDepth of the task they are associated with.
4. Introduce the concept of metastable state to replace appshell's RunBeforeNextEvent. Metastable state is reached after every microtask or task is completed. This provides the semantics that bent and I want for IndexedDB, where transactions autocommit at the end of a microtask and do not "spill" from one microtask into a subsequent microtask. This differs from appshell's RunBeforeNextEvent in two ways:
a) It fires between microtasks, which was the motivation for starting this.
b) It no longer ensures that we're at the same event loop depth in the native event queue. bent decided we don't care about this.
5. Reorder stable state to happen after microtasks such as Promises, per HTML. Right now we call the regular thread observers, including appshell, before the main thread observer (XPConnect), so stable state tasks happen before microtasks.
Zero output channels are used on ScriptProcessorNodes to improve efficiency in
tests when output is not required.
--HG--
extra : rebase_source : f3ddee8031d772bdcedbd482d80d3259a095e0ea
The effects of garbage collection must not be observable. We can collect an
AudioNode if it is not going to cause any further changes, but we must keep
any current effects.
--HG--
extra : rebase_source : f7ce500de2afd4f6cdff79c30c99a0ee8e74ab40
because stream inputs may be removed when only providing null data.
The ScriptProcessor is also kept alive when it has only input nodes so that it
is not garbage collected when its input nodes are collected.
--HG--
extra : rebase_source : ee70db1b3e13b212107e048620880b929c662ad6
Creating the event added a reference to the ScriptProcessorNode, which wasn't
released until the AudioProcessingEvent was destroyed in
nsCycleCollector::FreeSnowWhite().
If another event is dispatched before cycle collection considers the
ScriptProcessorNode, then the node will not be collected.
Also, the reference count of the ScriptProcessorNode is no longer toggled
because this seemed to interfere with the cycle collection process.
--HG--
extra : rebase_source : 41878e716fe3fcc8f46f518be2a50d050b8ed14c
In test_HaveMetadataUnbufferedSeek_mp4, do endOfStream after appending 2nd buffer in case decoder doesn't output enough frames to seek to the target point.
Calculating intersections between two interval sets with different fuzz can lead to useless tiny intervals which could cause CheckNextInsertionIndex to fail.
Should a playback error occurs, the MediaSource element will be closed and will detach its sourcebuffers. Cancel any pending operations going in the sourcebuffers.