Răsfoiți Sursa

Applied SDL Android RWops patch.

Lasse Öörni 13 ani în urmă
părinte
comite
2c54f016c8

+ 0 - 1
Docs/GettingStarted.dox

@@ -59,7 +59,6 @@ By default the Android package for Urho3D is com.googlecode.urho3d. For a real a
 - ThirdParty/SDL/include/SDL_config_android.h, look for the NATIVE_FUNCTION macro
 - ThirdParty/SDL/include/SDL_config_android.h, look for the NATIVE_FUNCTION macro
 
 
 
 
-
 \page Running Running Urho3D
 \page Running Running Urho3D
 
 
 The main executable Urho3D.exe in the Bin directory contains all the engine runtime functionality. However, it does not contain any inbuilt logic or application, and therefore must be supplied with the name of the application script file it should run:
 The main executable Urho3D.exe in the Bin directory contains all the engine runtime functionality. However, it does not contain any inbuilt logic or application, and therefore must be supplied with the name of the application script file it should run:

+ 0 - 3
ThirdParty/SDL/include/SDL_rwops.h

@@ -85,11 +85,8 @@ typedef struct SDL_RWops
 #if defined(ANDROID)
 #if defined(ANDROID)
         struct
         struct
         {
         {
-            void *fileName;
             void *fileNameRef;
             void *fileNameRef;
-            void *inputStream;
             void *inputStreamRef;
             void *inputStreamRef;
-            void *readableByteChannel;
             void *readableByteChannelRef;
             void *readableByteChannelRef;
             void *readMethod;
             void *readMethod;
             long position;
             long position;

+ 9 - 7
ThirdParty/SDL/src/core/android/SDL_android.cpp

@@ -505,7 +505,7 @@ static int Android_JNI_FileOpen(SDL_RWops* ctx)
         goto failure;
         goto failure;
     }
     }
 
 
-    fileNameJString = (jstring)ctx->hidden.androidio.fileName;
+    fileNameJString = (jstring)ctx->hidden.androidio.fileNameRef;
 
 
     // context = SDLActivity.getContext();
     // context = SDLActivity.getContext();
     mid = mEnv->GetStaticMethodID(mActivityClass,
     mid = mEnv->GetStaticMethodID(mActivityClass,
@@ -525,7 +525,6 @@ static int Android_JNI_FileOpen(SDL_RWops* ctx)
         goto failure;
         goto failure;
     }
     }
 
 
-    ctx->hidden.androidio.inputStream = inputStream;
     ctx->hidden.androidio.inputStreamRef = mEnv->NewGlobalRef(inputStream);
     ctx->hidden.androidio.inputStreamRef = mEnv->NewGlobalRef(inputStream);
 
 
     // Despite all the visible documentation on [Asset]InputStream claiming
     // Despite all the visible documentation on [Asset]InputStream claiming
@@ -553,7 +552,6 @@ static int Android_JNI_FileOpen(SDL_RWops* ctx)
         goto failure;
         goto failure;
     }
     }
 
 
-    ctx->hidden.androidio.readableByteChannel = readableByteChannel;
     ctx->hidden.androidio.readableByteChannelRef =
     ctx->hidden.androidio.readableByteChannelRef =
         mEnv->NewGlobalRef(readableByteChannel);
         mEnv->NewGlobalRef(readableByteChannel);
 
 
@@ -573,6 +571,11 @@ failure:
         if(ctx->hidden.androidio.inputStreamRef != NULL) {
         if(ctx->hidden.androidio.inputStreamRef != NULL) {
             mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.inputStreamRef);
             mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.inputStreamRef);
         }
         }
+
+        if(ctx->hidden.androidio.readableByteChannelRef != NULL) {
+            mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.readableByteChannelRef);
+        }
+
     }
     }
 
 
     return result;
     return result;
@@ -592,7 +595,6 @@ extern "C" int Android_JNI_FileOpen(SDL_RWops* ctx,
     }
     }
 
 
     jstring fileNameJString = mEnv->NewStringUTF(fileName);
     jstring fileNameJString = mEnv->NewStringUTF(fileName);
-    ctx->hidden.androidio.fileName = fileNameJString;
     ctx->hidden.androidio.fileNameRef = mEnv->NewGlobalRef(fileNameJString);
     ctx->hidden.androidio.fileNameRef = mEnv->NewGlobalRef(fileNameJString);
     ctx->hidden.androidio.inputStreamRef = NULL;
     ctx->hidden.androidio.inputStreamRef = NULL;
 
 
@@ -610,7 +612,7 @@ extern "C" size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer,
         return -1;
         return -1;
     }
     }
 
 
-    jobject readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannel;
+    jobject readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannelRef;
     jmethodID readMethod = (jmethodID)ctx->hidden.androidio.readMethod;
     jmethodID readMethod = (jmethodID)ctx->hidden.androidio.readMethod;
     jobject byteBuffer = mEnv->NewDirectByteBuffer(buffer, bytesRemaining);
     jobject byteBuffer = mEnv->NewDirectByteBuffer(buffer, bytesRemaining);
 
 
@@ -656,7 +658,7 @@ static int Android_JNI_FileClose(SDL_RWops* ctx, bool release)
             mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.fileNameRef);
             mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.fileNameRef);
         }
         }
 
 
-        jobject inputStream = (jobject)ctx->hidden.androidio.inputStream;
+        jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef;
 
 
         // inputStream.close();
         // inputStream.close();
         jmethodID mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream),
         jmethodID mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream),
@@ -703,7 +705,7 @@ extern "C" long Android_JNI_FileSeek(SDL_RWops* ctx, long offset, int whence)
     }
     }
 
 
     long movement = newPosition - ctx->hidden.androidio.position;
     long movement = newPosition - ctx->hidden.androidio.position;
-    jobject inputStream = (jobject)ctx->hidden.androidio.inputStream;
+    jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef;
 
 
     if (movement > 0) {
     if (movement > 0) {
         unsigned char buffer[1024];
         unsigned char buffer[1024];