Browse Source

Merge pull request #22676 from akien-mga/fix-warnings

Fix warnings in Android platform
Rémi Verschelde 6 years ago
parent
commit
874e3b4a37

+ 1 - 0
doc/classes/OS.xml

@@ -583,6 +583,7 @@
 			</argument>
 			</argument>
 			<description>
 			<description>
 				Plays native video from the specified path, at the given volume and with audio and subtitle tracks.
 				Plays native video from the specified path, at the given volume and with audio and subtitle tracks.
+				Note: This method is only implemented on Android and iOS, and the current Android implementation does not support the [code]volume[/code], [code]audio_track[/code] and [code]subtitle_track[/code] options.
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="native_video_stop">
 		<method name="native_video_stop">

+ 1 - 1
drivers/unix/dir_access_unix.cpp

@@ -391,7 +391,7 @@ size_t DirAccessUnix::get_space_left() {
 
 
 	return vfs.f_bfree * vfs.f_bsize;
 	return vfs.f_bfree * vfs.f_bsize;
 #else
 #else
-#warning THIS IS BROKEN
+	// FIXME: Implement this.
 	return 0;
 	return 0;
 #endif
 #endif
 };
 };

+ 0 - 1
modules/mobile_vr/mobile_vr_interface.cpp

@@ -398,7 +398,6 @@ void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_t
 	ERR_FAIL_COND(p_screen_rect == Rect2());
 	ERR_FAIL_COND(p_screen_rect == Rect2());
 
 
 	Rect2 dest = p_screen_rect;
 	Rect2 dest = p_screen_rect;
-	float aspect_ratio = 0.5 * p_screen_rect.size.x / p_screen_rect.size.y;
 	Vector2 eye_center;
 	Vector2 eye_center;
 
 
 	// we output half a screen
 	// we output half a screen

+ 11 - 3
platform/android/SCsub

@@ -18,14 +18,17 @@ android_files = [
     'dir_access_jandroid.cpp',
     'dir_access_jandroid.cpp',
     'thread_jandroid.cpp',
     'thread_jandroid.cpp',
     'audio_driver_jandroid.cpp',
     'audio_driver_jandroid.cpp',
-    'ifaddrs_android.cpp',
-    'android_native_app_glue.c',
     'java_glue.cpp',
     'java_glue.cpp',
-    'cpu-features.c',
     'java_class_wrapper.cpp',
     'java_class_wrapper.cpp',
 #    'power_android.cpp'
 #    'power_android.cpp'
 ]
 ]
 
 
+thirdparty_files = [
+    'ifaddrs_android.cpp',
+    'android_native_app_glue.c',
+    'cpu-features.c',
+]
+
 env_android = env.Clone()
 env_android = env.Clone()
 if env['target'] == "profile":
 if env['target'] == "profile":
     env_android.Append(CPPFLAGS=['-DPROFILER_ENABLED'])
     env_android.Append(CPPFLAGS=['-DPROFILER_ENABLED'])
@@ -34,6 +37,11 @@ android_objects = []
 for x in android_files:
 for x in android_files:
     android_objects.append(env_android.SharedObject(x))
     android_objects.append(env_android.SharedObject(x))
 
 
+env_thirdparty = env_android.Clone()
+env_thirdparty.disable_warnings()
+for x in thirdparty_files:
+    android_objects.append(env_thirdparty.SharedObject(x))
+
 prog = None
 prog = None
 
 
 abspath = env.Dir(".").abspath
 abspath = env.Dir(".").abspath

+ 3 - 14
platform/android/audio_driver_opensl.cpp

@@ -38,12 +38,7 @@
 /* Structure for passing information to callback function */
 /* Structure for passing information to callback function */
 
 
 void AudioDriverOpenSL::_buffer_callback(
 void AudioDriverOpenSL::_buffer_callback(
-		SLAndroidSimpleBufferQueueItf queueItf
-		/*   SLuint32 eventFlags,
-    const void * pBuffer,
-    SLuint32 bufferSize,
-    SLuint32 dataUsed*/
-) {
+		SLAndroidSimpleBufferQueueItf queueItf) {
 
 
 	bool mix = true;
 	bool mix = true;
 
 
@@ -85,7 +80,6 @@ void AudioDriverOpenSL::_buffer_callbacks(
 
 
 	AudioDriverOpenSL *ad = (AudioDriverOpenSL *)pContext;
 	AudioDriverOpenSL *ad = (AudioDriverOpenSL *)pContext;
 
 
-	//ad->_buffer_callback(queueItf,eventFlags,pBuffer,bufferSize,dataUsed);
 	ad->_buffer_callback(queueItf);
 	ad->_buffer_callback(queueItf);
 }
 }
 
 
@@ -98,12 +92,9 @@ const char *AudioDriverOpenSL::get_name() const {
 
 
 Error AudioDriverOpenSL::init() {
 Error AudioDriverOpenSL::init() {
 
 
-	SLresult
-			res;
+	SLresult res;
 	SLEngineOption EngineOption[] = {
 	SLEngineOption EngineOption[] = {
-		(SLuint32)SL_ENGINEOPTION_THREADSAFE,
-		(SLuint32)SL_BOOLEAN_TRUE
-
+		{ (SLuint32)SL_ENGINEOPTION_THREADSAFE, (SLuint32)SL_BOOLEAN_TRUE }
 	};
 	};
 	res = slCreateEngine(&sl, 1, EngineOption, 0, NULL, NULL);
 	res = slCreateEngine(&sl, 1, EngineOption, 0, NULL, NULL);
 	if (res != SL_RESULT_SUCCESS) {
 	if (res != SL_RESULT_SUCCESS) {
@@ -126,8 +117,6 @@ void AudioDriverOpenSL::start() {
 	mutex = Mutex::create();
 	mutex = Mutex::create();
 	active = false;
 	active = false;
 
 
-	SLint32 numOutputs = 0;
-	SLuint32 deviceID = 0;
 	SLresult res;
 	SLresult res;
 
 
 	buffer_size = 1024;
 	buffer_size = 1024;

+ 1 - 10
platform/android/audio_driver_opensl.h

@@ -70,19 +70,10 @@ class AudioDriverOpenSL : public AudioDriver {
 	static AudioDriverOpenSL *s_ad;
 	static AudioDriverOpenSL *s_ad;
 
 
 	void _buffer_callback(
 	void _buffer_callback(
-			SLAndroidSimpleBufferQueueItf queueItf
-			/*   SLuint32 eventFlags,
-	    const void * pBuffer,
-	    SLuint32 bufferSize,
-	    SLuint32 dataUsed*/
-	);
+			SLAndroidSimpleBufferQueueItf queueItf);
 
 
 	static void _buffer_callbacks(
 	static void _buffer_callbacks(
 			SLAndroidSimpleBufferQueueItf queueItf,
 			SLAndroidSimpleBufferQueueItf queueItf,
-			/*SLuint32 eventFlags,
-	    const void * pBuffer,
-	    SLuint32 bufferSize,
-	    SLuint32 dataUsed,*/
 			void *pContext);
 			void *pContext);
 
 
 public:
 public:

+ 0 - 12
platform/android/java_glue.cpp

@@ -589,8 +589,6 @@ TST tst;
 
 
 static bool initialized = false;
 static bool initialized = false;
 static int step = 0;
 static int step = 0;
-static bool resized = false;
-static bool resized_reload = false;
 static Size2 new_size;
 static Size2 new_size;
 static Vector3 accelerometer;
 static Vector3 accelerometer;
 static Vector3 gravity;
 static Vector3 gravity;
@@ -792,7 +790,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
 		_getClipboard = env->GetMethodID(cls, "getClipboard", "()Ljava/lang/String;");
 		_getClipboard = env->GetMethodID(cls, "getClipboard", "()Ljava/lang/String;");
 		_setClipboard = env->GetMethodID(cls, "setClipboard", "(Ljava/lang/String;)V");
 		_setClipboard = env->GetMethodID(cls, "setClipboard", "(Ljava/lang/String;)V");
 
 
-		jclass clsio = env->FindClass("org/godotengine/godot/Godot");
 		if (cls) {
 		if (cls) {
 			jclass c = env->GetObjectClass(gob);
 			jclass c = env->GetObjectClass(gob);
 			_openURI = env->GetMethodID(c, "openURI", "(Ljava/lang/String;)I");
 			_openURI = env->GetMethodID(c, "openURI", "(Ljava/lang/String;)I");
@@ -886,8 +883,6 @@ static void _initialize_java_modules() {
 				ERR_EXPLAIN("Couldn't find proper initialize function 'public static Godot.SingletonBase Class::initialize(Activity p_activity)' initializer for singleton class: " + m);
 				ERR_EXPLAIN("Couldn't find proper initialize function 'public static Godot.SingletonBase Class::initialize(Activity p_activity)' initializer for singleton class: " + m);
 				ERR_CONTINUE(!initialize);
 				ERR_CONTINUE(!initialize);
 			}
 			}
-			jobject obj = env->CallStaticObjectMethod(singletonClass, initialize, _godot_instance);
-			jobject gob = env->NewGlobalRef(obj);
 		}
 		}
 	}
 	}
 }
 }
@@ -931,13 +926,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, j
 
 
 	if (os_android)
 	if (os_android)
 		os_android->set_display_size(Size2(width, height));
 		os_android->set_display_size(Size2(width, height));
-
-	/*input_mutex->lock();
-	resized=true;
-	if (reload)
-		resized_reload=true;
-	new_size=Size2(width,height);
-	input_mutex->unlock();*/
 }
 }
 
 
 JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jobject obj, bool p_32_bits) {
 JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jobject obj, bool p_32_bits) {

+ 3 - 2
platform/android/os_android.cpp

@@ -677,13 +677,14 @@ String OS_Android::get_unique_id() const {
 	return OS::get_unique_id();
 	return OS::get_unique_id();
 }
 }
 
 
-Error OS_Android::native_video_play(String p_path, float p_volume) {
+Error OS_Android::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
+	// FIXME: Add support for volume, audio and subtitle tracks
 	if (video_play_func)
 	if (video_play_func)
 		video_play_func(p_path);
 		video_play_func(p_path);
 	return OK;
 	return OK;
 }
 }
 
 
-bool OS_Android::native_video_is_playing() {
+bool OS_Android::native_video_is_playing() const {
 	if (video_is_playing_func)
 	if (video_is_playing_func)
 		return video_is_playing_func();
 		return video_is_playing_func();
 	return false;
 	return false;

+ 2 - 2
platform/android/os_android.h

@@ -237,8 +237,8 @@ public:
 	void process_event(Ref<InputEvent> p_event);
 	void process_event(Ref<InputEvent> p_event);
 	void init_video_mode(int p_video_width, int p_video_height);
 	void init_video_mode(int p_video_width, int p_video_height);
 
 
-	virtual Error native_video_play(String p_path, float p_volume);
-	virtual bool native_video_is_playing();
+	virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
+	virtual bool native_video_is_playing() const;
 	virtual void native_video_pause();
 	virtual void native_video_pause();
 	virtual void native_video_stop();
 	virtual void native_video_stop();