diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/audio_driver_opensl.cpp | 12 | ||||
-rw-r--r-- | platform/android/audio_driver_opensl.h | 27 | ||||
-rw-r--r-- | platform/android/java_godot_lib_jni.cpp | 2 | ||||
-rw-r--r-- | platform/web/audio_driver_web.cpp | 8 | ||||
-rw-r--r-- | platform/web/audio_driver_web.h | 14 | ||||
-rw-r--r-- | platform/web/godot_audio.h | 4 | ||||
-rw-r--r-- | platform/web/js/libs/library_godot_audio.js | 12 |
7 files changed, 40 insertions, 39 deletions
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index 9dad0c9357..5fc32132e3 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -80,10 +80,6 @@ void AudioDriverOpenSL::_buffer_callbacks( ad->_buffer_callback(queueItf); } -const char *AudioDriverOpenSL::get_name() const { - return "Android"; -} - Error AudioDriverOpenSL::init() { SLresult res; SLEngineOption EngineOption[] = { @@ -204,7 +200,7 @@ void AudioDriverOpenSL::_record_buffer_callbacks(SLAndroidSimpleBufferQueueItf q ad->_record_buffer_callback(queueItf); } -Error AudioDriverOpenSL::capture_init_device() { +Error AudioDriverOpenSL::init_input_device() { SLDataLocator_IODevice loc_dev = { SL_DATALOCATOR_IODEVICE, SL_IODEVICE_AUDIOINPUT, @@ -271,15 +267,15 @@ Error AudioDriverOpenSL::capture_init_device() { return OK; } -Error AudioDriverOpenSL::capture_start() { +Error AudioDriverOpenSL::input_start() { if (OS::get_singleton()->request_permission("RECORD_AUDIO")) { - return capture_init_device(); + return init_input_device(); } return OK; } -Error AudioDriverOpenSL::capture_stop() { +Error AudioDriverOpenSL::input_stop() { SLuint32 state; SLresult res = (*recordItf)->GetRecordState(recordItf, &state); ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h index ae8c33fec0..6ea0f77def 100644 --- a/platform/android/audio_driver_opensl.h +++ b/platform/android/audio_driver_opensl.h @@ -84,23 +84,26 @@ class AudioDriverOpenSL : public AudioDriver { SLAndroidSimpleBufferQueueItf queueItf, void *pContext); - virtual Error capture_init_device(); + Error init_input_device(); public: - virtual const char *get_name() const; + virtual const char *get_name() const override { + return "Android"; + } - virtual Error init(); - virtual void start(); - virtual int get_mix_rate() const; - virtual SpeakerMode get_speaker_mode() const; - virtual void lock(); - virtual void unlock(); - virtual void finish(); + virtual Error init() override; + virtual void start() override; + virtual int get_mix_rate() const override; + virtual SpeakerMode get_speaker_mode() const override; - virtual void set_pause(bool p_pause); + virtual void lock() override; + virtual void unlock() override; + virtual void finish() override; - virtual Error capture_start(); - virtual Error capture_stop(); + virtual Error input_start() override; + virtual Error input_stop() override; + + void set_pause(bool p_pause); AudioDriverOpenSL(); }; diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 1ee1cccb82..e7abe580f1 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -488,7 +488,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jclass clazz, jstring p_permission, jboolean p_result) { String permission = jstring_to_string(p_permission, env); if (permission == "android.permission.RECORD_AUDIO" && p_result) { - AudioDriver::get_singleton()->capture_start(); + AudioDriver::get_singleton()->input_start(); } if (os_android->get_main_loop()) { diff --git a/platform/web/audio_driver_web.cpp b/platform/web/audio_driver_web.cpp index a5234627d1..1d7b96d707 100644 --- a/platform/web/audio_driver_web.cpp +++ b/platform/web/audio_driver_web.cpp @@ -166,18 +166,18 @@ void AudioDriverWeb::finish() { } } -Error AudioDriverWeb::capture_start() { +Error AudioDriverWeb::input_start() { lock(); input_buffer_init(buffer_length); unlock(); - if (godot_audio_capture_start()) { + if (godot_audio_input_start()) { return FAILED; } return OK; } -Error AudioDriverWeb::capture_stop() { - godot_audio_capture_stop(); +Error AudioDriverWeb::input_stop() { + godot_audio_input_stop(); lock(); input_buffer.clear(); unlock(); diff --git a/platform/web/audio_driver_web.h b/platform/web/audio_driver_web.h index f3afbdbb92..be13935bd9 100644 --- a/platform/web/audio_driver_web.h +++ b/platform/web/audio_driver_web.h @@ -77,12 +77,12 @@ public: virtual void start() final; virtual void finish() final; - virtual float get_latency() override; virtual int get_mix_rate() const override; virtual SpeakerMode get_speaker_mode() const override; + virtual float get_latency() override; - virtual Error capture_start() override; - virtual Error capture_stop() override; + virtual Error input_start() override; + virtual Error input_stop() override; static void resume(); @@ -111,10 +111,12 @@ protected: virtual void finish_driver() override; public: - virtual const char *get_name() const override { return "AudioWorklet"; } + virtual const char *get_name() const override { + return "AudioWorklet"; + } - void lock() override; - void unlock() override; + virtual void lock() override; + virtual void unlock() override; }; #endif // AUDIO_DRIVER_WEB_H diff --git a/platform/web/godot_audio.h b/platform/web/godot_audio.h index d7bff078f8..c6f92161fa 100644 --- a/platform/web/godot_audio.h +++ b/platform/web/godot_audio.h @@ -43,8 +43,8 @@ extern int godot_audio_has_script_processor(); extern int godot_audio_init(int *p_mix_rate, int p_latency, void (*_state_cb)(int), void (*_latency_cb)(float)); extern void godot_audio_resume(); -extern int godot_audio_capture_start(); -extern void godot_audio_capture_stop(); +extern int godot_audio_input_start(); +extern void godot_audio_input_stop(); // Worklet typedef int32_t GodotAudioState[4]; diff --git a/platform/web/js/libs/library_godot_audio.js b/platform/web/js/libs/library_godot_audio.js index 68348a3962..1993d66310 100644 --- a/platform/web/js/libs/library_godot_audio.js +++ b/platform/web/js/libs/library_godot_audio.js @@ -186,17 +186,17 @@ const GodotAudio = { } }, - godot_audio_capture_start__proxy: 'sync', - godot_audio_capture_start__sig: 'i', - godot_audio_capture_start: function () { + godot_audio_input_start__proxy: 'sync', + godot_audio_input_start__sig: 'i', + godot_audio_input_start: function () { return GodotAudio.create_input(function (input) { input.connect(GodotAudio.driver.get_node()); }); }, - godot_audio_capture_stop__proxy: 'sync', - godot_audio_capture_stop__sig: 'v', - godot_audio_capture_stop: function () { + godot_audio_input_stop__proxy: 'sync', + godot_audio_input_stop__sig: 'v', + godot_audio_input_stop: function () { if (GodotAudio.input) { const tracks = GodotAudio.input['mediaStream']['getTracks'](); for (let i = 0; i < tracks.length; i++) { |