diff options
Diffstat (limited to 'platform/android')
| -rw-r--r-- | platform/android/audio_driver_opensl.cpp | 104 | ||||
| -rw-r--r-- | platform/android/audio_driver_opensl.h | 15 | ||||
| -rw-r--r-- | platform/android/detect.py | 6 | ||||
| -rw-r--r-- | platform/android/export/export.cpp | 24 | ||||
| -rw-r--r-- | platform/android/java/src/org/godotengine/godot/GodotIO.java | 8 | ||||
| -rw-r--r-- | platform/android/os_android.cpp | 2 | 
6 files changed, 136 insertions, 23 deletions
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index e259380a63..0d62b242a8 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -211,6 +211,110 @@ void AudioDriverOpenSL::start() {  	active = true;  } +void AudioDriverOpenSL::_record_buffer_callback(SLAndroidSimpleBufferQueueItf queueItf) { + +	for (int i = 0; i < rec_buffer.size(); i++) { +		int32_t sample = rec_buffer[i] << 16; +		input_buffer_write(sample); +		input_buffer_write(sample); // call twice to convert to Stereo +	} + +	SLresult res = (*recordBufferQueueItf)->Enqueue(recordBufferQueueItf, rec_buffer.ptrw(), rec_buffer.size() * sizeof(int16_t)); +	ERR_FAIL_COND(res != SL_RESULT_SUCCESS); +} + +void AudioDriverOpenSL::_record_buffer_callbacks(SLAndroidSimpleBufferQueueItf queueItf, void *pContext) { + +	AudioDriverOpenSL *ad = (AudioDriverOpenSL *)pContext; + +	ad->_record_buffer_callback(queueItf); +} + +Error AudioDriverOpenSL::capture_start() { + +	SLDataLocator_IODevice loc_dev = { +		SL_DATALOCATOR_IODEVICE, +		SL_IODEVICE_AUDIOINPUT, +		SL_DEFAULTDEVICEID_AUDIOINPUT, +		NULL +	}; +	SLDataSource recSource = { &loc_dev, NULL }; + +	SLDataLocator_AndroidSimpleBufferQueue loc_bq = { +		SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, +		2 +	}; +	SLDataFormat_PCM format_pcm = { +		SL_DATAFORMAT_PCM, +		1, +		SL_SAMPLINGRATE_44_1, +		SL_PCMSAMPLEFORMAT_FIXED_16, +		SL_PCMSAMPLEFORMAT_FIXED_16, +		SL_SPEAKER_FRONT_CENTER, +		SL_BYTEORDER_LITTLEENDIAN +	}; +	SLDataSink recSnk = { &loc_bq, &format_pcm }; + +	const SLInterfaceID ids[2] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_ANDROIDCONFIGURATION }; +	const SLboolean req[2] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE }; + +	SLresult res = (*EngineItf)->CreateAudioRecorder(EngineItf, &recorder, &recSource, &recSnk, 2, ids, req); +	ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +	res = (*recorder)->Realize(recorder, SL_BOOLEAN_FALSE); +	ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +	res = (*recorder)->GetInterface(recorder, SL_IID_RECORD, (void *)&recordItf); +	ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +	res = (*recorder)->GetInterface(recorder, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, (void *)&recordBufferQueueItf); +	ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +	res = (*recordBufferQueueItf)->RegisterCallback(recordBufferQueueItf, _record_buffer_callbacks, this); +	ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +	SLuint32 state; +	res = (*recordItf)->GetRecordState(recordItf, &state); +	ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +	if (state != SL_RECORDSTATE_STOPPED) { +		res = (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_STOPPED); +		ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +		res = (*recordBufferQueueItf)->Clear(recordBufferQueueItf); +		ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); +	} + +	const int rec_buffer_frames = 2048; +	rec_buffer.resize(rec_buffer_frames); +	input_buffer_init(rec_buffer_frames); + +	res = (*recordBufferQueueItf)->Enqueue(recordBufferQueueItf, rec_buffer.ptrw(), rec_buffer.size() * sizeof(int16_t)); +	ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +	res = (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_RECORDING); +	ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +	return OK; +} + +Error AudioDriverOpenSL::capture_stop() { + +	SLuint32 state; +	SLresult res = (*recordItf)->GetRecordState(recordItf, &state); +	ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +	if (state != SL_RECORDSTATE_STOPPED) { +		res = (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_STOPPED); +		ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); + +		res = (*recordBufferQueueItf)->Clear(recordBufferQueueItf); +		ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN); +	} + +	return OK; +} +  int AudioDriverOpenSL::get_mix_rate() const {  	return 44100; diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h index 77e16e507a..9bd0d5e999 100644 --- a/platform/android/audio_driver_opensl.h +++ b/platform/android/audio_driver_opensl.h @@ -54,13 +54,18 @@ class AudioDriverOpenSL : public AudioDriver {  	int32_t *mixdown_buffer;  	int last_free; +	Vector<int16_t> rec_buffer; +  	SLPlayItf playItf; +	SLRecordItf recordItf;  	SLObjectItf sl;  	SLEngineItf EngineItf;  	SLObjectItf OutputMix;  	SLVolumeItf volumeItf;  	SLObjectItf player; +	SLObjectItf recorder;  	SLAndroidSimpleBufferQueueItf bufferQueueItf; +	SLAndroidSimpleBufferQueueItf recordBufferQueueItf;  	SLDataSource audioSource;  	SLDataFormat_PCM pcm;  	SLDataSink audioSink; @@ -76,6 +81,13 @@ class AudioDriverOpenSL : public AudioDriver {  			SLAndroidSimpleBufferQueueItf queueItf,  			void *pContext); +	void _record_buffer_callback( +			SLAndroidSimpleBufferQueueItf queueItf); + +	static void _record_buffer_callbacks( +			SLAndroidSimpleBufferQueueItf queueItf, +			void *pContext); +  public:  	void set_singleton(); @@ -91,6 +103,9 @@ public:  	virtual void set_pause(bool p_pause); +	virtual Error capture_start(); +	virtual Error capture_stop(); +  	AudioDriverOpenSL();  }; diff --git a/platform/android/detect.py b/platform/android/detect.py index aa48252435..80cda68a9e 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -298,12 +298,6 @@ def configure(env):      env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL'])      env.Append(LIBS=['OpenSLES', 'EGL', 'GLESv3', 'android', 'log', 'z', 'dl']) -    # TODO: Move that to opus module's config -    if 'module_opus_enabled' in env and env['module_opus_enabled']: -        if (env["android_arch"] == "armv6" or env["android_arch"] == "armv7"): -            env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) -        env.opus_fixed_point = "yes" -  # Return NDK version string in source.properties (adapted from the Chromium project).  def get_ndk_version(path):      if path is None: diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 8d9d9c697e..e489bce3f8 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -658,6 +658,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {  		int orientation = p_preset->get("screen/orientation"); +		bool min_gles3 = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name") == "GLES3" && +						 !ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2");  		bool screen_support_small = p_preset->get("screen/support_small");  		bool screen_support_normal = p_preset->get("screen/support_normal");  		bool screen_support_large = p_preset->get("screen/support_large"); @@ -815,6 +817,11 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {  							}  						} +						if (tname == "uses-feature" && attrname == "glEsVersion") { + +							encode_uint32(min_gles3 ? 0x00030000 : 0x00020000, &p_manifest.write[iofs + 16]); +						} +  						iofs += 20;  					} @@ -1114,17 +1121,14 @@ public:  public:  	virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) { -		// Re-enable when a GLES 2.0 backend is read -		/*int api = p_preset->get("graphics/api"); -		if (api == 0) -			r_features->push_back("etc"); -		else*/  		String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name"); -		if (driver == "GLES2" || driver == "GLES3") { +		if (driver == "GLES2") {  			r_features->push_back("etc"); -		} -		if (driver == "GLES3") { +		} else if (driver == "GLES3") {  			r_features->push_back("etc2"); +			if (ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2")) { +				r_features->push_back("etc"); +			}  		}  		Vector<String> abis = get_enabled_abis(p_preset); @@ -1495,6 +1499,10 @@ public:  			}  		} +		if (!DirAccess::exists(p_path.get_base_dir())) { +			return ERR_FILE_BAD_PATH; +		} +  		FileAccess *src_f = NULL;  		zlib_filefunc_def io = zipio_create_io_from_file(&src_f); diff --git a/platform/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java index 8cee20e435..85bba8bb4c 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java @@ -516,14 +516,6 @@ public class GodotIO {  	public void hideKeyboard() {  		if (edit != null)  			edit.hideKeyboard(); - -		InputMethodManager inputMgr = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE); -		View v = activity.getCurrentFocus(); -		if (v != null) { -			inputMgr.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); -		} else { -			inputMgr.hideSoftInputFromWindow(new View(activity).getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); -		}  	};  	public void setScreenOrientation(int p_orientation) { diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index b86976843c..8c4531213f 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -131,7 +131,7 @@ Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int  				RasterizerGLES3::make_current();  				break;  			} else { -				if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") { +				if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {  					p_video_driver = VIDEO_DRIVER_GLES2;  					use_gl3 = false;  					continue;  |