Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2][HTML5] Port inline JS code to libraries, AudioWorklet support. #43454

Merged
merged 5 commits into from
Nov 11, 2020

Conversation

Faless
Copy link
Collaborator

@Faless Faless commented Nov 11, 2020

3.2 version of: #43358 + #43443 .

This PR introduces some C++11 style (member initializers) to the JavaScript platform code (which I understand is fine), so the audio driver is almost the same in 4.0 and 3.2 in an effort to make cherry picking easier, though not necessarily completely straight-forward.

The size of the audio buffer was incorrectly doubled when creating the
script processor.
latencyHint is expressed in seconds, not milliseconds.
Additionally, on some browsers it actually affect the performance and
stability of the audio driver.
For this reason it has been completely disabled (interactive) and a not
has been left for future reference.
The API is implemented in javascript, and generates C functions that can
be called from godot.
This allows much cleaner code replacing all `EM_ASM` calls in our C++
code with plain C function calls.
This also gets rid of few hacks and comes with few optimizations (e.g.
custom cursor shapes should be much faster now).
Rewrote AudioDriverJavaScript to support multiple processor nodes.
The old (and deprecated) ScriptProcessorNode when threads are not
available, and the new AudioWorklet API when threads are enabled.

The new implementation uses two ring buffers and a shared state to
communicated with the AudioWorklet thread.

The audio.worklet.js JavaScript file is always added to the export
template, but only really used (and download) in the thread build.
@akien-mga
Copy link
Member

This PR introduces some C++11 style (member initializers) to the JavaScript platform code (which I understand is fine)

Yes, the 3.2 branch compiles with the current compilers' default C++ target (C++14), and we allow use of recent features, even if the codebase had not been ported yet to use relevant ones systematically.

@akien-mga akien-mga added this to the 3.2 milestone Nov 11, 2020
@akien-mga akien-mga merged commit 941e2f2 into godotengine:3.2 Nov 11, 2020
@akien-mga
Copy link
Member

Thanks!

@akien-mga akien-mga modified the milestones: 3.2, 3.3 Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants