mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
[HTML5] Run Audio process in thread when available
This should fix some of the audio stuttering issues when the HTML5 export is compiled with threads support. The API should be ported to AudioWorklet to (hopefully) be perfect. That though, cannot be backported to 3.2 due to extra restriction of AudioWorklet (which only runs in SecureContext, and needs a polyfill for Safari).
This commit is contained in:
parent
a57bd798cd
commit
61d4b8045c
5 changed files with 331 additions and 186 deletions
|
@ -31,18 +31,33 @@
|
|||
#ifndef AUDIO_DRIVER_JAVASCRIPT_H
|
||||
#define AUDIO_DRIVER_JAVASCRIPT_H
|
||||
|
||||
#include "core/os/mutex.h"
|
||||
#include "core/os/thread.h"
|
||||
#include "servers/audio_server.h"
|
||||
|
||||
class AudioDriverJavaScript : public AudioDriver {
|
||||
|
||||
private:
|
||||
float *internal_buffer;
|
||||
|
||||
int _driver_id;
|
||||
int buffer_length;
|
||||
|
||||
int mix_rate;
|
||||
int channel_count;
|
||||
|
||||
public:
|
||||
#ifndef NO_THREADS
|
||||
Mutex *mutex;
|
||||
Thread *thread;
|
||||
bool quit;
|
||||
bool needs_process;
|
||||
|
||||
static void _audio_thread_func(void *p_data);
|
||||
#endif
|
||||
|
||||
void _js_driver_process();
|
||||
|
||||
static bool is_available();
|
||||
void mix_to_js();
|
||||
void process_capture(float sample);
|
||||
|
||||
static AudioDriverJavaScript *singleton;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue