Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add android support #1

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := libspeex
LOCAL_CFLAGS := -DHAVE_CONFIG_H
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include

LOCAL_ARM_MODE := arm

LOCAL_SRC_FILES := \
libspeex/bits.c \
libspeex/cb_search.c \
libspeex/exc_10_32_table.c \
libspeex/exc_10_16_table.c \
libspeex/exc_20_32_table.c \
libspeex/exc_5_256_table.c \
libspeex/exc_5_64_table.c \
libspeex/exc_8_128_table.c \
libspeex/filters.c \
libspeex/gain_table.c \
libspeex/hexc_table.c \
libspeex/high_lsp_tables.c \
libspeex/lsp.c \
libspeex/ltp.c \
libspeex/speex.c \
libspeex/stereo.c \
libspeex/vbr.c \
libspeex/vq.c \
libspeex/gain_table_lbr.c \
libspeex/hexc_10_32_table.c \
libspeex/lpc.c \
libspeex/lsp_tables_nb.c \
libspeex/modes.c \
libspeex/modes_wb.c \
libspeex/nb_celp.c \
libspeex/quant_lsp.c \
libspeex/sb_celp.c \
libspeex/speex_callbacks.c \
libspeex/speex_header.c \
libspeex/window.c

include $(BUILD_STATIC_LIBRARY)

39 changes: 39 additions & 0 deletions android/build_native.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

mkdir ../dist
mkdir ../dist/arm
mkdir ../dist/x86

# for arm
cd ..

export CC=arm-linux-androideabi-gcc

./configure --host=arm --enable-arm5e-asm --enable-fixed-point --disable-float-api

cd android

ndk-build -B V=1 -j4 APP_ABI=armeabi-v7a

ls -lR libs

cp ../config.h ../dist/arm/config.h
cp libs/armeabi-v7a/libspeex-jni.so ../dist/arm/libspeex-jni.so
cp obj/local/armeabi-v7a/libspeex.a ../dist/arm/libspeex.a

# for x86
cd ..

export CC=i686-linux-android-gcc

./configure --host=arm --enable-sse

cd android

ndk-build -B V=1 -j4 APP_ABI=x86

ls -lR libs

cp ../config.h ../dist/x86/config.h
cp libs/armeabi-v7a/libspeex-jni.so ../dist/x86/libspeex-jni.so
cp obj/local/armeabi-v7a/libspeex.a ../dist/x86/libspeex.a
92 changes: 92 additions & 0 deletions android/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
LOCAL_PATH := $(call my-dir)

SPEEX_PATH=$(realpath $(LOCAL_PATH)/../..)
#$(info $(SPEEX_PATH))

ifeq ($(NDK_DEBUG),1)

# for profiler when debug!
include $(CLEAR_VARS)

LOCAL_CFLAGS := -fvisibility=hidden -DDEBUG
LOCAL_MODULE := android-ndk-profiler
LOCAL_SRC_FILES := profiler/gnu_mcount.S profiler/prof.c profiler/read_maps.c

include $(BUILD_STATIC_LIBRARY)
endif

# for speex-jni
include $(CLEAR_VARS)

LOCAL_MODULE := libspeex-jni

LOCAL_CFLAGS += -Wall -fvisibility=hidden
LOCAL_C_INCLUDES := $(SPEEX_PATH)/include

LOCAL_SRC_FILES := speex-jni.cpp
LOCAL_STATIC_LIBRARIES := libspeex

LOCAL_LDLIBS := -llog
LOCAL_LDFLAGS := -Wl,--as-needed

include $(BUILD_SHARED_LIBRARY)

# for speexenc
include $(CLEAR_VARS)

LOCAL_MODULE := speexenc

LOCAL_CFLAGS += -Wall -fvisibility=hidden

# add debug info
ifeq ($(NDK_DEBUG),1)
LOCAL_CFLAGS += -pg -fno-omit-frame-pointer -DENABLE_PROFILER
endif

LOCAL_C_INCLUDES := $(SPEEX_PATH)/include

LOCAL_SRC_FILES := $(SPEEX_PATH)/src/speexenc.c \
$(SPEEX_PATH)/src/skeleton.c \
$(SPEEX_PATH)/src/wav_io.c

LOCAL_STATIC_LIBRARIES := libspeex
# add profiler static library
ifeq ($(NDK_DEBUG),1)
LOCAL_STATIC_LIBRARIES += libandroid-ndk-profiler
endif

LOCAL_LDLIBS := -llog
LOCAL_LDFLAGS := -Wl,--as-needed -logg

include $(BUILD_EXECUTABLE)

# for speexdec
include $(CLEAR_VARS)

LOCAL_MODULE := speexdec

LOCAL_CFLAGS += -Wall -fvisibility=hidden

# add debug info
ifeq ($(NDK_DEBUG),1)
LOCAL_CFLAGS += -pg -fno-omit-frame-pointer -DENABLE_PROFILER
endif

LOCAL_C_INCLUDES := $(SPEEX_PATH)/include

LOCAL_SRC_FILES := $(SPEEX_PATH)/src/speexdec.c \
$(SPEEX_PATH)/src/skeleton.c \
$(SPEEX_PATH)/src/wav_io.c

LOCAL_STATIC_LIBRARIES := libspeex
# add profiler static library
ifeq ($(NDK_DEBUG),1)
LOCAL_STATIC_LIBRARIES += libandroid-ndk-profiler
endif

LOCAL_LDLIBS := -llog
LOCAL_LDFLAGS := -Wl,--as-needed -logg

include $(BUILD_EXECUTABLE)

include $(SPEEX_PATH)/Android.mk
8 changes: 8 additions & 0 deletions android/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The ARMv7 is significanly faster due to the use of the hardware FPU
# APP_ABI := armeabi-v7a armeabi x86 mips
APP_ABI := armeabi-v7a
APP_PLATFORM := android-14

APP_STL := gnustl_static

APP_CPPFLAGS += -fexceptions
148 changes: 148 additions & 0 deletions android/jni/profiler/gmon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* Copyright (c) 1983, 1991, 1993, 2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef gmon_h
#define gmon_h

/* Size of the 4.4BSD gmon header */
#define GMON_HDRSIZE_BSD44_32 (4 + 4 + 4 + 4 + 4 + (3 * 4))
#define GMON_HDRSIZE_BSD44_64 (8 + 8 + 4 + 4 + 4 + (3 * 4))

#if 0 /* For documentation purposes only. */
struct raw_phdr
{
char low_pc[sizeof(void *)]; /* base pc address of sample buffer */
char high_pc[sizeof(void *)];/* max pc address of sampled buffer */
char ncnt[4]; /* size of sample buffer (plus this
header) */

char version[4]; /* version number */
char profrate[4]; /* profiling clock rate */
char spare[3*4]; /* reserved */
};
#endif

#define GMONVERSION 0x00051879

/* Size of the old BSD gmon header */
#define GMON_HDRSIZE_OLDBSD_32 (4 + 4 + 4)

/* FIXME: Checking host compiler defines here means that we can't
use a cross gprof alpha OSF. */
#if defined(__alpha__) && defined (__osf__)
#define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4 + 4)
#else
#define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4)
#endif

#if 0 /* For documentation purposes only. */
struct old_raw_phdr
{
char low_pc[sizeof(void *)]; /* base pc address of sample buffer */
char high_pc[sizeof(void *)];/* max pc address of sampled buffer */
char ncnt[4]; /* size of sample buffer (plus this
header) */
#if defined (__alpha__) && defined (__osf__)
/*
* DEC's OSF v3.0 uses 4 bytes of padding to bring the header to
* a size that is a multiple of 8.
*/
char pad[4];
#endif
};
#endif

/*
* Histogram counters are unsigned shorts:
*/
#define HISTCOUNTER unsigned short

/*
* Fraction of text space to allocate for histogram counters here, 1/2:
*/
#define HISTFRACTION 2

/*
* Fraction of text space to allocate for from hash buckets. The
* value of HASHFRACTION is based on the minimum number of bytes of
* separation between two subroutine call points in the object code.
* Given MIN_SUBR_SEPARATION bytes of separation the value of
* HASHFRACTION is calculated as:
*
* HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
*
* For the VAX, the shortest two call sequence is:
*
* calls $0,(r0)
* calls $0,(r0)
*
* which is separated by only three bytes, thus HASHFRACTION is
* calculated as:
*
* HASHFRACTION = 3 / (2 * 2 - 1) = 1
*
* Note that the division above rounds down, thus if MIN_SUBR_FRACTION
* is less than three, this algorithm will not work!
*/
#define HASHFRACTION 1

/*
* Percent of text space to allocate for tostructs with a minimum:
*/
#define ARCDENSITY 2
#define MINARCS 50

struct tostruct
{
char *selfpc;
int count;
unsigned short link;
};

/*
* A raw arc, with pointers to the calling site and the called site
* and a count. Everything is defined in terms of characters so
* as to get a packed representation (otherwise, different compilers
* might introduce different padding):
*/
#if 0 /* For documentation purposes only. */
struct raw_arc
{
char from_pc[sizeof(void *)];
char self_pc[sizeof(void *)];
char count[sizeof(long)];
};
#endif

/*
* General rounding functions:
*/
#define ROUNDDOWN(x,y) (((x)/(y))*(y))
#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y))

#endif /* gmon_h */
45 changes: 45 additions & 0 deletions android/jni/profiler/gmon_out.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* gmon_out.h

Copyright 2000, 2001 Free Software Foundation, Inc.

This file is part of GNU Binutils.

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. */

/* A gmon.out file consists of a header (defined by gmon_hdr) followed
by a sequence of records. Each record starts with a one-byte tag
identifying the type of records, followed by records specific data. */
#ifndef gmon_out_h
#define gmon_out_h

#define GMON_MAGIC "gmon" /* magic cookie */
#define GMON_VERSION 1 /* version number */

/* Raw header as it appears on file (without padding). */
struct gmon_hdr
{
char cookie[4];
char version[4];
char spare[3 * 4];
};

/* Types of records in this file. */
typedef enum
{
GMON_TAG_TIME_HIST = 0, GMON_TAG_CG_ARC = 1, GMON_TAG_BB_COUNT = 2
}
GMON_Record_Tag;

#endif /* gmon_out_h */
Loading