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

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

Merged
merged 5 commits into from
Nov 11, 2020

Conversation

Faless
Copy link
Collaborator

@Faless Faless commented Nov 10, 2020

In this PR:

  • Usual fixes to the RasterizerDummy
  • Fix gdnative build when WebRTC module is disabled.
  • Update syntax for lto. (we could do better, and specify lto=thin lto=full etc, but keep it short for now).
  • A huge refactor of the JavaScript code porting it to libraries:
    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).
  • AudioWorklet API implementation.
    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 downloaded) in the thread build.

Fixes #40891 (on thread builds, which is the only build that can be fixed).
Potentially others, which I will review.

There is a 3.x version here: https://github.com/Faless/godot/tree/js/3.x_audio_worklet

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 downloaded) in the thread build.
}

void WebRTCDataChannelJS::close() {
in_buffer.resize(0);
queue_count = 0;
_was_string = false;
/* clang-format off */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, begone /* clang-format off */ hacks around all EM_ASM calls :D

@akien-mga akien-mga merged commit 10fd107 into godotengine:master Nov 11, 2020
@akien-mga
Copy link
Member

Thanks!

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.

Audio stuttering on HTML5 export
2 participants