diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-11-06 15:10:57 +0100 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2020-11-06 15:38:47 +0100 |
commit | b3453e866beb5ab4a7347ff62ddca268567a97f2 (patch) | |
tree | 6b1bc5b7c6c0e32575526c968fb8ce4da7ad4a31 | |
parent | a9bc440311d962197d7d289afd61e3718d95bb8c (diff) |
[HTML5] Fix audio buffer size and latency hint.
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.
-rw-r--r-- | platform/javascript/audio_driver_javascript.cpp | 2 | ||||
-rw-r--r-- | platform/javascript/native/library_godot_audio.js | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp index 6ea948004e..006552a188 100644 --- a/platform/javascript/audio_driver_javascript.cpp +++ b/platform/javascript/audio_driver_javascript.cpp @@ -100,7 +100,7 @@ Error AudioDriverJavaScript::init() { int latency = GLOBAL_GET("audio/output_latency"); channel_count = godot_audio_init(mix_rate, latency); - buffer_length = closest_power_of_2((latency * mix_rate / 1000) * channel_count); + buffer_length = closest_power_of_2(latency * mix_rate / 1000); buffer_length = godot_audio_create_processor(buffer_length, channel_count); if (!buffer_length) { return FAILED; diff --git a/platform/javascript/native/library_godot_audio.js b/platform/javascript/native/library_godot_audio.js index d300280ccd..4e7f3e2af5 100644 --- a/platform/javascript/native/library_godot_audio.js +++ b/platform/javascript/native/library_godot_audio.js @@ -47,7 +47,7 @@ var GodotAudio = { godot_audio_init: function(mix_rate, latency) { GodotAudio.ctx = new (window.AudioContext || window.webkitAudioContext)({ sampleRate: mix_rate, - latencyHint: latency + // latencyHint: latency / 1000 // Do not specify, leave 'interactive' for good performance. }); return GodotAudio.ctx.destination.channelCount; }, |