From 54418ea659061edccdf1ac16470505542dcc33f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 3 Oct 2022 10:57:36 +0200 Subject: Remove NO_THREADS fallback code, Godot 4 requires thread support This also removes `OS::can_use_threads` from the public API since it's always true. --- platform/web/audio_driver_web.cpp | 46 --------------------------------------- platform/web/audio_driver_web.h | 41 ---------------------------------- platform/web/os_web.cpp | 3 --- 3 files changed, 90 deletions(-) (limited to 'platform/web') diff --git a/platform/web/audio_driver_web.cpp b/platform/web/audio_driver_web.cpp index 0e37afc2cc..c4b27c782d 100644 --- a/platform/web/audio_driver_web.cpp +++ b/platform/web/audio_driver_web.cpp @@ -184,51 +184,6 @@ Error AudioDriverWeb::capture_stop() { return OK; } -#ifdef NO_THREADS -/// ScriptProcessorNode implementation -AudioDriverScriptProcessor *AudioDriverScriptProcessor::singleton = nullptr; - -void AudioDriverScriptProcessor::_process_callback() { - AudioDriverScriptProcessor::singleton->_audio_driver_capture(); - AudioDriverScriptProcessor::singleton->_audio_driver_process(); -} - -Error AudioDriverScriptProcessor::create(int &p_buffer_samples, int p_channels) { - if (!godot_audio_has_script_processor()) { - return ERR_UNAVAILABLE; - } - return (Error)godot_audio_script_create(&p_buffer_samples, p_channels); -} - -void AudioDriverScriptProcessor::start(float *p_out_buf, int p_out_buf_size, float *p_in_buf, int p_in_buf_size) { - godot_audio_script_start(p_in_buf, p_in_buf_size, p_out_buf, p_out_buf_size, &_process_callback); -} - -/// AudioWorkletNode implementation (no threads) -AudioDriverWorklet *AudioDriverWorklet::singleton = nullptr; - -Error AudioDriverWorklet::create(int &p_buffer_size, int p_channels) { - if (!godot_audio_has_worklet()) { - return ERR_UNAVAILABLE; - } - return (Error)godot_audio_worklet_create(p_channels); -} - -void AudioDriverWorklet::start(float *p_out_buf, int p_out_buf_size, float *p_in_buf, int p_in_buf_size) { - _audio_driver_process(); - godot_audio_worklet_start_no_threads(p_out_buf, p_out_buf_size, &_process_callback, p_in_buf, p_in_buf_size, &_capture_callback); -} - -void AudioDriverWorklet::_process_callback(int p_pos, int p_samples) { - AudioDriverWorklet *driver = AudioDriverWorklet::singleton; - driver->_audio_driver_process(p_pos, p_samples); -} - -void AudioDriverWorklet::_capture_callback(int p_pos, int p_samples) { - AudioDriverWorklet *driver = AudioDriverWorklet::singleton; - driver->_audio_driver_capture(p_pos, p_samples); -} -#else /// AudioWorkletNode implementation (threads) void AudioDriverWorklet::_audio_thread_func(void *p_data) { AudioDriverWorklet *driver = static_cast(p_data); @@ -290,4 +245,3 @@ void AudioDriverWorklet::finish_driver() { quit = true; // Ask thread to quit. thread.wait_to_finish(); } -#endif diff --git a/platform/web/audio_driver_web.h b/platform/web/audio_driver_web.h index dfce277c0c..0a322d61b4 100644 --- a/platform/web/audio_driver_web.h +++ b/platform/web/audio_driver_web.h @@ -89,46 +89,6 @@ public: AudioDriverWeb() {} }; -#ifdef NO_THREADS -class AudioDriverScriptProcessor : public AudioDriverWeb { -private: - static void _process_callback(); - - static AudioDriverScriptProcessor *singleton; - -protected: - Error create(int &p_buffer_samples, int p_channels) override; - void start(float *p_out_buf, int p_out_buf_size, float *p_in_buf, int p_in_buf_size) override; - -public: - virtual const char *get_name() const override { return "ScriptProcessor"; } - - virtual void lock() override {} - virtual void unlock() override {} - - AudioDriverScriptProcessor() { singleton = this; } -}; - -class AudioDriverWorklet : public AudioDriverWeb { -private: - static void _process_callback(int p_pos, int p_samples); - static void _capture_callback(int p_pos, int p_samples); - - static AudioDriverWorklet *singleton; - -protected: - virtual Error create(int &p_buffer_size, int p_output_channels) override; - virtual void start(float *p_out_buf, int p_out_buf_size, float *p_in_buf, int p_in_buf_size) override; - -public: - virtual const char *get_name() const override { return "AudioWorklet"; } - - virtual void lock() override {} - virtual void unlock() override {} - - AudioDriverWorklet() { singleton = this; } -}; -#else class AudioDriverWorklet : public AudioDriverWeb { private: enum { @@ -156,6 +116,5 @@ public: void lock() override; void unlock() override; }; -#endif #endif // AUDIO_DRIVER_WEB_H diff --git a/platform/web/os_web.cpp b/platform/web/os_web.cpp index ebe56924df..c263ee094b 100644 --- a/platform/web/os_web.cpp +++ b/platform/web/os_web.cpp @@ -239,9 +239,6 @@ OS_Web::OS_Web() { godot_js_pwa_cb(&OS_Web::update_pwa_state_callback); if (AudioDriverWeb::is_available()) { -#ifdef NO_THREADS - audio_drivers.push_back(memnew(AudioDriverScriptProcessor)); -#endif audio_drivers.push_back(memnew(AudioDriverWorklet)); } for (int i = 0; i < audio_drivers.size(); i++) { -- cgit v1.2.3