diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2016-07-21 17:31:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-21 17:31:14 +0200 |
commit | 93de25f68a6b277293c0d3476996ab074ba3dc16 (patch) | |
tree | 54a0373eb925fab10751a662744daa08aadb2229 | |
parent | 2c1a74fb3a8aac2d8d8a7050b890aa780a5f0356 (diff) | |
parent | beaa56bff209d4a4a24e556ff4b592f380c99550 (diff) |
Merge pull request #5837 from hurikhan/android_cleanup
Minor code formatting in platform/android
-rw-r--r-- | platform/android/audio_driver_jandroid.cpp | 12 | ||||
-rw-r--r-- | platform/android/audio_driver_opensl.cpp | 6 | ||||
-rw-r--r-- | platform/android/dir_access_android.cpp | 5 | ||||
-rw-r--r-- | platform/android/dir_access_jandroid.cpp | 3 | ||||
-rw-r--r-- | platform/android/export/export.cpp | 4 | ||||
-rw-r--r-- | platform/android/file_access_android.cpp | 5 | ||||
-rw-r--r-- | platform/android/file_access_jandroid.cpp | 13 | ||||
-rw-r--r-- | platform/android/ifaddrs_android.cpp | 11 | ||||
-rw-r--r-- | platform/android/java_class_wrapper.cpp | 5 | ||||
-rw-r--r-- | platform/android/java_glue.cpp | 26 | ||||
-rw-r--r-- | platform/android/java_glue.h | 2 | ||||
-rw-r--r-- | platform/android/os_android.cpp | 22 | ||||
-rw-r--r-- | platform/android/thread_jandroid.cpp | 2 |
13 files changed, 69 insertions, 47 deletions
diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index 6d428e3fe5..419ed977b5 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -192,29 +192,31 @@ void AudioDriverAndroid::thread_func(JNIEnv *env) { env->CallVoidMethod(gob, _write_buffer, (jshortArray)audioBuffer); } - - } int AudioDriverAndroid::get_mix_rate() const { return mix_rate; } + AudioDriverSW::OutputFormat AudioDriverAndroid::get_output_format() const{ return OUTPUT_STEREO; } + void AudioDriverAndroid::lock(){ if (mutex) mutex->lock(); } + void AudioDriverAndroid::unlock() { if (mutex) mutex->unlock(); } + void AudioDriverAndroid::finish(){ JNIEnv *env = ThreadAndroid::get_env(); @@ -236,13 +238,11 @@ void AudioDriverAndroid::set_pause(bool p_pause) { } -AudioDriverAndroid::AudioDriverAndroid() -{ +AudioDriverAndroid::AudioDriverAndroid() { + s_ad=this; active=false; - - } #endif diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index a908f6193e..b7ef1424e5 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -207,6 +207,7 @@ Error AudioDriverOpenSL::init(){ return OK; } + void AudioDriverOpenSL::start(){ @@ -366,26 +367,31 @@ void AudioDriverOpenSL::start(){ active=true; } + int AudioDriverOpenSL::get_mix_rate() const { return 44100; } + AudioDriverSW::OutputFormat AudioDriverOpenSL::get_output_format() const{ return OUTPUT_STEREO; } + void AudioDriverOpenSL::lock(){ if (active && mutex) mutex->lock(); } + void AudioDriverOpenSL::unlock() { if (active && mutex) mutex->unlock(); } + void AudioDriverOpenSL::finish(){ (*sl)->Destroy(sl); diff --git a/platform/android/dir_access_android.cpp b/platform/android/dir_access_android.cpp index 85df5dc37a..79ba83b3ee 100644 --- a/platform/android/dir_access_android.cpp +++ b/platform/android/dir_access_android.cpp @@ -61,6 +61,7 @@ String DirAccessAndroid::get_next(){ } + bool DirAccessAndroid::current_is_dir() const{ String sd; @@ -79,9 +80,11 @@ bool DirAccessAndroid::current_is_dir() const{ return false; } + bool DirAccessAndroid::current_is_hidden() const{ return current!="." && current!=".." && current.begins_with("."); } + void DirAccessAndroid::list_dir_end(){ if (aad==NULL) @@ -96,6 +99,7 @@ int DirAccessAndroid::get_drive_count(){ return 0; } + String DirAccessAndroid::get_drive(int p_drive){ return ""; @@ -164,6 +168,7 @@ Error DirAccessAndroid::rename(String p_from, String p_to){ ERR_FAIL_V(ERR_UNAVAILABLE); } + Error DirAccessAndroid::remove(String p_name){ ERR_FAIL_V(ERR_UNAVAILABLE); diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 8b7cb992d9..be2ffde2cd 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -76,6 +76,7 @@ String DirAccessJAndroid::get_next(){ return ret; } + bool DirAccessJAndroid::current_is_dir() const{ @@ -106,6 +107,7 @@ int DirAccessJAndroid::get_drive_count(){ return 0; } + String DirAccessJAndroid::get_drive(int p_drive){ return ""; @@ -215,6 +217,7 @@ Error DirAccessJAndroid::rename(String p_from, String p_to){ ERR_FAIL_V(ERR_UNAVAILABLE); } + Error DirAccessJAndroid::remove(String p_name){ ERR_FAIL_V(ERR_UNAVAILABLE); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index f4fafc4fab..10d77aba6c 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1482,6 +1482,7 @@ int EditorExportPlatformAndroid::get_device_count() const { return dc; } + String EditorExportPlatformAndroid::get_device_name(int p_device) const { ERR_FAIL_INDEX_V(p_device,devices.size(),""); @@ -1490,6 +1491,7 @@ String EditorExportPlatformAndroid::get_device_name(int p_device) const { device_lock->unlock(); return s; } + String EditorExportPlatformAndroid::get_device_info(int p_device) const { ERR_FAIL_INDEX_V(p_device,devices.size(),""); @@ -1883,7 +1885,6 @@ bool EditorExportPlatformAndroid::can_export(String *r_error) const { EditorExportPlatformAndroid::~EditorExportPlatformAndroid() { - quit_request=true; Thread::wait_to_finish(device_thread); memdelete(device_lock); @@ -1912,6 +1913,5 @@ void register_android_exporter() { Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>( memnew(EditorExportPlatformAndroid) ); EditorImportExport::get_singleton()->add_export_platform(exporter); - } diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index 334d32de0c..aefa16ca9c 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -74,6 +74,7 @@ void FileAccessAndroid::close() { AAsset_close(a); a=NULL; } + bool FileAccessAndroid::is_open() const { return a!=NULL; @@ -92,6 +93,7 @@ void FileAccessAndroid::seek(size_t p_position) { } } + void FileAccessAndroid::seek_end(int64_t p_position) { ERR_FAIL_COND(!a); @@ -99,10 +101,12 @@ void FileAccessAndroid::seek_end(int64_t p_position) { pos=len+p_position; } + size_t FileAccessAndroid::get_pos() const { return pos; } + size_t FileAccessAndroid::get_len() const { return len; @@ -128,6 +132,7 @@ uint8_t FileAccessAndroid::get_8() const { return byte; } + int FileAccessAndroid::get_buffer(uint8_t *p_dst, int p_length) const { diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp index ea33e9a67b..3d2e525bbc 100644 --- a/platform/android/file_access_jandroid.cpp +++ b/platform/android/file_access_jandroid.cpp @@ -90,6 +90,7 @@ void FileAccessJAndroid::close() { id=0; } + bool FileAccessJAndroid::is_open() const { return id!=0; @@ -102,6 +103,7 @@ void FileAccessJAndroid::seek(size_t p_position) { ERR_FAIL_COND(!is_open()); env->CallVoidMethod(io,_file_seek,id,p_position); } + void FileAccessJAndroid::seek_end(int64_t p_position) { ERR_FAIL_COND(!is_open()); @@ -109,6 +111,7 @@ void FileAccessJAndroid::seek_end(int64_t p_position) { seek(get_len()); } + size_t FileAccessJAndroid::get_pos() const { JNIEnv *env = ThreadAndroid::get_env(); @@ -116,13 +119,13 @@ size_t FileAccessJAndroid::get_pos() const { return env->CallIntMethod(io,_file_tell,id); } + size_t FileAccessJAndroid::get_len() const { JNIEnv *env = ThreadAndroid::get_env(); ERR_FAIL_COND_V(!is_open(),0); return env->CallIntMethod(io,_file_get_size,id); - } bool FileAccessJAndroid::eof_reached() const { @@ -167,7 +170,6 @@ Error FileAccessJAndroid::get_error() const { void FileAccessJAndroid::store_8(uint8_t p_dest) { - } bool FileAccessJAndroid::file_exists(const String& p_path) { @@ -195,7 +197,6 @@ bool FileAccessJAndroid::file_exists(const String& p_path) { void FileAccessJAndroid::setup( jobject p_io) { - io=p_io; JNIEnv *env = ThreadAndroid::get_env(); @@ -239,14 +240,12 @@ void FileAccessJAndroid::setup( jobject p_io) { } -FileAccessJAndroid::FileAccessJAndroid() -{ +FileAccessJAndroid::FileAccessJAndroid() { id=0; } -FileAccessJAndroid::~FileAccessJAndroid() -{ +FileAccessJAndroid::~FileAccessJAndroid() { if (is_open()) close(); diff --git a/platform/android/ifaddrs_android.cpp b/platform/android/ifaddrs_android.cpp index c1e9eb3584..f6d5cdbe77 100644 --- a/platform/android/ifaddrs_android.cpp +++ b/platform/android/ifaddrs_android.cpp @@ -38,13 +38,16 @@ #include <errno.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> + struct netlinkrequest { nlmsghdr header; ifaddrmsg msg; }; + namespace { const int kMaxReadSize = 4096; -}; +} + static int set_ifname(struct ifaddrs* ifaddr, int interface) { char buf[IFNAMSIZ] = {0}; char* name = if_indextoname(interface, buf); @@ -55,6 +58,7 @@ static int set_ifname(struct ifaddrs* ifaddr, int interface) { strncpy(ifaddr->ifa_name, name, strlen(name) + 1); return 0; } + static int set_flags(struct ifaddrs* ifaddr) { int fd = socket(AF_INET, SOCK_DGRAM, 0); if (fd == -1) { @@ -71,6 +75,7 @@ static int set_flags(struct ifaddrs* ifaddr) { ifaddr->ifa_flags = ifr.ifr_flags; return 0; } + static int set_addresses(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* data, size_t len) { if (msg->ifa_family == AF_INET) { @@ -89,6 +94,7 @@ static int set_addresses(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* data, } return 0; } + static int make_prefixes(struct ifaddrs* ifaddr, int family, int prefixlen) { char* prefix = NULL; if (family == AF_INET) { @@ -120,6 +126,7 @@ static int make_prefixes(struct ifaddrs* ifaddr, int family, int prefixlen) { *prefix = remainder; return 0; } + static int populate_ifaddrs(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* bytes, size_t len) { if (set_ifname(ifaddr, msg->ifa_index) != 0) { @@ -136,6 +143,7 @@ static int populate_ifaddrs(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* bytes, } return 0; } + int getifaddrs(struct ifaddrs** result) { int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (fd < 0) { @@ -207,6 +215,7 @@ int getifaddrs(struct ifaddrs** result) { freeifaddrs(start); return -1; } + void freeifaddrs(struct ifaddrs* addrs) { struct ifaddrs* last = NULL; struct ifaddrs* cursor = addrs; diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index 4fda13fec0..cc1e5b61d1 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -540,25 +540,21 @@ Variant JavaClass::call(const StringName& p_method,const Variant** p_args,int p_ JavaClass::JavaClass() { - } ///////////////////// Variant JavaObject::call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error){ - return Variant(); } JavaObject::JavaObject(const Ref<JavaClass>& p_base,jobject *p_instance) { - } JavaObject::~JavaObject(){ - } @@ -1356,5 +1352,4 @@ JavaClassWrapper::JavaClassWrapper(jobject p_activity) { bclass = env->FindClass("java/lang/Double"); Double_doubleValue = env->GetMethodID(bclass, "doubleValue", "()D"); - } diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 96e6b85230..e5b655e5d5 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -215,7 +215,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant* p_a } return v; -}; +} String _get_class_name(JNIEnv * env, jclass cls, bool* array) { @@ -233,7 +233,7 @@ String _get_class_name(JNIEnv * env, jclass cls, bool* array) { return name; -}; +} Variant _jobject_to_variant(JNIEnv * env, jobject obj) { @@ -406,7 +406,7 @@ Variant _jobject_to_variant(JNIEnv * env, jobject obj) { env->DeleteLocalRef(c); return Variant(); -}; +} class JNISingleton : public Object { @@ -731,27 +731,27 @@ static void _show_vk(const String& p_existing) { JNIEnv* env = ThreadAndroid::get_env(); jstring jStr = env->NewStringUTF(p_existing.utf8().get_data()); env->CallVoidMethod(godot_io, _showKeyboard, jStr); -}; +} static void _set_screen_orient(int p_orient) { JNIEnv* env = ThreadAndroid::get_env(); env->CallVoidMethod(godot_io, _setScreenOrientation, p_orient ); -}; +} static String _get_system_dir(int p_dir) { JNIEnv *env = ThreadAndroid::get_env(); jstring s =(jstring)env->CallObjectMethod(godot_io,_getSystemDir,p_dir); return String(env->GetStringUTFChars( s, NULL )); -}; +} static void _hide_vk() { JNIEnv* env = ThreadAndroid::get_env(); env->CallVoidMethod(godot_io, _hideKeyboard); -}; +} // virtual Error native_video_play(String p_path); // virtual bool native_video_is_playing(); @@ -953,7 +953,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv * e os_android->reload_gfx(); } - } @@ -968,7 +967,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_quit(JNIEnv * env, jo static void _initialize_java_modules() { - String modules = Globals::get_singleton()->get("android/modules"); Vector<String> mods = modules.split(",",false); print_line("ANDROID MODULES : " + modules); @@ -1417,7 +1415,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv * en input_mutex->lock(); joy_events.push_back(jevent); input_mutex->unlock(); -}; +} JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv * env, jobject obj, jint p_device, jint p_axis, jfloat p_value) { @@ -1430,7 +1428,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv * env, input_mutex->lock(); joy_events.push_back(jevent); input_mutex->unlock(); -}; +} JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv * env, jobject obj, jint p_device, jint p_hat_x, jint p_hat_y) { OS_Android::JoystickEvent jevent; @@ -1493,7 +1491,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv * env, job input_mutex->lock(); key_events.push_back(ievent); input_mutex->unlock(); -}; +} JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z) { @@ -1722,7 +1720,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv * e env->PopLocalFrame(NULL); -}; +} JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * env, jobject p_obj, jint ID, jstring method, jobjectArray params) { @@ -1757,7 +1755,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * // something env->PopLocalFrame(NULL); -}; +} //Main::cleanup(); diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h index ae7ced45ee..f1c83f01e8 100644 --- a/platform/android/java_glue.h +++ b/platform/android/java_glue.h @@ -58,7 +58,7 @@ extern "C" { JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv * env, jobject obj, jstring path); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv * env, jobject obj, jint ID, jstring method, jobjectArray params); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * env, jobject obj, jint ID, jstring method, jobjectArray params); -}; +} #endif diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 1bddf13ad1..4e395a6f9f 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -53,6 +53,7 @@ int OS_Android::get_video_driver_count() const { return 1; } + const char * OS_Android::get_video_driver_name(int p_driver) const { return "GLES2"; @@ -271,17 +272,18 @@ bool OS_Android::is_mouse_grab_enabled() const { //*sigh* technology has evolved so much since i was a kid.. return false; } + Point2 OS_Android::get_mouse_pos() const { return Point2(); } + int OS_Android::get_mouse_button_state() const { return 0; } void OS_Android::set_window_title(const String& p_title) { - } //interesting byt not yet @@ -290,13 +292,13 @@ void OS_Android::set_window_title(const String& p_title) { void OS_Android::set_video_mode(const VideoMode& p_video_mode,int p_screen) { - } OS::VideoMode OS_Android::get_video_mode(int p_screen) const { return default_videomode; } + void OS_Android::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { p_list->push_back(default_videomode); @@ -340,6 +342,7 @@ void OS_Android::main_loop_begin() { if (main_loop) main_loop->init(); } + bool OS_Android::main_loop_iterate() { if (!main_loop) @@ -394,7 +397,7 @@ void OS_Android::process_event(InputEvent p_event) { p_event.ID = last_id++; input->parse_input_event(p_event); -}; +} void OS_Android::process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points) { @@ -627,7 +630,7 @@ bool OS_Android::has_touchscreen_ui_hint() const { bool OS_Android::has_virtual_keyboard() const { return true; -}; +} void OS_Android::show_virtual_keyboard(const String& p_existing_text,const Rect2& p_screen_rect) { @@ -637,7 +640,7 @@ void OS_Android::show_virtual_keyboard(const String& p_existing_text,const Rect2 ERR_PRINT("Virtual keyboard not available"); }; -}; +} void OS_Android::hide_virtual_keyboard() { @@ -648,7 +651,7 @@ void OS_Android::hide_virtual_keyboard() { ERR_PRINT("Virtual keyboard not available"); }; -}; +} void OS_Android::init_video_mode(int p_video_width,int p_video_height) { @@ -684,7 +687,7 @@ Error OS_Android::shell_open(String p_uri) { if (open_uri_func) return open_uri_func(p_uri)?ERR_CANT_OPEN:OK; return ERR_UNAVAILABLE; -}; +} String OS_Android::get_resource_dir() const { @@ -749,12 +752,11 @@ String OS_Android::get_data_dir() const { return "."; //return Globals::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir"); -}; +} void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) { - if (set_screen_orientation_func) set_screen_orientation_func(p_orientation); } @@ -817,7 +819,6 @@ String OS_Android::get_joy_guid(int p_device) const { OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, bool p_use_apk_expansion) { - use_apk_expansion=p_use_apk_expansion; default_videomode.width=800; default_videomode.height=600; @@ -856,5 +857,4 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu OS_Android::~OS_Android() { - } diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp index 61ee237586..73818b282f 100644 --- a/platform/android/thread_jandroid.cpp +++ b/platform/android/thread_jandroid.cpp @@ -64,10 +64,12 @@ Thread* ThreadAndroid::create_func_jandroid(ThreadCreateCallback p_callback,void return tr; } + Thread::ID ThreadAndroid::get_thread_ID_func_jandroid() { return (ID)pthread_self(); } + void ThreadAndroid::wait_to_finish_func_jandroid(Thread* p_thread) { ThreadAndroid *tp=static_cast<ThreadAndroid*>(p_thread); |