Fixes bug 1696, thanks Paul Geerts!
authorGabriel Jacobo <gabomdq@gmail.com>
Mon, 14 Jan 2013 20:20:33 -0300
changeset 6816 b3d3ef1e15b5
parent 6815 5fefa916e039
child 6817 93103b719488
Fixes bug 1696, thanks Paul Geerts! Also adds a bit of information about asset loading on Android.
README.android
src/core/android/SDL_android.cpp
--- a/README.android	Mon Jan 14 08:14:53 2013 -0800
+++ b/README.android	Mon Jan 14 20:20:33 2013 -0300
@@ -138,6 +138,18 @@
 
 See SDL_system.h for more details on these functions.
 
+The asset packaging system will, by default, compress certain file extensions.
+SDL includes two asset file access mechanisms, the preferred one is the so
+called "File Descriptor" method, which is faster and doesn't involve the Dalvik
+GC, but given this method does not work on compressed assets, there is also the
+"Input Stream" method, which is automatically used as a fall back by SDL. You
+may want to keep this fact in mind when building your APK, specially when large
+files are involved.
+For more information on which extensions get compressed by default and how to
+disable this behaviour, see for example:
+    
+http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/
+
 ================================================================================
  Pause / Resume behaviour
 ================================================================================
--- a/src/core/android/SDL_android.cpp	Mon Jan 14 08:14:53 2013 -0800
+++ b/src/core/android/SDL_android.cpp	Mon Jan 14 20:20:33 2013 -0300
@@ -613,6 +613,9 @@
     descriptor = mEnv->GetFieldID(fdCls, "descriptor", "I");
     ctx->hidden.androidio.fd = mEnv->GetIntField(fd, descriptor);
 
+    // Seek to the correct offset in the file.
+    lseek(ctx->hidden.androidio.fd, (off_t)ctx->hidden.androidio.offset, SEEK_SET);
+
     if (false) {
 fallback:
         __android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file");