Skip to content

Commit

Permalink
towards android port
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmaclarty committed Apr 9, 2017
1 parent b6accfd commit 3619b47
Show file tree
Hide file tree
Showing 11 changed files with 747 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
config.log
config.status
amulet
amulet.exe
libamulet.so
builds/*
tags
settings
Expand Down
27 changes: 27 additions & 0 deletions Common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,30 @@ else ifeq ($(TARGET_PLATFORM),iossim)
-Wl,-framework,GLKit $(GOOGLE_ADS_FRAMEWORK_OPT)
LUA_CFLAGS += -DLUA_USE_POSIX
IOS = 1
else ifeq ($(TARGET_PLATFORM),android)
NDK_HOME=$(HOME)/android/ndk-r14
NDK_HOST=darwin-x86_64
ANDROID_VER=16
NDK_VER=$(NDK_HOME)/toolchains/arm-linux-androideabi-4.9
NDK_SYSROOT=$(NDK_HOME)/platforms/android-$(ANDROID_VER)/arch-arm
CC = $(NDK_HOME)/toolchains/llvm/prebuilt/$(NDK_HOST)/bin/clang
CPP = $(NDK_HOME)/toolchains/llvm/prebuilt/$(NDK_HOST)/bin/clang++
LINK = $(CPP)
AR= $(NDK_VER)/prebuilt/$(NDK_HOST)/bin/arm-linux-androideabi-ar
TARGET_CFLAGS += --sysroot $(NDK_SYSROOT) -gcc-toolchain $(NDK_VER)/prebuilt/$(NDK_HOST) -fpic \
-target armv7-none-linux-androideabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-exceptions -fno-rtti \
-I$(NDK_HOME)/sources/android/native_app_glue \
-I$(NDK_HOME)/sources/cxx-stl/gnu-libstdc++/4.9/include \
-I$(NDK_HOME)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include \
-I$(NDK_HOME)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward \
-I$(NDK_SYSROOT)usr/include \
-DANDROID
XLDFLAGS = $(TARGET_CFLAGS) -Wl,-soname,libamulet.so -shared \
$(NDK_HOME)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a -lgcc \
-no-canonical-prefixes -Wl,--fix-cortex-a8 \
-L$(NDK_SYSROOT)/usr/lib -llog -landroid -lEGL -lGLESv2 -lOpenSLES -llog -lc -lm
LUA_CFLAGS += -DLUA_USE_POSIX
ANDROID = 1
else ifeq ($(TARGET_PLATFORM),html)
CC = emcc
CPP = em++
Expand Down Expand Up @@ -307,6 +331,9 @@ else
else ifeq ($(TARGET_PLATFORM),ios64)
GRADE_CFLAGS = -O3 -DNDEBUG
GRADE_LDFLAGS =
else ifeq ($(TARGET_PLATFORM),android)
GRADE_CFLAGS = -O3 -DNDEBUG
GRADE_LDFLAGS =
else
GRADE_CFLAGS = -O3 -DNDEBUG
GRADE_LDFLAGS = -s
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ else ifdef IOS
else ifeq ($(TARGET_PLATFORM),msvc32)
AM_DEPS = $(LUAVM) stb kissfft tinymt ft2
EXTRA_PREREQS = $(SDL_PREBUILT) $(ANGLE_WIN_PREBUILT) $(SIMPLEGLOB_H)
else ifdef ANDROID
AM_DEPS = $(LUAVM) stb kissfft tinymt
AMULET = $(BUILD_BIN_DIR)/libamulet.so
else ifeq ($(TARGET_PLATFORM),mingw32)
AM_DEPS = $(LUAVM) stb kissfft tinymt ft2
EXTRA_PREREQS = $(SDL_PREBUILT) $(ANGLE_WIN_PREBUILT) $(SIMPLEGLOB_H)
Expand Down
18 changes: 18 additions & 0 deletions src/am_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,24 @@ void am_interleave_audio(float* AM_RESTRICT dest, float* AM_RESTRICT src,
}
}

void am_interleave_audio16(int16_t* AM_RESTRICT dest, float* AM_RESTRICT src,
int num_channels, int num_samples, int sample_offset, int count)
{
int i, j;
int k = sample_offset + count;
assert(k <= num_samples);
for (int c = 0; c < num_channels; c++) {
i = k - count;
j = c;
while (i != k) {
dest[j] = (int16_t)(src[i] * 32767.0);
i++;
j += num_channels;
}
k += num_samples;
}
}

void am_uninterleave_audio(float* AM_RESTRICT dest, float* AM_RESTRICT src,
int num_channels, int num_samples)
{
Expand Down
2 changes: 2 additions & 0 deletions src/am_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,7 @@ void am_sync_audio_graph(lua_State *L);

void am_interleave_audio(float* AM_RESTRICT dest, float* AM_RESTRICT src,
int num_channels, int num_samples, int sample_offset, int count);
void am_interleave_audio16(int16_t* AM_RESTRICT dest, float* AM_RESTRICT src,
int num_channels, int num_samples, int sample_offset, int count);
void am_uninterleave_audio(float* AM_RESTRICT dest, float* AM_RESTRICT src,
int num_channels, int num_samples);
Loading

0 comments on commit 3619b47

Please sign in to comment.