The ThreadSharedFloatArrayBufferList may be null even when there is a buffer
if one of its arrays has been neutered.
SAMPLE_RATE is used instead of BUFFEREND to detect whether start() and buffer
have been received because buffers can have zero length when acquiring the
contents returns "zero-length channel data buffers", although this zero-length
is not yet implemented.
LOOP and BUFFEREND are reset when the buffer is set to null to end playback.
--HG--
extra : rebase_source : f247ca61e045ff548180da5c8c6e521e944620be
I think the limits on sample rates already ensure that mBufferPosition will
not overflow, but this makes sure that there are no out of bounds reads.
The node checks the parameters are > 0 before sending to the engine.
--HG--
extra : rebase_source : 3547c7a6ed8bd1e30a34c8c402a1c339ecb89ac2
At this point AudioBlockBuffer is just like SharedBuffer but always with float
channels of length 128.
--HG--
extra : rebase_source : 61159da1577fb9607d5a766ba4288db3a7be2aff
In a subsequent patch, AllocateAudioBlock will become part of an AudioBlock
class derived from AudioChunk and used for AudioNodeStream members.
--HG--
extra : rebase_source : a3bfde8345995865c6f8e46abed24f008c112702
We don't need AudioNodes to block each other anymore.
--HG--
extra : commitid : 9rtWh5A3YY2
extra : rebase_source : cdd5c28b11602e53aaee178d3978b3e983ba5195
To make this work, we have to iterate over suspended MediaStreams in a few
more places. We don't need START_TIME_DELAYED anymore since blocking takes
care of that. I think it's good to allow suspended MediaStreams to notify
the main thread that they're finished; we might need that later when
we have non-AudioNode streams being suspended.
--HG--
extra : commitid : AZKt73Eg3rQ
extra : rebase_source : a662e9c85453212299f30085c1228ec959355440
There's no reason why WebAudio should block an incoming MediaStream.
--HG--
extra : commitid : IjUoo3OFdq9
extra : rebase_source : 5df1530c9d927e30194931c15f97389b7b74b524
The patch removes 455 occurrences of FAIL_ON_WARNINGS from moz.build files, and
adds 78 instances of ALLOW_COMPILER_WARNINGS. About half of those 78 are in
code we control and which should be removable with a little effort.
--HG--
extra : rebase_source : 82e3387abfbd5f1471e953961d301d3d97ed2973
The avoids the allocation and copying altogether when the output buffer
is silent.
--HG--
extra : rebase_source : f225628dc9bb2ea0cd0ec414a2212e39da92405f
This API lets AudioBuffer generators avoid a copy.
Future modifications to AudioBuffer will remove the unnecessary initial
allocation and zeroing.
--HG--
extra : rebase_source : 50f4d4dd79b32111583748d0b83065a13b03d888
Being able to write to the channel data in the buffer list saves the creator
from needing to manage its own pointers to the channel data.
--HG--
extra : rebase_source : 02b22b8b2dc2d640bec706433d7f921858fd8ef4
MediaStreamAudioDestinationNode does not need any main thread events because
mDOMStream provides GetCurrentTime to consumers.
MediaRecoder also does not use main thread current time.
--HG--
extra : rebase_source : e022dc12e8a0e67c70d4a617449e28e76288b57e
AudioBuffers are often generated from OfflineAudioContext to be used in other
contexts, when the OfflineAudioContext is no longer required.
--HG--
extra : rebase_source : 4d163ba69164f813256478ed0870803421c1f6a5
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
After this change, we have ShallowSizeOf{In,Ex}cludingThis(), which don't do
anything to measure children. (They can be combined with iteration to measure
children.)
And we still have the existing single-arg SizeOf{In,Ex}cluding() functions,
which work if the entry type itself defines SizeOfExcludingThis().
--HG--
extra : rebase_source : f93de9b789c21b1b148bed9de795f663f77c9dd9
It is now no longer necessary to clear zero bins because these are zeroed
in the FFTBlock constructor.
nsTArray bounds assertions now apply.
--HG--
extra : rebase_source : 18c07ecb51f9cb3c199536fe59110093db2295d4
realP[halfSize] was always set to zero because numberOfPartials < halfSize + 1
was always true.
--HG--
extra : rebase_source : 819b04a56032d810231a16fa0dd139cf82ef8ddf
The built-in waveforms are all odd and so realP[halfSize] was zero, and it
would have been ignored in createBandLimitedTables even if it was non-zero.
imagP[halfSize] was ignored as it was not involved in the inverse FFT.
This returns the code to that prior to
https://hg.mozilla.org/mozilla-central/diff/5377bce3b478/content/media/webaudio/blink/PeriodicWave.cpp#l1.276
--HG--
extra : rebase_source : 1bfa9eefc7dd269a64a98cdfdd4cbf76fa207dc4
There are no behavior changes here, just the change in meaning of the variable.
--HG--
extra : rebase_source : 9bae9f29a27430e9074dc0337773313140af9ba2
This makes it clearer that, unlike how SizeOf*() functions usually work, this
doesn't measure any children hanging off the array.
And do likewise for nsTObserverArray.
--HG--
extra : rebase_source : 6a8c8d8ffb53ad51b5773afea77126cdd767f149
tableInterpolationFactor = 0 now means use lowerWaveData, which is
rangeIndex2.
--HG--
extra : rebase_source : a8e1b64c534cf2e9aea92dd8a06a4eeee8403d73
This moves the application of volume and averaging of channels to the main
thread, performed when required. It avoids a potential allocation on the
graph thread. If doing a full analysis for frequency data, the extra work on
the main thread should be negligible. I assume that repeatedly fetching the
same time domain data with getFloatFrequencyData() is not something we need to
optimize for. If, in rare circumstances, the extra main thread work turns out
to be significant, then the main thread work in getters is self-regulating,
but too much load on the graph thread leads to catastrophic failure in the
audio.
This also fixes some bugs:
Input and output streams for other consumers are not corrupted by in-place
scaling of data intended to be read-only.
When there are additional channels and fftSize < WEBAUDIO_BLOCK_SIZE, the
channels are not written past the current length of a buffer, so there is no
longer a dependency on nsTArray's behavior of never not reducing allocation
size on length changes.
The most recent fftSize samples are now used even when fftSize <
WEBAUDIO_BLOCK_SIZE, instead of the first fftSize samples in the most recent
block.
Enough time domain data is recorded so that getters will work immediately
following a change in fftSize.
--HG--
extra : rebase_source : bbd8a3e705d73781bb838a47261bf7d60cd1a9a7
This is built on top of the AudioChannel infrastructure. This patch does not
actually implement the capture, it just does the plumbing to be able to notify
all HTMLMediaElement/AudioContext for a document.
This is built on top of the AudioChannel infrastructure. This patch does not
actually implement the capture, it just does the plumbing to be able to notify
all HTMLMediaElement/AudioContext for a document.
This is built on top of the AudioChannel infrastructure. This patch does not
actually implement the capture, it just does the plumbing to be able to notify
all HTMLMediaElement/AudioContext for a document.
Otherwise this name will collide with the rename of MediaTaskQueue to TaskQueue.
It's also a better naming convention, because it generalizes to things that are
owned by an AbstractThread that is not a Task Queue.
We rename to Queue() in TestMozPromise, because that's more accurate.
If DestroyMediaStream() has cleared the node on the engine, then it will call
MediaStream::Destroy(). I doubt the additional code and cost of repeatedly
checking this is worth the savings in no-op events dispatched to main thread
between MediaStream::Destroy() on the main thread and destruction on the graph
thread.
Also ScriptProcessorNode should not be potentially ignoring its output buffer
immediately when the ScriptProcessor loses its last reference. At least the
block currently being processed should output the output buffer.
(Deterministically playing the remainder of the output buffer would be best.)
--HG--
extra : rebase_source : 279f08808f4fbdbb41d67da0c3e495b65fdb24de
The bulk of this commit was generated by running:
run-clang-tidy.py \
-checks='-*,llvm-namespace-comment' \
-header-filter=^/.../mozilla-central/.* \
-fix
Since navigating away from a page with an active AudioContext will close
it internally, this patch fixes a similar issue to bug 1180535 for Web
Audio too.
Since navigating away from a page with an active AudioContext will close
it internally, this patch fixes a similar issue to bug 1180535 for Web
Audio too.
Because these nodes are only registered on PannerNodes if they have a
stream, they need only be unregistered once after the stream is destroyed.
Previously unregistration happened on finish, unlink, and destructor.
--HG--
extra : rebase_source : 7dab08fe4b5648e2a04495d6f570727684247f51
This conversion was done with the script:
find . -name '*.cpp' -o -name '*.h' -o -name '*.mm' -o -name '*.idl' | \
egrep -v 'cairo-win32-refptr.h|RefPtr.h|TestRefPtr.cpp' | \
xargs sed -i -e 's/mozilla::TemporaryRef</already_AddRefed</g' \
-e 's/TemporaryRef</already_AddRefed</g'
Manual fixups were performed in the following instances:
- We handled mfbt/RefPtr.h manually so as to not convert TemporaryRef itself
into already_AddRefed.
- The following files had explicit Move() calls added to make up for the lack
of a copy constructor on already_AddRefed:
dom/base/ImageEncoder.cpp
dom/media/MediaTaskQueue.{h,cpp}
dom/media/webaudio/PannerNode.cpp
- A redundant overload for MediaTaskQueue::Dispatch was deleted.
- A few manual fixups were required in mfbt/tests/TestRefPtr.cpp.
- Comments, using declarations, and forward declarations relating to
TemporaryRef in dom/canvas/ and gfx/layers/ were changed to refer to
already_AddRefed.
It would be nice to remove the argument in a separate patch, but we can't
perform MediaResource reads on the main thread, so the SilentReadAt stuff
needs to happen at the same time as the off-main-thread stuff.
It would be nice to remove the argument in a separate patch, but we can't
perform MediaResource reads on the main thread, so the SilentReadAt stuff
needs to happen at the same time as the off-main-thread stuff.