Merge pull request #43358 from Faless/js/4.x_audio_latency_fix

[HTML5] Fix audio buffer size and latency hint.
This commit is contained in:
Rémi Verschelde 2020-11-06 15:58:19 +01:00 committed by GitHub
commit 6797ab6719
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -100,7 +100,7 @@ Error AudioDriverJavaScript::init() {
int latency = GLOBAL_GET("audio/output_latency"); int latency = GLOBAL_GET("audio/output_latency");
channel_count = godot_audio_init(mix_rate, 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); buffer_length = godot_audio_create_processor(buffer_length, channel_count);
if (!buffer_length) { if (!buffer_length) {
return FAILED; return FAILED;

View File

@ -47,7 +47,7 @@ var GodotAudio = {
godot_audio_init: function(mix_rate, latency) { godot_audio_init: function(mix_rate, latency) {
GodotAudio.ctx = new (window.AudioContext || window.webkitAudioContext)({ GodotAudio.ctx = new (window.AudioContext || window.webkitAudioContext)({
sampleRate: mix_rate, sampleRate: mix_rate,
latencyHint: latency // latencyHint: latency / 1000 // Do not specify, leave 'interactive' for good performance.
}); });
return GodotAudio.ctx.destination.channelCount; return GodotAudio.ctx.destination.channelCount;
}, },