src/SDL_android.cpp
author Sam Lantinga <slouken@libsdl.org>
Thu, 13 Jan 2011 11:14:20 -0800
changeset 4995 9f9bea41e88f
parent 4989 58b6bb4a45e9
child 4996 8d7315668e35
permissions -rw-r--r--
Working audio implementation contributed by Joseph Lunderville
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
    Copyright (C) 1997-2010 Sam Lantinga
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
*/
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
#include "SDL_config.h"
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
4989
58b6bb4a45e9 More Android cleanup:
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
    24
#include "SDL_android.h"
58b6bb4a45e9 More Android cleanup:
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
    25
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents: 4964
diff changeset
    26
extern "C" {
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents: 4964
diff changeset
    27
#include "events/SDL_events_c.h"
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents: 4964
diff changeset
    28
#include "video/android/SDL_androidkeyboard.h"
4981
55b82067815b Fill in the video mode with the correct screen format
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
    29
#include "video/android/SDL_androidvideo.h"
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    30
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    31
/* Impelemented in audio/android/SDL_androidaudio.c */
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    32
extern void Android_RunAudioThread();
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    33
} // C
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents: 4964
diff changeset
    34
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
/*******************************************************************************
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
 This file links the Java side of Android with libsdl
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
*******************************************************************************/
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
#include <jni.h>
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
#include <android/log.h>
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
/*******************************************************************************
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
                               Globals
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
*******************************************************************************/
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    45
static JavaVM* mVM = NULL;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    46
static JNIEnv* mEnv = NULL;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    47
static JNIEnv* mAudioEnv = NULL;
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    49
// Main activity
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    50
static jclass mActivityInstance;
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    52
// method signatures
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    53
static jmethodID midCreateGLContext;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    54
static jmethodID midFlipBuffers;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    55
static jmethodID midAudioInit;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    56
static jmethodID midAudioWriteShortBuffer;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    57
static jmethodID midAudioWriteByteBuffer;
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    59
// Accelerometer data storage
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
float fLastAccelerometer[3];
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
/*******************************************************************************
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
                 Functions called by JNI
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
*******************************************************************************/
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
// Library init
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
{
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
    mVM = vm;
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
    return JNI_VERSION_1_4;
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
}
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
// Called before SDL_main() to initialize JNI bindings
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
extern "C" void SDL_Android_Init(JNIEnv* env)
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
{
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
    mEnv = env;
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init()");
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
    jclass cls = mEnv->FindClass ("org/libsdl/app/SDLActivity"); 
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
    mActivityInstance = cls;
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
    midCreateGLContext = mEnv->GetStaticMethodID(cls,"createGLContext","()V");
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
    midFlipBuffers = mEnv->GetStaticMethodID(cls,"flipBuffers","()V");
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    86
	midAudioInit = mEnv->GetStaticMethodID(cls, "audioInit", "(IZZI)Ljava/lang/Object;");
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    87
	midAudioWriteShortBuffer = mEnv->GetStaticMethodID(cls, "audioWriteShortBuffer", "([S)V");
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    88
	midAudioWriteByteBuffer = mEnv->GetStaticMethodID(cls, "audioWriteByteBuffer", "([B)V");
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    90
    if(!midCreateGLContext || !midFlipBuffers || !midAudioInit ||
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    91
       !midAudioWriteShortBuffer || !midAudioWriteByteBuffer) {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    92
		__android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly");
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
    }
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
}
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    96
// Resize
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    97
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeResize(
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    98
                                    JNIEnv* env, jobject obj,
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
    99
                                    jint width, jint height, jint format)
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
{
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   101
    Android_SetScreenResolution(width, height, format);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   102
}
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   103
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   104
// Keydown
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   105
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyDown(
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   106
                                    JNIEnv* env, jobject obj, jint keycode)
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   107
{
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents: 4964
diff changeset
   108
    Android_OnKeyDown(keycode);
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
}
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
// Keyup
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   112
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyUp(
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   113
                                    JNIEnv* env, jobject obj, jint keycode)
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
{
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents: 4964
diff changeset
   115
    Android_OnKeyUp(keycode);
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
}
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
// Touch
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   119
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeTouch(
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   120
                                    JNIEnv* env, jobject obj,
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   121
                                    jint action, jfloat x, jfloat y, jfloat p)
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
{
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
#ifdef DEBUG
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
    __android_log_print(ANDROID_LOG_INFO, "SDL", 
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
                        "SDL: native touch event %d @ %f/%f, pressure %f\n", 
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
                        action, x, y, p);
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
#endif
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
    //TODO: Pass this off to the SDL multitouch stuff
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
}
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   132
// Accelerometer
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
extern "C" void Java_org_libsdl_app_SDLActivity_onNativeAccel(
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   134
                                    JNIEnv* env, jobject obj,
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   135
                                    jfloat x, jfloat y, jfloat z)
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
{
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
    fLastAccelerometer[0] = x;
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
    fLastAccelerometer[1] = y;
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
    fLastAccelerometer[2] = z;   
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
}
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   142
// Quit
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   143
extern "C" void Java_org_libsdl_app_SDLActivity_nativeQuit(
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   144
                                    JNIEnv* env, jobject obj)
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   145
{    
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   146
    // Inject a SDL_QUIT event
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   147
    SDL_SendQuit();
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   148
}
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   149
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   150
extern "C" void Java_org_libsdl_app_SDLActivity_nativeRunAudioThread(
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   151
                                    JNIEnv* env)
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   152
{
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   153
	mVM->AttachCurrentThread(&mAudioEnv, NULL);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   154
	Android_RunAudioThread();
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   155
}
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
/*******************************************************************************
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
             Functions called by SDL into Java
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
*******************************************************************************/
4989
58b6bb4a45e9 More Android cleanup:
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   161
extern "C" void Android_JNI_CreateContext()
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
{
4989
58b6bb4a45e9 More Android cleanup:
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   163
    mEnv->CallStaticVoidMethod(mActivityInstance, midCreateGLContext); 
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
}
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
4989
58b6bb4a45e9 More Android cleanup:
Sam Lantinga <slouken@libsdl.org>
parents: 4981
diff changeset
   166
extern "C" void Android_JNI_SwapWindow()
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
{
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
    mEnv->CallStaticVoidMethod(mActivityInstance, midFlipBuffers); 
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
}
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   171
//
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   172
// Audio support
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   173
//
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   174
static jint audioBufferFrames = 0;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   175
static bool audioBuffer16Bit = false;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   176
static bool audioBufferStereo = false;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   177
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   178
static jobject audioBuffer;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   179
static void * audioPinnedBuffer;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   180
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   181
extern "C" int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames)
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   182
{
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   183
	__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   184
	audioBuffer16Bit = is16Bit;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   185
	audioBufferStereo = channelCount > 1;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   186
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   187
	audioBuffer = mEnv->CallStaticObjectMethod(mActivityInstance, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   188
	audioBuffer = mEnv->NewGlobalRef(audioBuffer);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   189
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   190
	if (audioBuffer == NULL) {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   191
		__android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: didn't get back a good audio buffer!");
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   192
		return 0;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   193
	}
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   194
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   195
	if (audioBufferStereo) {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   196
		audioBufferFrames = mEnv->GetArrayLength((jshortArray)audioBuffer) / 2;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   197
	} else {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   198
		audioBufferFrames = mEnv->GetArrayLength((jbyteArray)audioBuffer);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   199
	}
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   200
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   201
	return audioBufferFrames;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   202
}
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   203
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   204
extern "C" void * Android_JNI_PinAudioBuffer()
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
{
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   206
	jboolean isCopy = JNI_FALSE;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   207
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   208
	if (audioPinnedBuffer != NULL) {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   209
		return audioPinnedBuffer;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   210
	}
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   211
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   212
	if (audioBuffer16Bit) {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   213
		audioPinnedBuffer = mAudioEnv->GetShortArrayElements((jshortArray)audioBuffer, &isCopy);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   214
	} else {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   215
		audioPinnedBuffer = mAudioEnv->GetByteArrayElements((jbyteArray)audioBuffer, &isCopy);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   216
	}
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   217
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   218
	return audioPinnedBuffer;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   219
}
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   221
extern "C" void Android_JNI_WriteAudioBufferAndUnpin()
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   222
{
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   223
	if (audioPinnedBuffer == NULL) {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   224
		return;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   225
	}
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   227
	if (audioBuffer16Bit) {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   228
		mAudioEnv->ReleaseShortArrayElements((jshortArray)audioBuffer, (jshort *)audioPinnedBuffer, JNI_COMMIT);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   229
		mAudioEnv->CallStaticVoidMethod(mActivityInstance, midAudioWriteShortBuffer, (jshortArray)audioBuffer);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   230
	} else {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   231
		mAudioEnv->ReleaseByteArrayElements((jbyteArray)audioBuffer, (jbyte *)audioPinnedBuffer, JNI_COMMIT);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   232
		mAudioEnv->CallStaticVoidMethod(mActivityInstance, midAudioWriteByteBuffer, (jbyteArray)audioBuffer);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   233
	}
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   234
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   235
	audioPinnedBuffer = NULL;
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   236
}
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   237
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   238
extern "C" void Android_JNI_CloseAudioDevice()
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   239
{
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   240
    if (audioBuffer) {
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   241
        mEnv->DeleteGlobalRef(audioBuffer);
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   242
        audioBuffer = NULL;
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
    }
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
4995
9f9bea41e88f Working audio implementation contributed by Joseph Lunderville
Sam Lantinga <slouken@libsdl.org>
parents: 4989
diff changeset
   245
	// TODO: Implement
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
}
4981
55b82067815b Fill in the video mode with the correct screen format
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
   247
55b82067815b Fill in the video mode with the correct screen format
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
   248
/* vi: set ts=4 sw=4 expandtab: */