Commit Graph

40 Commits

Author SHA1 Message Date
Shannon Booth
71ccd8ad25 LibWeb: Implement BaseAudioContext.createBuffer
This is a simple factory function which effectively just calls the
AudioBuffer constructor.
2024-05-26 07:49:49 +02:00
Shannon Booth
17ae65cedc LibWeb: Implement AudioBuffer.copyToChannel 2024-05-26 07:48:37 +02:00
Tim Ledbetter
68a1a78a1a LibWeb: Use FIXME extended attribute where possible 2024-05-19 17:35:25 +02:00
Shannon Booth
4fe0cbcf85 LibWeb: Use 'FIXME' extended attribute where possible
This improves the debuggability of many live web pages :^)
2024-05-19 16:24:11 +02:00
Shannon Booth
3ccbc83168 LibWeb: Add a stubbed slot for DynamicsCompressorNode.reduction
For now, this slot is always 0 - (the default value per spec). But
once we start actually processing audio streams this internal slot
should be changed correspondingly.
2024-05-19 09:26:20 +02:00
Shannon Booth
cf615cbd1c LibWeb: Add AudioParams for DynamicsCompressorNode 2024-05-19 09:26:20 +02:00
Shannon Booth
452ffa56dc LibWeb: Implement BaseAudioContext.createDynamicsCompressor 2024-05-14 13:45:43 -04:00
Shannon Booth
2a56df8ecd LibWeb: Add scaffolding for DynamicsCompressorNode 2024-05-14 13:45:43 -04:00
Shannon Booth
5e7678d1c6 LibWeb: Implement AudioBuffer.copyFromChannel 2024-05-12 19:11:37 +02:00
Shannon Booth
94354ea7fb LibWeb: Clamp AudioParam's value between min and max
The spec isn't _super_ clear on how this is meant to be done, but the
way I understand this is that we should simply clamp the returned
'current value' between 'min' and 'max'.

Firefox does not appear to do this clamping, but Chrome does.
2024-05-04 14:01:38 +02:00
Shannon Booth
e2b5ff2450 LibWeb: Implement OscillatorNode.frequency
Which is an AudioParam clamped by the nyquist_frequency.
2024-05-04 14:01:38 +02:00
Shannon Booth
5f57596520 LibWeb: Pass through sample rate in OfflineAudioContext constructor
I can't actually spot in the spec where it explicitly says to pass this
through (unlike the AudioContext constructor) - but clearly this needs
to be passed through for an OfflineAudioContext to actually have a
sample rate!
2024-05-04 14:01:38 +02:00
Shannon Booth
303958a803 LibWeb: Add BaseAudioContext::nyquist_frequency helper function
As a convenient shorthand :^)
2024-05-04 14:01:38 +02:00
Shannon Booth
099c9e4a7e LibWeb: Implement OscillatorNode.type
This is a simple getter and setter of the OscillatorType enum, with
error checking to not allow 'custom', as that should only be changed
through 'setPeriodicWave()'.
2024-05-04 14:01:38 +02:00
Shannon Booth
b48ba823b9 LibWeb: Implement AudioNode.context
This is just a simple getter which returns the audio context that
created this audio node.
2024-05-04 14:01:38 +02:00
Shannon Booth
97576d27b9 LibWeb: Add constructor for OscillatorNode
This is still missing a bunch of spec steps to construct the
audio node based on the parameters of the OscillatorNode, but it is at
least enough to construct an object to be able to add a basic test which
can get built upon as more is implemented.
2024-05-04 14:01:38 +02:00
Shannon Booth
1678f43c38 LibWeb: Implement BaseAudioContext.createOscillator
Which currently will always throw an exception as it is unimplemented
under the hood - but this gives all of the plumbing we need in order to
create a oscillator node as used in the reduced turnstyle testcase.
2024-05-02 07:49:23 +02:00
Shannon Booth
a83f4216a5 LibWeb: Add stub IDL interface for OscillatorNode
This source node generates a periodic wave form.
2024-05-02 07:49:23 +02:00
Shannon Booth
c9b2c1c747 LibWeb: Add stub IDL interface for AudioScheduledSourceNode
This is a base class of a few different audio nodes, most notably for
our immediate needs - OscillatorNode.
2024-05-02 07:49:23 +02:00
Shannon Booth
6661c68b28 LibWeb: Add stub IDL interface for AudioNode
An AudioNode is the fundamental building block used in 'Audio
Contexts'. In our immediate case, the audio node we are working towards
implementing is an oscillating source node.
2024-05-02 07:49:23 +02:00
Shannon Booth
5ae0ac7b73 LibWeb: Add stub IDL interface for AudioParam
An AudioParam is a fundamental building block in WebAudio as it controls
the value of an individual parameter of an AudioNode, such as volume.
2024-05-02 07:49:23 +02:00
Shannon Booth
b1b7e2324a LibWeb: Add stub IDL interface for PeriodicWave
PeriodicWave represents an arbitrary periodic waveform to be used
with an OscillatorNode.
2024-05-02 07:49:23 +02:00
Shannon Booth
bad44f8fc9 LibWeb: Remove Bindings/Forward.h from LibWeb/Forward.h
This was resulting in a whole lot of rebuilding whenever a new IDL
interface was added.

Instead, just directly include the prototype in every C++ file which
needs it. While we only really need a forward declaration in each cpp
file; including the full prototype header (which itself only includes
LibJS/Object.h, which is already transitively brought in by
PlatformObject) - it seems like a small price to pay compared to what
feels like a full rebuild of LibWeb whenever a new IDL file is added.

Given all of these includes are only needed for the ::initialize
method, there is probably a smart way of avoiding this problem
altogether. I've considered both using some macro trickery or generating
these functions somehow instead.
2024-04-27 18:29:35 -04:00
Shannon Booth
91efa1d568 LibWeb: Add skeleton for OfflineAudioContext
Implement enough to construct the object itself, with most parts stubbed
out.
2024-04-27 07:11:02 +02:00
Shannon Booth
0c8a98ac94 LibWeb: Begin implementing the interface for AudioBuffer
Implement the constructor and getChannelData function, working towards
the functionality that we need in order to implement
OfflineAudioContext.
2024-04-25 19:26:19 -04:00
Shannon Booth
5cb6d495bb LibWeb: Implement verification of 'nominal' audio options
The spec doesn't tell us the exact value to use, but a minumum & maximum
range of supported values. Just to be consistent with another browser,
we follow the values that firefox appears to support from testing the
interface on my machine.

This function will be used in the AudioBuffer constructor, but is
defined in the spec as part of BaseAudioContext.
2024-04-25 19:26:19 -04:00
Shannon Booth
46ec3681a4 LibWeb: Verify document is fully ready in AudioContext
This was just a trival FIXME to resolve as I was in the area.
2024-04-25 19:26:19 -04:00
Andreas Kling
53d0dd4a2e LibJS+LibWeb: Use new Cell::Visitor helpers to avoid manual iteration 2024-04-16 07:40:01 +02:00
Andreas Kling
2ef37c0b06 LibWeb: Make EventLoop, TaskQueue, and Task GC-allocated
...and use HeapFunction instead of SafeFunction for task steps.

Since there is only one EventLoop per process, it lives as a global
handle in the VM custom data.

This makes it much easier to reason about lifetimes of tasks, task
steps, and random stuff captured by them.
2024-04-05 08:14:19 +02:00
Andreas Kling
14f2012c8b LibWeb: Fix a bunch of bad stack captures in AudioContext
It's not safe to capture a local NonnullGCPtr by reference in a closure
that will execute at some arbitrary time in the future when the local is
out of scope.
2024-03-30 08:25:59 +01:00
Andreas Kling
c0d7f748ed LibWeb: Avoid FlyString lookups when setting IDL interface prototypes
This commit introduces a WEB_SET_PROTOTYPE_FOR_INTERFACE macro that
caches the interface name in a local static FlyString. This means that
we only pay for FlyString-from-literal lookup once per browser lifetime
instead of every time the interface is instantiated.
2024-03-16 16:35:54 +01:00
Shannon Booth
96af80acd1 LibWeb: Port Intrinsics from DeprecatedString 2023-11-28 17:15:27 -05:00
Andreas Kling
bfd354492e LibWeb: Put most LibWeb GC objects in type-specific heap blocks
With this change, we now have ~1200 CellAllocators across both LibJS and
LibWeb in a normal WebContent instance.

This gives us a minimum heap size of 4.7 MiB in the scenario where we
only have one cell allocated per type. Of course, in practice there will
be many more of each type, so the effective overhead is quite a bit
smaller than that in practice.

I left a few types unconverted to this mechanism because I got tired of
doing this. :^)
2023-11-19 22:00:48 +01:00
Bastiaan van der Plaat
169d24ae2e LibWeb: Add comments and missing items of various IDL files 2023-10-25 19:45:41 +02:00
Shannon Booth
41928c2902 LibWeb: Port DOMException interface from DeprecatedString to String 2023-09-06 11:44:45 -04:00
Andreas Kling
72c9f56c66 LibJS: Make Heap::allocate<T>() infallible
Stop worrying about tiny OOMs. Work towards #20449.

While going through these, I also changed the function signature in many
places where returning ThrowCompletionOr<T> is no longer necessary.
2023-08-13 15:38:42 +02:00
Andreas Kling
18c54d8d40 LibJS: Make Cell::initialize() return void
Stop worrying about tiny OOMs.

Work towards #20405
2023-08-08 07:39:11 +02:00
Timothy Flynn
c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Daniel Adams
49e6414c58 LibWeb: Start filling out BaseAudioContext/AudioContext interfaces
- Fills out both IDLs and implements some basic attributes/methods.
- No actual audio processing yet though :^)
2023-06-28 05:22:51 +02:00
Luke Wilde
a5936864d9 LibWeb: Stub AudioContext constructor
This is enough to make Discord not throw up "Well this is awkward" on
login.
2023-05-22 06:07:05 +02:00