project_files/Android-build/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp
author Xeli
Tue, 24 Jan 2012 02:47:51 +0100
changeset 6592 cf12f07d6f24
parent 6328 d14adf1c7721
child 6597 814683bbd230
permissions -rw-r--r--
update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
     1
/*
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
     2
  Simple DirectMedia Layer
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
     4
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
     5
  This software is provided 'as-is', without any express or implied
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
     7
  arising from the use of this software.
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
     8
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    11
  freely, subject to the following restrictions:
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    12
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    14
     claim that you wrote the original software. If you use this software
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    16
     appreciated but is not required.
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    18
     misrepresented as being the original software.
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    20
*/
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    21
#include "SDL_config.h"
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    22
#include "SDL_stdinc.h"
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    23
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    24
#ifdef __ANDROID__
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    25
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    26
#include "SDL_android.h"
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    27
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    28
extern "C" {
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    29
#include "../../events/SDL_events_c.h"
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    30
#include "../../video/android/SDL_androidkeyboard.h"
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    31
#include "../../video/android/SDL_androidtouch.h"
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    32
#include "../../video/android/SDL_androidvideo.h"
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    33
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    34
#include <android/log.h>
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    35
#define LOG_TAG "SDL_android"
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    36
//#define LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    37
//#define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    38
#define LOGI(...) do {} while (false)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    39
#define LOGE(...) do {} while (false)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    40
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    41
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    42
/* Implemented in audio/android/SDL_androidaudio.c */
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    43
extern void Android_RunAudioThread();
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    44
} // C
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    45
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    46
/*******************************************************************************
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    47
 This file links the Java side of Android with libsdl
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    48
*******************************************************************************/
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    49
#include <jni.h>
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    50
#include <android/log.h>
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    51
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    52
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    53
/*******************************************************************************
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    54
                               Globals
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    55
*******************************************************************************/
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    56
static JNIEnv* mEnv = NULL;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    57
static JNIEnv* mAudioEnv = NULL;
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    58
static JavaVM* mJavaVM;
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    59
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    60
// Main activity
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    61
static jclass mActivityClass;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    62
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    63
// method signatures
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    64
static jmethodID midCreateGLContext;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    65
static jmethodID midFlipBuffers;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    66
static jmethodID midAudioInit;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    67
static jmethodID midAudioWriteShortBuffer;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    68
static jmethodID midAudioWriteByteBuffer;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    69
static jmethodID midAudioQuit;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    70
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    71
// Accelerometer data storage
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    72
static float fLastAccelerometer[3];
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    73
static bool bHasNewData;
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    74
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    75
/*******************************************************************************
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    76
                 Functions called by JNI
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    77
*******************************************************************************/
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    78
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    79
// Library init
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    80
extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    81
{
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    82
    JNIEnv *env;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    83
    mJavaVM = vm;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    84
    LOGI("JNI_OnLoad called");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    85
    if (mJavaVM->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    86
        LOGE("Failed to get the environment using GetEnv()");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    87
        return -1;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    88
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    89
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    90
    return JNI_VERSION_1_4;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    91
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    92
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    93
// Called before SDL_main() to initialize JNI bindings
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    94
extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    95
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    96
    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init()");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    97
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
    98
    mEnv = env;
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
    99
    mActivityClass = (jclass)env->NewGlobalRef(cls);
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   100
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   101
    midCreateGLContext = mEnv->GetStaticMethodID(mActivityClass,
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   102
                                "createGLContext","(II)Z");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   103
    midFlipBuffers = mEnv->GetStaticMethodID(mActivityClass,
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   104
                                "flipBuffers","()V");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   105
    midAudioInit = mEnv->GetStaticMethodID(mActivityClass, 
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   106
                                "audioInit", "(IZZI)Ljava/lang/Object;");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   107
    midAudioWriteShortBuffer = mEnv->GetStaticMethodID(mActivityClass,
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   108
                                "audioWriteShortBuffer", "([S)V");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   109
    midAudioWriteByteBuffer = mEnv->GetStaticMethodID(mActivityClass,
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   110
                                "audioWriteByteBuffer", "([B)V");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   111
    midAudioQuit = mEnv->GetStaticMethodID(mActivityClass,
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   112
                                "audioQuit", "()V");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   113
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   114
    bHasNewData = false;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   115
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   116
    if(!midCreateGLContext || !midFlipBuffers || !midAudioInit ||
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   117
       !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit) {
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   118
        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   119
    }
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   120
    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init() finished!");
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   121
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   122
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   123
// Resize
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents: 5540
diff changeset
   124
extern "C" void Java_org_hedgewars_hedgeroid_SDLActivity_onNativeResize(
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   125
                                    JNIEnv* env, jclass jcls,
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   126
                                    jint width, jint height, jint format)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   127
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   128
    Android_SetScreenResolution(width, height, format);
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   129
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   130
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   131
// Keydown
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents: 5540
diff changeset
   132
extern "C" void Java_org_hedgewars_hedgeroid_SDLActivity_onNativeKeyDown(
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   133
                                    JNIEnv* env, jclass jcls, jint keycode)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   134
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   135
    Android_OnKeyDown(keycode);
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   136
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   137
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   138
// Keyup
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents: 5540
diff changeset
   139
extern "C" void Java_org_hedgewars_hedgeroid_SDLActivity_onNativeKeyUp(
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   140
                                    JNIEnv* env, jclass jcls, jint keycode)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   141
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   142
    Android_OnKeyUp(keycode);
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   143
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   144
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   145
// Touch
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents: 5540
diff changeset
   146
extern "C" void Java_org_hedgewars_hedgeroid_SDLActivity_onNativeTouch(
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   147
                                    JNIEnv* env, jclass jcls,
6328
d14adf1c7721 merge...i think
Xeli
parents: 6047
diff changeset
   148
                                    jint touch_device_id_in, jint pointer_finger_id_in,
d14adf1c7721 merge...i think
Xeli
parents: 6047
diff changeset
   149
                                    jint action, jfloat x, jfloat y, jfloat p)
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   150
{
6328
d14adf1c7721 merge...i think
Xeli
parents: 6047
diff changeset
   151
    Android_OnTouch(touch_device_id_in, pointer_finger_id_in, action, x, y, p);
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   152
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   153
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   154
// Accelerometer
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents: 5540
diff changeset
   155
extern "C" void Java_org_hedgewars_hedgeroid_SDLActivity_onNativeAccel(
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   156
                                    JNIEnv* env, jclass jcls,
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   157
                                    jfloat x, jfloat y, jfloat z)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   158
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   159
    fLastAccelerometer[0] = x;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   160
    fLastAccelerometer[1] = y;
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   161
    fLastAccelerometer[2] = z;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   162
    bHasNewData = true;
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   163
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   164
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   165
// Quit
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents: 5540
diff changeset
   166
extern "C" void Java_org_hedgewars_hedgeroid_SDLActivity_nativeQuit(
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   167
                                    JNIEnv* env, jclass cls)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   168
{    
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   169
    // Inject a SDL_QUIT event
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   170
    SDL_SendQuit();
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   171
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   172
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   173
// Pause
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   174
extern "C" void Java_org_libsdl_app_SDLActivity_nativePause(
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   175
                                    JNIEnv* env, jclass cls)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   176
{
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   177
    if (Android_Window) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   178
        SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   179
        SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   180
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   181
}
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   182
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   183
// Resume
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   184
extern "C" void Java_org_libsdl_app_SDLActivity_nativeResume(
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   185
                                    JNIEnv* env, jclass cls)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   186
{
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   187
    if (Android_Window) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   188
        SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   189
        SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESTORED, 0, 0);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   190
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   191
}
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   192
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   193
extern "C" void Java_org_libsdl_app_SDLActivity_nativeRunAudioThread(
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   194
                                    JNIEnv* env, jclass cls)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   195
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   196
    /* This is the audio thread, with a different environment */
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   197
    mAudioEnv = env;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   198
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   199
    Android_RunAudioThread();
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   200
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   201
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   202
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   203
/*******************************************************************************
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   204
             Functions called by SDL into Java
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   205
*******************************************************************************/
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   206
extern "C" SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   207
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   208
    if (mEnv->CallStaticBooleanMethod(mActivityClass, midCreateGLContext, majorVersion, minorVersion)) {
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   209
        return SDL_TRUE;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   210
    } else {
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   211
        return SDL_FALSE;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   212
    }
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   213
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   214
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   215
extern "C" void Android_JNI_SwapWindow()
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   216
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   217
    mEnv->CallStaticVoidMethod(mActivityClass, midFlipBuffers); 
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   218
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   219
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   220
extern "C" void Android_JNI_SetActivityTitle(const char *title)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   221
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   222
    jmethodID mid;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   223
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   224
    mid = mEnv->GetStaticMethodID(mActivityClass,"setActivityTitle","(Ljava/lang/String;)V");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   225
    if (mid) {
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   226
        mEnv->CallStaticVoidMethod(mActivityClass, mid, mEnv->NewStringUTF(title));
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   227
    }
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   228
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   229
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   230
extern "C" SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   231
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   232
    int i;
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   233
    SDL_bool retval = SDL_FALSE;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   234
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   235
    if (bHasNewData) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   236
        for (i = 0; i < 3; ++i) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   237
            values[i] = fLastAccelerometer[i];
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   238
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   239
        bHasNewData = false;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   240
        retval = SDL_TRUE;
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   241
    }
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   242
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   243
    return retval;
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   244
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   245
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   246
//
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   247
// Audio support
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   248
//
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   249
static jboolean audioBuffer16Bit = JNI_FALSE;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   250
static jboolean audioBufferStereo = JNI_FALSE;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   251
static jobject audioBuffer = NULL;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   252
static void* audioBufferPinned = NULL;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   253
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   254
extern "C" int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames)
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   255
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   256
    int audioBufferFrames;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   257
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   258
    int status;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   259
    JNIEnv *env;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   260
    static bool isAttached = false;    
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   261
    status = mJavaVM->GetEnv((void **) &env, JNI_VERSION_1_4);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   262
    if(status < 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   263
        LOGE("callback_handler: failed to get JNI environment, assuming native thread");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   264
        status = mJavaVM->AttachCurrentThread(&env, NULL);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   265
        if(status < 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   266
            LOGE("callback_handler: failed to attach current thread");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   267
            return 0;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   268
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   269
        isAttached = true;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   270
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   271
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   272
    
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   273
    __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   274
    audioBuffer16Bit = is16Bit;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   275
    audioBufferStereo = channelCount > 1;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   276
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   277
    audioBuffer = env->CallStaticObjectMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames);
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   278
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   279
    if (audioBuffer == NULL) {
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   280
        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: didn't get back a good audio buffer!");
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   281
        return 0;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   282
    }
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   283
    audioBuffer = env->NewGlobalRef(audioBuffer);
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   284
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   285
    jboolean isCopy = JNI_FALSE;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   286
    if (audioBuffer16Bit) {
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   287
        audioBufferPinned = env->GetShortArrayElements((jshortArray)audioBuffer, &isCopy);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   288
        audioBufferFrames = env->GetArrayLength((jshortArray)audioBuffer);
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   289
    } else {
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   290
        audioBufferPinned = env->GetByteArrayElements((jbyteArray)audioBuffer, &isCopy);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   291
        audioBufferFrames = env->GetArrayLength((jbyteArray)audioBuffer);
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   292
    }
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   293
    if (audioBufferStereo) {
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   294
        audioBufferFrames /= 2;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   295
    }
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   296
 
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   297
    if (isAttached) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   298
        mJavaVM->DetachCurrentThread();
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   299
    }
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   300
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   301
    return audioBufferFrames;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   302
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   303
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   304
extern "C" void * Android_JNI_GetAudioBuffer()
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   305
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   306
    return audioBufferPinned;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   307
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   308
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   309
extern "C" void Android_JNI_WriteAudioBuffer()
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   310
{
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   311
    if (audioBuffer16Bit) {
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   312
        mAudioEnv->ReleaseShortArrayElements((jshortArray)audioBuffer, (jshort *)audioBufferPinned, JNI_COMMIT);
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   313
        mAudioEnv->CallStaticVoidMethod(mActivityClass, midAudioWriteShortBuffer, (jshortArray)audioBuffer);
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   314
    } else {
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   315
        mAudioEnv->ReleaseByteArrayElements((jbyteArray)audioBuffer, (jbyte *)audioBufferPinned, JNI_COMMIT);
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   316
        mAudioEnv->CallStaticVoidMethod(mActivityClass, midAudioWriteByteBuffer, (jbyteArray)audioBuffer);
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   317
    }
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   318
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   319
    /* JNI_COMMIT means the changes are committed to the VM but the buffer remains pinned */
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   320
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   321
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   322
extern "C" void Android_JNI_CloseAudioDevice()
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   323
{
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   324
    int status;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   325
    JNIEnv *env;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   326
    static bool isAttached = false;    
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   327
    status = mJavaVM->GetEnv((void **) &env, JNI_VERSION_1_4);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   328
    if(status < 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   329
        LOGE("callback_handler: failed to get JNI environment, assuming native thread");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   330
        status = mJavaVM->AttachCurrentThread(&env, NULL);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   331
        if(status < 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   332
            LOGE("callback_handler: failed to attach current thread");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   333
            return;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   334
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   335
        isAttached = true;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   336
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   337
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   338
    env->CallStaticVoidMethod(mActivityClass, midAudioQuit); 
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   339
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   340
    if (audioBuffer) {
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   341
        env->DeleteGlobalRef(audioBuffer);
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   342
        audioBuffer = NULL;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   343
        audioBufferPinned = NULL;
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   344
    }
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   345
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   346
    if (isAttached) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   347
        mJavaVM->DetachCurrentThread();
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   348
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   349
}
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   350
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   351
// Test for an exception and call SDL_SetError with its detail if one occurs
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   352
static bool Android_JNI_ExceptionOccurred()
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   353
{
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   354
    jthrowable exception = mEnv->ExceptionOccurred();
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   355
    if (exception != NULL) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   356
        jmethodID mid;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   357
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   358
        // Until this happens most JNI operations have undefined behaviour
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   359
        mEnv->ExceptionClear();
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   360
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   361
        jclass exceptionClass = mEnv->GetObjectClass(exception);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   362
        jclass classClass = mEnv->FindClass("java/lang/Class");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   363
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   364
        mid = mEnv->GetMethodID(classClass, "getName", "()Ljava/lang/String;");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   365
        jstring exceptionName = (jstring)mEnv->CallObjectMethod(exceptionClass, mid);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   366
        const char* exceptionNameUTF8 = mEnv->GetStringUTFChars(exceptionName, 0);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   367
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   368
        mid = mEnv->GetMethodID(exceptionClass, "getMessage", "()Ljava/lang/String;");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   369
        jstring exceptionMessage = (jstring)mEnv->CallObjectMethod(exception, mid);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   370
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   371
        if (exceptionMessage != NULL) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   372
            const char* exceptionMessageUTF8 = mEnv->GetStringUTFChars(
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   373
                    exceptionMessage, 0);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   374
            SDL_SetError("%s: %s", exceptionNameUTF8, exceptionMessageUTF8);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   375
            mEnv->ReleaseStringUTFChars(exceptionMessage, exceptionMessageUTF8);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   376
            mEnv->DeleteLocalRef(exceptionMessage);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   377
        } else {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   378
            SDL_SetError("%s", exceptionNameUTF8);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   379
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   380
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   381
        mEnv->ReleaseStringUTFChars(exceptionName, exceptionNameUTF8);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   382
        mEnv->DeleteLocalRef(exceptionName);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   383
        mEnv->DeleteLocalRef(classClass);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   384
        mEnv->DeleteLocalRef(exceptionClass);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   385
        mEnv->DeleteLocalRef(exception);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   386
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   387
        return true;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   388
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   389
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   390
    return false;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   391
}
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   392
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   393
static int Android_JNI_FileOpen(SDL_RWops* ctx)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   394
{
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   395
    int result = 0;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   396
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   397
    jmethodID mid;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   398
    jobject context;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   399
    jobject assetManager;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   400
    jobject inputStream;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   401
    jclass channels;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   402
    jobject readableByteChannel;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   403
    jstring fileNameJString;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   404
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   405
    bool allocatedLocalFrame = false;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   406
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   407
    if (mEnv->PushLocalFrame(16) < 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   408
        SDL_SetError("Failed to allocate enough JVM local references");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   409
        goto failure;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   410
    } else {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   411
        allocatedLocalFrame = true;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   412
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   413
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   414
    fileNameJString = (jstring)ctx->hidden.androidio.fileName;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   415
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   416
    // context = SDLActivity.getContext();
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   417
    mid = mEnv->GetStaticMethodID(mActivityClass,
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   418
            "getContext","()Landroid/content/Context;");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   419
    context = mEnv->CallStaticObjectMethod(mActivityClass, mid);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   420
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   421
    // assetManager = context.getAssets();
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   422
    mid = mEnv->GetMethodID(mEnv->GetObjectClass(context),
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   423
            "getAssets", "()Landroid/content/res/AssetManager;");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   424
    assetManager = mEnv->CallObjectMethod(context, mid);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   425
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   426
    // inputStream = assetManager.open(<filename>);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   427
    mid = mEnv->GetMethodID(mEnv->GetObjectClass(assetManager),
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   428
            "open", "(Ljava/lang/String;)Ljava/io/InputStream;");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   429
    inputStream = mEnv->CallObjectMethod(assetManager, mid, fileNameJString);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   430
    if (Android_JNI_ExceptionOccurred()) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   431
        goto failure;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   432
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   433
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   434
    ctx->hidden.androidio.inputStream = inputStream;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   435
    ctx->hidden.androidio.inputStreamRef = mEnv->NewGlobalRef(inputStream);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   436
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   437
    // Despite all the visible documentation on [Asset]InputStream claiming
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   438
    // that the .available() method is not guaranteed to return the entire file
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   439
    // size, comments in <sdk>/samples/<ver>/ApiDemos/src/com/example/ ...
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   440
    // android/apis/content/ReadAsset.java imply that Android's
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   441
    // AssetInputStream.available() /will/ always return the total file size
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   442
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   443
    // size = inputStream.available();
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   444
    mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream),
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   445
            "available", "()I");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   446
    ctx->hidden.androidio.size = mEnv->CallIntMethod(inputStream, mid);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   447
    if (Android_JNI_ExceptionOccurred()) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   448
        goto failure;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   449
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   450
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   451
    // readableByteChannel = Channels.newChannel(inputStream);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   452
    channels = mEnv->FindClass("java/nio/channels/Channels");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   453
    mid = mEnv->GetStaticMethodID(channels,
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   454
            "newChannel",
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   455
            "(Ljava/io/InputStream;)Ljava/nio/channels/ReadableByteChannel;");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   456
    readableByteChannel = mEnv->CallStaticObjectMethod(
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   457
            channels, mid, inputStream);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   458
    if (Android_JNI_ExceptionOccurred()) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   459
        goto failure;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   460
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   461
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   462
    ctx->hidden.androidio.readableByteChannel = readableByteChannel;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   463
    ctx->hidden.androidio.readableByteChannelRef =
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   464
        mEnv->NewGlobalRef(readableByteChannel);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   465
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   466
    // Store .read id for reading purposes
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   467
    mid = mEnv->GetMethodID(mEnv->GetObjectClass(readableByteChannel),
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   468
            "read", "(Ljava/nio/ByteBuffer;)I");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   469
    ctx->hidden.androidio.readMethod = mid;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   470
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   471
    ctx->hidden.androidio.position = 0;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   472
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   473
    if (false) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   474
failure:
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   475
        result = -1;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   476
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   477
        mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.fileNameRef);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   478
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   479
        if(ctx->hidden.androidio.inputStreamRef != NULL) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   480
            mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.inputStreamRef);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   481
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   482
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   483
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   484
    if (allocatedLocalFrame) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   485
        mEnv->PopLocalFrame(NULL);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   486
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   487
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   488
    return result;
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   489
}
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   490
6592
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   491
extern "C" int Android_JNI_FileOpen(SDL_RWops* ctx,
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   492
        const char* fileName, const char*)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   493
{
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   494
    if (!ctx) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   495
        return -1;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   496
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   497
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   498
    jstring fileNameJString = mEnv->NewStringUTF(fileName);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   499
    ctx->hidden.androidio.fileName = fileNameJString;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   500
    ctx->hidden.androidio.fileNameRef = mEnv->NewGlobalRef(fileNameJString);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   501
    ctx->hidden.androidio.inputStreamRef = NULL;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   502
    mEnv->DeleteLocalRef(fileNameJString);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   503
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   504
    return Android_JNI_FileOpen(ctx);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   505
}
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   506
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   507
extern "C" size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer,
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   508
        size_t size, size_t maxnum)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   509
{
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   510
    int bytesRemaining = size * maxnum;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   511
    int bytesRead = 0;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   512
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   513
    jobject readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannel;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   514
    jmethodID readMethod = (jmethodID)ctx->hidden.androidio.readMethod;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   515
    jobject byteBuffer = mEnv->NewDirectByteBuffer(buffer, bytesRemaining);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   516
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   517
    while (bytesRemaining > 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   518
        // result = readableByteChannel.read(...);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   519
        int result = mEnv->CallIntMethod(readableByteChannel, readMethod, byteBuffer);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   520
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   521
        if (Android_JNI_ExceptionOccurred()) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   522
            mEnv->DeleteLocalRef(byteBuffer);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   523
            return 0;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   524
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   525
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   526
        if (result < 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   527
            break;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   528
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   529
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   530
        bytesRemaining -= result;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   531
        bytesRead += result;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   532
        ctx->hidden.androidio.position += result;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   533
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   534
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   535
    mEnv->DeleteLocalRef(byteBuffer);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   536
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   537
    return bytesRead / size;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   538
}
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   539
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   540
extern "C" size_t Android_JNI_FileWrite(SDL_RWops* ctx, const void* buffer,
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   541
        size_t size, size_t num)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   542
{
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   543
    SDL_SetError("Cannot write to Android package filesystem");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   544
    return 0;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   545
}
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   546
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   547
static int Android_JNI_FileClose(SDL_RWops* ctx, bool release)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   548
{
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   549
    int result = 0;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   550
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   551
    if (ctx) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   552
        if (release) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   553
            mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.fileNameRef);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   554
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   555
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   556
        jobject inputStream = (jobject)ctx->hidden.androidio.inputStream;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   557
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   558
        // inputStream.close();
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   559
        jmethodID mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream),
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   560
                "close", "()V");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   561
        mEnv->CallVoidMethod(inputStream, mid);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   562
        mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.inputStreamRef);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   563
        mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.readableByteChannelRef);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   564
        if (Android_JNI_ExceptionOccurred()) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   565
            result = -1;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   566
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   567
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   568
        if (release) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   569
            SDL_FreeRW(ctx);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   570
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   571
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   572
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   573
    return result;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   574
}
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   575
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   576
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   577
extern "C" long Android_JNI_FileSeek(SDL_RWops* ctx, long offset, int whence)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   578
{
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   579
    long newPosition;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   580
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   581
    switch (whence) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   582
        case RW_SEEK_SET:
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   583
            newPosition = offset;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   584
            break;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   585
        case RW_SEEK_CUR:
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   586
            newPosition = ctx->hidden.androidio.position + offset;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   587
            break;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   588
        case RW_SEEK_END:
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   589
            newPosition = ctx->hidden.androidio.size + offset;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   590
            break;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   591
        default:
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   592
            SDL_SetError("Unknown value for 'whence'");
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   593
            return -1;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   594
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   595
    if (newPosition < 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   596
        newPosition = 0;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   597
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   598
    if (newPosition > ctx->hidden.androidio.size) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   599
        newPosition = ctx->hidden.androidio.size;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   600
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   601
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   602
    long movement = newPosition - ctx->hidden.androidio.position;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   603
    jobject inputStream = (jobject)ctx->hidden.androidio.inputStream;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   604
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   605
    if (movement > 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   606
        unsigned char buffer[1024];
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   607
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   608
        // The easy case where we're seeking forwards
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   609
        while (movement > 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   610
            long amount = (long) sizeof (buffer);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   611
            if (amount > movement) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   612
                amount = movement;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   613
            }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   614
            size_t result = Android_JNI_FileRead(ctx, buffer, 1, amount);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   615
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   616
            if (result <= 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   617
                // Failed to read/skip the required amount, so fail
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   618
                return -1;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   619
            }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   620
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   621
            movement -= result;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   622
        }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   623
    } else if (movement < 0) {
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   624
        // We can't seek backwards so we have to reopen the file and seek
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   625
        // forwards which obviously isn't very efficient
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   626
        Android_JNI_FileClose(ctx, false);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   627
        Android_JNI_FileOpen(ctx);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   628
        Android_JNI_FileSeek(ctx, newPosition, RW_SEEK_SET);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   629
    }
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   630
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   631
    ctx->hidden.androidio.position = newPosition;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   632
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   633
    return ctx->hidden.androidio.position;
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   634
}
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   635
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   636
extern "C" int Android_JNI_FileClose(SDL_RWops* ctx)
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   637
{
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   638
    return Android_JNI_FileClose(ctx, true);
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   639
}
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   640
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   641
#endif /* __ANDROID__ */
cf12f07d6f24 update the core/android/SDL_android.cpp fix some includes in Android.mks, use a different host to download some libs, sdl doesn't have up to date tarballs..
Xeli
parents: 6328
diff changeset
   642
5337
16477d1c12b1 Package name changes
Xeli
parents:
diff changeset
   643
/* vi: set ts=4 sw=4 expandtab: */