From 8afee2e81cc10b7f7c8d1c7562f4b72b9348d027 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sun, 29 May 2011 12:45:32 +0200 Subject: [PATCH] Android: install codecs as native libs instead of extracting them. Codec files are loaded as dynamic libraries. Instead of extracting them from the packaged libmisc.so and therefore having them present twice on the device put them into the apk as native libraries. Decreases the size of the installed Rockbox by the compressed size of the codecs. Also, the extraction on first Rockbox startup gets notably faster since it's less data to extract. --- android/android.make | 4 ++++ apps/codecs.c | 4 ++-- apps/metadata.h | 6 ++++++ firmware/export/rbpaths.h | 4 ++++ tools/buildzip.pl | 8 ++++++-- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/android/android.make b/android/android.make index 108aa5e..ddf152f 100644 --- a/android/android.make +++ b/android/android.make @@ -46,6 +46,7 @@ JAVA_OBJ := $(call java2class,$(subst $(ANDROID)/src/$(PACKAGE_PATH),$(ANDROID)/ LIBS := $(BINLIB_DIR)/$(BINARY) $(BINLIB_DIR)/libmisc.so +LIBS += $(addprefix $(BINLIB_DIR)/lib,$(patsubst %.codec,%.so,$(notdir $(CODECS)))) TEMP_APK := $(BUILDDIR)/bin/_rockbox.apk TEMP_APK2 := $(BUILDDIR)/bin/__rockbox.apk DEX := $(BUILDDIR)/bin/classes.dex @@ -108,6 +109,9 @@ $(BINLIB_DIR)/$(BINARY): $(BUILDDIR)/$(BINARY) $(BINLIB_DIR)/libmisc.so: $(BUILDDIR)/rockbox.zip $(call PRINTS,CP rockbox.zip)cp $^ $@ +$(BINLIB_DIR)/lib%.so: $(BUILDDIR)/apps/codecs/%.codec + $(call PRINTS,CP $(@F))cp $^ $@ + libs: $(LIBS) $(TEMP_APK): $(AP_) $(LIBS) $(DEX) | $(DIRS) diff --git a/apps/codecs.c b/apps/codecs.c index 249cd8f..cd4a9d5 100644 --- a/apps/codecs.c +++ b/apps/codecs.c @@ -169,8 +169,8 @@ struct codec_api ci = { void codec_get_full_path(char *path, const char *codec_root_fn) { - snprintf(path, MAX_PATH-1, "%s/%s." CODEC_EXTENSION, - CODECS_DIR, codec_root_fn); + snprintf(path, MAX_PATH-1, CODECS_DIR "/" CODEC_PREFIX "%s." + CODEC_EXTENSION, codec_root_fn); } /* Returns pointer to and size of free codec RAM. Aligns to CACHEALIGN_SIZE. */ diff --git a/apps/metadata.h b/apps/metadata.h index 3499e13..a191e43 100644 --- a/apps/metadata.h +++ b/apps/metadata.h @@ -107,7 +107,13 @@ enum }; #if CONFIG_CODEC == SWCODEC +#if (CONFIG_PLATFORM & PLATFORM_ANDROID) +#define CODEC_EXTENSION "so" +#define CODEC_PREFIX "lib" +#else #define CODEC_EXTENSION "codec" +#define CODEC_PREFIX "" +#endif #ifdef HAVE_RECORDING enum rec_format_indexes diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h index ade7894..74d26f9 100644 --- a/firmware/export/rbpaths.h +++ b/firmware/export/rbpaths.h @@ -60,7 +60,11 @@ #else /* application */ #define PLUGIN_DIR ROCKBOX_LIBRARY_PATH "/rockbox/rocks" +#if (CONFIG_PLATFORM & PLATFORM_ANDROID) +#define CODECS_DIR ROCKBOX_BINARY_PATH +#else #define CODECS_DIR ROCKBOX_LIBRARY_PATH "/rockbox/codecs" +#endif #define REC_BASE_DIR ROCKBOX_DIR "/" #define PLAYLIST_CATALOG_DEFAULT_DIR ROCKBOX_DIR "/Playlists" diff --git a/tools/buildzip.pl b/tools/buildzip.pl index 2337dbe..9ff8d9d 100755 --- a/tools/buildzip.pl +++ b/tools/buildzip.pl @@ -150,7 +150,9 @@ sub make_install { unless (glob_mkdir("$libdir/codecs")) { return 0; } - glob_install("$src/codecs/*", "$libdir/codecs", "-m 0755"); + if ($modelname !~ /android/) { + glob_install("$src/codecs/*", "$libdir/codecs", "-m 0755"); + } # plugins unless (glob_mkdir("$libdir/rocks")) { @@ -473,7 +475,9 @@ STOP glob_mkdir("$temp_dir/codecs"); - find(find_copyfile(qr/.*\.codec/, abs_path("$temp_dir/codecs/")), 'apps/codecs'); + if ($modelname !~ /android/) { + find(find_copyfile(qr/.*\.codec/, abs_path("$temp_dir/codecs/")), 'apps/codecs'); + } # remove directory again if no codec was copied rmdir("$temp_dir/codecs"); -- 1.7.5.2