From d98729b8aaed84586efbd67cf6d8e9feb1194bbd Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 18 Jan 2013 11:50:31 +0100 Subject: [PATCH] Added libneon to detect neon in NDK instead of reading /proc/cpuinfo --- jni/Android.mk | 1 + jni/Application.mk | 2 +- jni/libneon/Android.mk | 37 ++++++++++++++++++++++++++++++++++ jni/libneon/libneon_jni.cc | 37 ++++++++++++++++++++++++++++++++++ src/org/linphone/CpuUtils.java | 34 +++++++++++++++++++++++++++++++ submodules/linphone | 2 +- 6 files changed, 111 insertions(+), 2 deletions(-) create mode 100755 jni/libneon/Android.mk create mode 100644 jni/libneon/libneon_jni.cc create mode 100644 src/org/linphone/CpuUtils.java diff --git a/jni/Android.mk b/jni/Android.mk index f6d3fe46b..300f025e0 100755 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -19,6 +19,7 @@ LINPHONE_VIDEO=0 BUILD_X264=0 endif +include $(linphone-root-dir)/jni/libneon/Android.mk ##ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) ifeq ($(BUILD_GPLV3_ZRTP), 1) diff --git a/jni/Application.mk b/jni/Application.mk index e502c0948..224f4faa8 100644 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -1,5 +1,5 @@ APP_PROJECT_PATH := $(call my-dir)/../ -APP_MODULES :=libspeex libgsm libortp libosip2 libeXosip2 libmediastreamer2 liblinphone liblinphonenoneon +APP_MODULES :=libspeex libgsm libortp libosip2 libeXosip2 libmediastreamer2 liblinphone liblinphonenoneon libneon APP_STL := stlport_static #default values diff --git a/jni/libneon/Android.mk b/jni/libneon/Android.mk new file mode 100755 index 000000000..dbdb0078f --- /dev/null +++ b/jni/libneon/Android.mk @@ -0,0 +1,37 @@ +## +## Android.mk -Android build script- +## +## +## Copyright (C) 2010 Belledonne Communications, Grenoble, France +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +## + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_CPP_EXTENSION := .cc + +LOCAL_SRC_FILES := \ + libneon_jni.cc + +LOCAL_STATIC_LIBRARIES := cpufeatures + +LOCAL_MODULE := libneon + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,android/cpufeatures) diff --git a/jni/libneon/libneon_jni.cc b/jni/libneon/libneon_jni.cc new file mode 100644 index 000000000..15298e803 --- /dev/null +++ b/jni/libneon/libneon_jni.cc @@ -0,0 +1,37 @@ +/* +libneon_jni.cc +Copyright (C) 2013 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include + +extern "C" { +#include +#include + +static JavaVM *jvm=0; + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) +{ + jvm=ajvm; + return JNI_VERSION_1_2; +} + +extern "C" jboolean Java_org_linphone_CpuUtils_hasNeon(JNIEnv* env, jobject thiz) { + return android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON; +} +} diff --git a/src/org/linphone/CpuUtils.java b/src/org/linphone/CpuUtils.java new file mode 100644 index 000000000..3882f6098 --- /dev/null +++ b/src/org/linphone/CpuUtils.java @@ -0,0 +1,34 @@ +package org.linphone; +/* +CpuUtils.java +Copyright (C) 2013 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * @author Sylvain Berfini + */ +public class CpuUtils { + private native boolean hasNeon(); + + public CpuUtils() { + + } + + public boolean isCpuNeon() { + return hasNeon(); + } +} diff --git a/submodules/linphone b/submodules/linphone index d496d9584..ebfa43d5b 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit d496d958452a3147eeefb9ba01be233b5b4f0b58 +Subproject commit ebfa43d5b22d986b5d0076cd04a8d0e8fbfd7fd8