From 70b81e65cceb83b8933c7da7bdae2ce709404998 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Tue, 31 May 2011 21:26:18 +0000 Subject: [PATCH] Android: install codecs as native libs instead of extracting them (FS#12134). 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. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29940 a1c6a512-1295-4272-9138-f99709370657 --- android/android.make | 4 ++++ apps/codecs.c | 4 ++-- apps/metadata.h | 6 ++++++ firmware/export/rbpaths.h | 4 ++++ tools/buildzip.pl | 12 ++++++++++-- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/android/android.make b/android/android.make index fa3b48eaf8..f12b79750d 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 @@ -107,6 +108,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 249cd8f5c1..cd4a9d50eb 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 3499e13f47..a191e43219 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 ade7894091..74d26f93d3 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 2337dbe729..ed937d42e4 100755 --- a/tools/buildzip.pl +++ b/tools/buildzip.pl @@ -150,7 +150,11 @@ sub make_install { unless (glob_mkdir("$libdir/codecs")) { return 0; } - glob_install("$src/codecs/*", "$libdir/codecs", "-m 0755"); + # Android has codecs installed as native libraries so they are not needed + # in the zip. + if ($modelname !~ /android/) { + glob_install("$src/codecs/*", "$libdir/codecs", "-m 0755"); + } # plugins unless (glob_mkdir("$libdir/rocks")) { @@ -473,7 +477,11 @@ STOP glob_mkdir("$temp_dir/codecs"); - find(find_copyfile(qr/.*\.codec/, abs_path("$temp_dir/codecs/")), 'apps/codecs'); + # Android has codecs installed as native libraries so they are not needed + # in the zip. + 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");