summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorEmmanouil Papadeas <manoschool@yahoo.gr>2023-02-08 17:40:15 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-02-09 11:02:00 +0100
commitc36460060ea434158c2069d696880cbaf4431123 (patch)
tree79e045ef1939b8daad696cc0a074778f9c61ae53 /platform/android
parentd69809cab603cae9f525768337affe5e12e454a8 (diff)
Further refactoring to AudioDriver implementations after #69120.
- Rename all instances of `capture_start()` and `capture_end()` to their new names. Fixes #72892. - More internal renames to match what was started in #69120. - Use `override` consistently so that such refactoring bugs can be caught. - Harmonize the order of definition of the overridden virtual methods in each audio driver. - Harmonize prototype for `set_output_device` and `set_input_device`. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/audio_driver_opensl.cpp12
-rw-r--r--platform/android/audio_driver_opensl.h27
-rw-r--r--platform/android/java_godot_lib_jni.cpp2
3 files changed, 20 insertions, 21 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()) {