* Unified all renderers into common class 'ALAudioRenderer' * LWJGL and Android now implement the AL / ALC / EFX interfaces to provide a common OpenAL backend for jME * Added support for OpenAL Soft "Pause Device" extension, which allows the engine to pause the context while running in the background (currently requires OpenAL soft 1.16 and thus is Android only feature)experimental
parent
e3c0b0ae38
commit
91715c4a48
@ -0,0 +1,134 @@ |
||||
#include "com_jme3_audio_android_AndroidAL.h" |
||||
#include "AL/al.h" |
||||
#include "AL/alext.h" |
||||
|
||||
JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidAL_alGetString |
||||
(JNIEnv* env, jobject obj, jint param) |
||||
{ |
||||
return (*env)->NewStringUTF(env, alGetString(param)); |
||||
} |
||||
|
||||
JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGenSources |
||||
(JNIEnv *env, jobject obj) |
||||
{ |
||||
ALuint source; |
||||
alGenSources(1, &source); |
||||
return source; |
||||
} |
||||
|
||||
JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGetError |
||||
(JNIEnv *env, jobject obj) |
||||
{ |
||||
return alGetError(); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alDeleteSources |
||||
(JNIEnv* env, jobject obj, jint numSources, jobject intbufSources) |
||||
{ |
||||
ALuint* pIntBufSources = (ALuint*) (*env)->GetDirectBufferAddress(env, intbufSources); |
||||
alDeleteSources((ALsizei)numSources, pIntBufSources); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alGenBuffers |
||||
(JNIEnv* env, jobject obj, jint numBuffers, jobject intbufBuffers) |
||||
{ |
||||
ALuint* pIntBufBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, intbufBuffers); |
||||
alGenBuffers((ALsizei)numBuffers, pIntBufBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alDeleteBuffers |
||||
(JNIEnv* env, jobject obj, jint numBuffers, jobject intbufBuffers) |
||||
{ |
||||
ALuint* pIntBufBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, intbufBuffers); |
||||
alDeleteBuffers((ALsizei)numBuffers, pIntBufBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceStop |
||||
(JNIEnv *env, jobject obj, jint source) |
||||
{ |
||||
alSourceStop((ALuint)source); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcei |
||||
(JNIEnv *env, jobject obj, jint source, jint param, jint value) |
||||
{ |
||||
alSourcei((ALuint)source, (ALenum)param, (ALint)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alBufferData |
||||
(JNIEnv* env, jobject obj, jint buffer, jint format, jobject bufferData, jint bufferSize, jint frequency) |
||||
{ |
||||
ALuint* pBufferData = (ALuint*) (*env)->GetDirectBufferAddress(env, bufferData); |
||||
alBufferData((ALuint)buffer, (ALenum)format, pBufferData, (ALsizei)bufferSize, (ALsizei)frequency); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcePlay |
||||
(JNIEnv *env, jobject obj, jint source) |
||||
{ |
||||
alSourcePlay((ALuint)source); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcePause |
||||
(JNIEnv *env, jobject obj, jint source) |
||||
{ |
||||
alSourcePause((ALuint)source); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcef |
||||
(JNIEnv *env, jobject obj, jint source, jint param, jfloat value) |
||||
{ |
||||
alSourcef((ALuint)source, (ALenum)param, (ALfloat)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSource3f |
||||
(JNIEnv *env, jobject obj, jint source, jint param, jfloat value1, jfloat value2, jfloat value3) |
||||
{ |
||||
alSource3f((ALuint)source, (ALenum)param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3); |
||||
} |
||||
|
||||
JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGetSourcei |
||||
(JNIEnv *env, jobject obj, jint source, jint param) |
||||
{ |
||||
ALint result; |
||||
alGetSourcei((ALuint)source, (ALenum)param, &result); |
||||
return (jint)result; |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceUnqueueBuffers |
||||
(JNIEnv* env, jobject obj, jint source, jint numBuffers, jobject buffers) |
||||
{ |
||||
ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffers); |
||||
alSourceUnqueueBuffers((ALuint)source, (ALsizei)numBuffers, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceQueueBuffers |
||||
(JNIEnv* env, jobject obj, jint source, jint numBuffers, jobject buffers) |
||||
{ |
||||
ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffers); |
||||
alSourceQueueBuffers((ALuint)source, (ALsizei)numBuffers, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListener |
||||
(JNIEnv* env, jobject obj, jint param, jobject bufferData) |
||||
{ |
||||
ALfloat* pBufferData = (ALfloat*) (*env)->GetDirectBufferAddress(env, bufferData); |
||||
alListenerfv((ALenum)param, pBufferData); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListenerf |
||||
(JNIEnv *env, jobject obj, jint param, jfloat value) |
||||
{ |
||||
alListenerf((ALenum)param, (ALfloat)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListener3f |
||||
(JNIEnv *env, jobject obj, jint param, jfloat value1, jfloat value2, jfloat value3) |
||||
{ |
||||
alListener3f((ALenum)param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSource3i |
||||
(JNIEnv *env, jobject obj, jint source, jint param, jint value1, jint value2, jint value3) |
||||
{ |
||||
alSource3i((ALuint)source, (ALenum)param, (ALint)value1, (ALint)value2, (ALint)value3); |
||||
} |
@ -0,0 +1,173 @@ |
||||
/* DO NOT EDIT THIS FILE - it is machine generated */ |
||||
#include <jni.h> |
||||
/* Header for class com_jme3_audio_android_AndroidAL */ |
||||
|
||||
#ifndef _Included_com_jme3_audio_android_AndroidAL |
||||
#define _Included_com_jme3_audio_android_AndroidAL |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alGetString |
||||
* Signature: (I)Ljava/lang/String; |
||||
*/ |
||||
JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidAL_alGetString |
||||
(JNIEnv *, jobject, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alGenSources |
||||
* Signature: ()I |
||||
*/ |
||||
JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGenSources |
||||
(JNIEnv *, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alGetError |
||||
* Signature: ()I |
||||
*/ |
||||
JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGetError |
||||
(JNIEnv *, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alDeleteSources |
||||
* Signature: (ILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alDeleteSources |
||||
(JNIEnv *, jobject, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alGenBuffers |
||||
* Signature: (ILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alGenBuffers |
||||
(JNIEnv *, jobject, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alDeleteBuffers |
||||
* Signature: (ILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alDeleteBuffers |
||||
(JNIEnv *, jobject, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alSourceStop |
||||
* Signature: (I)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceStop |
||||
(JNIEnv *, jobject, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alSourcei |
||||
* Signature: (III)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcei |
||||
(JNIEnv *, jobject, jint, jint, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alBufferData |
||||
* Signature: (IILjava/nio/ByteBuffer;II)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alBufferData |
||||
(JNIEnv *, jobject, jint, jint, jobject, jint, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alSourcePlay |
||||
* Signature: (I)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcePlay |
||||
(JNIEnv *, jobject, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alSourcePause |
||||
* Signature: (I)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcePause |
||||
(JNIEnv *, jobject, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alSourcef |
||||
* Signature: (IIF)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcef |
||||
(JNIEnv *, jobject, jint, jint, jfloat); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alSource3f |
||||
* Signature: (IIFFF)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSource3f |
||||
(JNIEnv *, jobject, jint, jint, jfloat, jfloat, jfloat); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alGetSourcei |
||||
* Signature: (II)I |
||||
*/ |
||||
JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGetSourcei |
||||
(JNIEnv *, jobject, jint, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alSourceUnqueueBuffers |
||||
* Signature: (IILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceUnqueueBuffers |
||||
(JNIEnv *, jobject, jint, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alSourceQueueBuffers |
||||
* Signature: (IILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceQueueBuffers |
||||
(JNIEnv *, jobject, jint, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alListener |
||||
* Signature: (ILjava/nio/FloatBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListener |
||||
(JNIEnv *, jobject, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alListenerf |
||||
* Signature: (IF)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListenerf |
||||
(JNIEnv *, jobject, jint, jfloat); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alListener3f |
||||
* Signature: (IFFF)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListener3f |
||||
(JNIEnv *, jobject, jint, jfloat, jfloat, jfloat); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidAL |
||||
* Method: alSource3i |
||||
* Signature: (IIIII)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSource3i |
||||
(JNIEnv *, jobject, jint, jint, jint, jint, jint); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,174 @@ |
||||
#include "util.h" |
||||
#include "com_jme3_audio_android_AndroidALC.h" |
||||
#include "AL/alc.h" |
||||
#include "AL/alext.h" |
||||
|
||||
static jboolean created = JNI_FALSE; |
||||
|
||||
/* InitAL opens the default device and sets up a context using default
|
||||
* attributes, making the program ready to call OpenAL functions. */ |
||||
static int InitAL() |
||||
{ |
||||
ALCdevice *device = NULL; |
||||
ALCcontext *ctx = NULL; |
||||
|
||||
/* Open and initialize a device with default settings */ |
||||
device = alcOpenDevice(NULL); |
||||
|
||||
if(device == NULL) |
||||
{ |
||||
fprintf(stderr, "Could not open a device!\n"); |
||||
goto cleanup; |
||||
} |
||||
|
||||
ctx = alcCreateContext(device, NULL); |
||||
|
||||
if (ctx == NULL) |
||||
{ |
||||
fprintf(stderr, "Could not create context!\n"); |
||||
goto cleanup; |
||||
} |
||||
|
||||
if (!alcMakeContextCurrent(ctx))
|
||||
{ |
||||
fprintf(stderr, "Could not make context current!\n"); |
||||
goto cleanup; |
||||
} |
||||
|
||||
return 0; |
||||
|
||||
cleanup: |
||||
if (ctx != NULL) alcDestroyContext(ctx); |
||||
if (device != NULL) alcCloseDevice(device); |
||||
return 1; |
||||
} |
||||
|
||||
/* CloseAL closes the device belonging to the current context, and destroys the
|
||||
* context. */ |
||||
static void CloseAL() |
||||
{ |
||||
ALCdevice *device; |
||||
ALCcontext *ctx; |
||||
|
||||
ctx = alcGetCurrentContext(); |
||||
|
||||
if (ctx == NULL)
|
||||
{ |
||||
return; |
||||
} |
||||
|
||||
device = alcGetContextsDevice(ctx); |
||||
|
||||
if (device == NULL)
|
||||
{ |
||||
return; |
||||
} |
||||
|
||||
if(!alcMakeContextCurrent(NULL)) { |
||||
return; |
||||
} |
||||
|
||||
alcDestroyContext(ctx); |
||||
alcCloseDevice(device); |
||||
} |
||||
|
||||
static ALCdevice* GetALCDevice() |
||||
{ |
||||
ALCdevice *device; |
||||
ALCcontext *ctx; |
||||
|
||||
ctx = alcGetCurrentContext(); |
||||
|
||||
if (ctx != NULL)
|
||||
{ |
||||
device = alcGetContextsDevice(ctx); |
||||
|
||||
if (device != NULL) |
||||
{ |
||||
return device; |
||||
} |
||||
} |
||||
|
||||
return NULL; |
||||
} |
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidALC_isCreated |
||||
(JNIEnv* env, jobject obj) |
||||
{ |
||||
return created; |
||||
} |
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_createALC |
||||
(JNIEnv* env, jobject obj) |
||||
{ |
||||
created = (InitAL() == 0); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_destroyALC |
||||
(JNIEnv* env, jobject obj) |
||||
{ |
||||
CloseAL(); |
||||
created = JNI_FALSE; |
||||
} |
||||
|
||||
JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidALC_alcGetString |
||||
(JNIEnv* env, jobject obj, jint param) |
||||
{ |
||||
ALCdevice* device = GetALCDevice(); |
||||
if (device == NULL) return NULL; |
||||
return (*env)->NewStringUTF(env, alcGetString(device, param)); |
||||
} |
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidALC_alcIsExtensionPresent |
||||
(JNIEnv* env, jobject obj, jstring extension) |
||||
{ |
||||
ALCdevice* device = GetALCDevice(); |
||||
|
||||
if (device == NULL) return JNI_FALSE; |
||||
|
||||
const char* strExtension = (*env)->GetStringUTFChars(env, extension, NULL); |
||||
|
||||
if (strExtension == NULL) |
||||
{ |
||||
return JNI_FALSE; |
||||
} |
||||
|
||||
jboolean result = alcIsExtensionPresent(device, strExtension); |
||||
|
||||
(*env)->ReleaseStringUTFChars(env, extension, strExtension); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcGetInteger |
||||
(JNIEnv* env, jobject obj, jint param, jobject buffer, jint bufferSize) |
||||
{ |
||||
ALCdevice* device = GetALCDevice(); |
||||
|
||||
if (device == NULL) return; |
||||
|
||||
ALCint* pBuffers = (ALCint*) (*env)->GetDirectBufferAddress(env, buffer); |
||||
|
||||
alcGetIntegerv(device, (ALCenum)param, (ALCsizei)bufferSize, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcDevicePauseSOFT |
||||
(JNIEnv* env, jobject obj) |
||||
{ |
||||
ALCdevice* device = GetALCDevice(); |
||||
|
||||
if (device == NULL) return; |
||||
|
||||
alcDevicePauseSOFT(device); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcDeviceResumeSOFT |
||||
(JNIEnv* env, jobject obj) |
||||
{ |
||||
ALCdevice* device = GetALCDevice(); |
||||
|
||||
if (device == NULL) return; |
||||
|
||||
alcDeviceResumeSOFT(device); |
||||
} |
@ -0,0 +1,77 @@ |
||||
/* DO NOT EDIT THIS FILE - it is machine generated */ |
||||
#include <jni.h> |
||||
/* Header for class com_jme3_audio_android_AndroidALC */ |
||||
|
||||
#ifndef _Included_com_jme3_audio_android_AndroidALC |
||||
#define _Included_com_jme3_audio_android_AndroidALC |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidALC |
||||
* Method: createALC |
||||
* Signature: ()V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_createALC |
||||
(JNIEnv *, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidALC |
||||
* Method: destroyALC |
||||
* Signature: ()V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_destroyALC |
||||
(JNIEnv *, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidALC |
||||
* Method: isCreated |
||||
* Signature: ()Z |
||||
*/ |
||||
JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidALC_isCreated |
||||
(JNIEnv *, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidALC |
||||
* Method: alcGetString |
||||
* Signature: (I)Ljava/lang/String; |
||||
*/ |
||||
JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidALC_alcGetString |
||||
(JNIEnv *, jobject, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidALC |
||||
* Method: alcIsExtensionPresent |
||||
* Signature: (Ljava/lang/String;)Z |
||||
*/ |
||||
JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidALC_alcIsExtensionPresent |
||||
(JNIEnv *, jobject, jstring); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidALC |
||||
* Method: alcGetInteger |
||||
* Signature: (ILjava/nio/IntBuffer;I)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcGetInteger |
||||
(JNIEnv *, jobject, jint, jobject, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidALC |
||||
* Method: alcDevicePauseSOFT |
||||
* Signature: ()V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcDevicePauseSOFT |
||||
(JNIEnv *, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidALC |
||||
* Method: alcDeviceResumeSOFT |
||||
* Signature: ()V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcDeviceResumeSOFT |
||||
(JNIEnv *, jobject); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -0,0 +1,75 @@ |
||||
#include "util.h" |
||||
#include "com_jme3_audio_android_AndroidEFX.h" |
||||
#include "AL/alext.h" |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenAuxiliaryEffectSlots |
||||
(JNIEnv* env, jobject obj, jint numSlots, jobject buffer) |
||||
{ |
||||
ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); |
||||
alGenAuxiliaryEffectSlots((ALsizei)numSlots, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenEffects |
||||
(JNIEnv* env, jobject obj, jint numEffects, jobject buffer) |
||||
{ |
||||
ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); |
||||
alGenEffects((ALsizei)numEffects, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alEffecti |
||||
(JNIEnv* env, jobject obj, jint effect, jint param, jint value) |
||||
{ |
||||
alEffecti((ALuint)effect, (ALenum)param, (ALint)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alAuxiliaryEffectSloti |
||||
(JNIEnv* env, jobject obj, jint effectSlot, jint param, jint value) |
||||
{ |
||||
alAuxiliaryEffectSloti((ALuint)effectSlot, (ALenum)param, (ALint)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteEffects |
||||
(JNIEnv* env, jobject obj, jint numEffects, jobject buffer) |
||||
{ |
||||
ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); |
||||
alDeleteEffects((ALsizei)numEffects, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteAuxiliaryEffectSlots |
||||
(JNIEnv* env, jobject obj, jint numEffectSlots, jobject buffer) |
||||
{ |
||||
ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); |
||||
alDeleteAuxiliaryEffectSlots((ALsizei)numEffectSlots, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenFilters |
||||
(JNIEnv* env, jobject obj, jint numFilters, jobject buffer) |
||||
{ |
||||
ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); |
||||
alGenFilters((ALsizei)numFilters, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alFilteri |
||||
(JNIEnv* env, jobject obj, jint filter, jint param, jint value) |
||||
{ |
||||
alFilteri((ALuint)filter, (ALenum)param, (ALint)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alFilterf |
||||
(JNIEnv* env, jobject obj, jint filter, jint param, jfloat value) |
||||
{ |
||||
alFilterf((ALuint)filter, (ALenum)param, (ALfloat)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteFilters |
||||
(JNIEnv* env, jobject obj, jint numFilters, jobject buffer) |
||||
{ |
||||
ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); |
||||
alDeleteFilters((ALsizei)numFilters, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alEffectf |
||||
(JNIEnv* env, jobject obj, jint effect, jint param, jfloat value) |
||||
{ |
||||
alEffectf((ALuint)effect, (ALenum)param, (ALfloat)value); |
||||
} |
@ -0,0 +1,101 @@ |
||||
/* DO NOT EDIT THIS FILE - it is machine generated */ |
||||
#include <jni.h> |
||||
/* Header for class com_jme3_audio_android_AndroidEFX */ |
||||
|
||||
#ifndef _Included_com_jme3_audio_android_AndroidEFX |
||||
#define _Included_com_jme3_audio_android_AndroidEFX |
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alGenAuxiliaryEffectSlots |
||||
* Signature: (ILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenAuxiliaryEffectSlots |
||||
(JNIEnv *, jobject, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alGenEffects |
||||
* Signature: (ILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenEffects |
||||
(JNIEnv *, jobject, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alEffecti |
||||
* Signature: (III)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alEffecti |
||||
(JNIEnv *, jobject, jint, jint, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alAuxiliaryEffectSloti |
||||
* Signature: (III)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alAuxiliaryEffectSloti |
||||
(JNIEnv *, jobject, jint, jint, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alDeleteEffects |
||||
* Signature: (ILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteEffects |
||||
(JNIEnv *, jobject, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alDeleteAuxiliaryEffectSlots |
||||
* Signature: (ILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteAuxiliaryEffectSlots |
||||
(JNIEnv *, jobject, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alGenFilters |
||||
* Signature: (ILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenFilters |
||||
(JNIEnv *, jobject, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alFilteri |
||||
* Signature: (III)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alFilteri |
||||
(JNIEnv *, jobject, jint, jint, jint); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alFilterf |
||||
* Signature: (IIF)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alFilterf |
||||
(JNIEnv *, jobject, jint, jint, jfloat); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alDeleteFilters |
||||
* Signature: (ILjava/nio/IntBuffer;)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteFilters |
||||
(JNIEnv *, jobject, jint, jobject); |
||||
|
||||
/*
|
||||
* Class: com_jme3_audio_android_AndroidEFX |
||||
* Method: alEffectf |
||||
* Signature: (IIF)V |
||||
*/ |
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alEffectf |
||||
(JNIEnv *, jobject, jint, jint, jfloat); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
#endif |
@ -1,483 +0,0 @@ |
||||
#include "com_jme3_audio_android_AndroidOpenALSoftAudioRenderer.h" |
||||
#include "AL/alc.h" |
||||
#include "AL/al.h" |
||||
#include "AL/alext.h" |
||||
// for __android_log_print(ANDROID_LOG_INFO, "YourApp", "formatted message");
|
||||
#include <android/log.h> |
||||
#include <jni.h> |
||||
#include <stddef.h> |
||||
#include <stdio.h> |
||||
#include <assert.h> |
||||
#include <string.h> |
||||
#include <time.h> |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
static jboolean created = JNI_FALSE; |
||||
|
||||
#define BUFFER_COUNT 1 |
||||
ALuint* buffers[BUFFER_COUNT] = { 0 }; |
||||
ALuint* source = 0; |
||||
|
||||
int getError() { |
||||
int errorcode = alGetError(); |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "getError: %d", errorcode);
|
||||
return errorcode; |
||||
} |
||||
|
||||
/* InitAL opens the default device and sets up a context using default
|
||||
* attributes, making the program ready to call OpenAL functions. */ |
||||
int InitAL() |
||||
{ |
||||
ALCdevice *device; |
||||
ALCcontext *ctx; |
||||
|
||||
/* Open and initialize a device with default settings */ |
||||
device = alcOpenDevice(NULL); |
||||
if(!device) |
||||
{ |
||||
fprintf(stderr, "Could not open a device!\n"); |
||||
return 1; |
||||
} |
||||
|
||||
ctx = alcCreateContext(device, NULL); |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "NULL: %d", NULL);
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Created context: %d", ctx);
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Created context addr: %d", &ctx);
|
||||
if(ctx == NULL || alcMakeContextCurrent(ctx) == ALC_FALSE) |
||||
{ |
||||
if(ctx != NULL) |
||||
alcDestroyContext(ctx); |
||||
alcCloseDevice(device); |
||||
fprintf(stderr, "Could not set a context!\n"); |
||||
return 1; |
||||
} |
||||
|
||||
printf("Opened \"%s\"\n", alcGetString(device, ALC_DEVICE_SPECIFIER)); |
||||
__android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Opened %s", alcGetString(device, ALC_DEVICE_SPECIFIER)); |
||||
return 0; |
||||
} |
||||
|
||||
/* CloseAL closes the device belonging to the current context, and destroys the
|
||||
* context. */ |
||||
void CloseAL() |
||||
{ |
||||
ALCdevice *device; |
||||
ALCcontext *ctx; |
||||
ALCboolean result; |
||||
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Getting current context");
|
||||
ctx = alcGetCurrentContext(); |
||||
// getError();
|
||||
if(ctx == NULL){ |
||||
__android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "No context found"); |
||||
return; |
||||
} |
||||
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Getting current context device");
|
||||
device = alcGetContextsDevice(ctx); |
||||
if(device == NULL) { |
||||
__android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "No device found"); |
||||
return; |
||||
} else { |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcGetContextsDevice device: %d", device);
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcGetContextsDevice device addr: %d", &device);
|
||||
} |
||||
// getError();
|
||||
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Setting context to NULL");
|
||||
result = alcMakeContextCurrent(NULL); |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcMakeContextCurrent returned");
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcMakeContextCurrent returned with result: %d", result);
|
||||
if(!result) { |
||||
__android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcMakeContextCurrent failed"); |
||||
return; |
||||
} |
||||
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Destroying context: %d", ctx);
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Destroying context addr: %d", &ctx);
|
||||
alcDestroyContext(ctx); |
||||
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Closing device");
|
||||
result = alcCloseDevice(device); |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcCloseDevice result: %d", result);
|
||||
} |
||||
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alIsCreated |
||||
(JNIEnv* env, jclass) |
||||
{ |
||||
return created; |
||||
} |
||||
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alCreate |
||||
(JNIEnv* env, jclass) |
||||
{ |
||||
__android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Starting Audio Engine"); |
||||
|
||||
InitAL(); |
||||
created = JNI_TRUE; |
||||
return created; |
||||
|
||||
} |
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDestroy |
||||
(JNIEnv* env, jclass) |
||||
{ |
||||
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDestroy");
|
||||
CloseAL(); |
||||
created = JNI_FALSE; |
||||
return created; |
||||
|
||||
} |
||||
|
||||
JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alcGetString |
||||
(JNIEnv* env, jclass, jint param) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcGetString for param: %d", param);
|
||||
|
||||
ALCdevice *device; |
||||
ALCcontext *ctx; |
||||
|
||||
ctx = alcGetCurrentContext(); |
||||
if(ctx != NULL) { |
||||
device = alcGetContextsDevice(ctx); |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcGetString param value: %s", alcGetString(device, param));
|
||||
return env->NewStringUTF(alcGetString(device, param)); |
||||
} |
||||
} |
||||
|
||||
JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGetString |
||||
(JNIEnv* env, jclass, jint param) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGetString for param: %d", param);
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGetString param value: %s", alGetString(param));
|
||||
return env->NewStringUTF(alGetString(param)); |
||||
} |
||||
|
||||
JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGenSources |
||||
(JNIEnv *, jclass) |
||||
{ |
||||
ALuint source; |
||||
alGenSources(1, &source); |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGenSources: %d", source);
|
||||
return source; |
||||
} |
||||
|
||||
JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGetError |
||||
(JNIEnv *, jclass) |
||||
{ |
||||
return getError(); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDeleteSources |
||||
(JNIEnv* env, jclass, jint numSources, jobject intbufSources) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteSources numSources: %d", numSources);
|
||||
|
||||
ALuint* pIntBufSources = (ALuint*) env->GetDirectBufferAddress(intbufSources); |
||||
alDeleteSources((ALsizei)numSources, pIntBufSources); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGenBuffers |
||||
(JNIEnv* env, jclass, jint numBuffers, jobject intbufBuffers) |
||||
{ |
||||
ALuint* pIntBufBuffers = (ALuint*) env->GetDirectBufferAddress(intbufBuffers); |
||||
alGenBuffers((ALsizei)numBuffers, pIntBufBuffers); |
||||
// for (int i=0; i<numBuffers; i++) {
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGenBuffers[%d]: %d", i, *(pIntBufBuffers+i));
|
||||
// }
|
||||
|
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDeleteBuffers |
||||
(JNIEnv* env, jclass, jint numBuffers, jobject intbufBuffers) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteBuffers numBuffers: %d", numBuffers);
|
||||
|
||||
ALuint* pIntBufBuffers = (ALuint*) env->GetDirectBufferAddress(intbufBuffers); |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteBuffers Buffers: %d", *pIntBufBuffers);
|
||||
// for (int i=0; i<numBuffers; i++) {
|
||||
// if(alIsBuffer(*(pIntBufBuffers+i)) == AL_TRUE) {
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteBuffers[%d]: %d", i, *(pIntBufBuffers+i));
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteBuffers buffer is a known buffer");
|
||||
// }
|
||||
// }
|
||||
alDeleteBuffers((ALsizei)numBuffers, pIntBufBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourceStop |
||||
(JNIEnv *, jclass, jint source) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourceStop for source: %d", source);
|
||||
alSourceStop((ALuint)source); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourcei |
||||
(JNIEnv *, jclass, jint source, jint param, jint value) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourcei for source: %d, param: %d, value: %d", source, param, value);
|
||||
alSourcei((ALuint)source, (ALenum)param, (ALint)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alBufferData |
||||
(JNIEnv* env, jclass, jint buffer, jint format, jobject bufferData, jint bufferSize, jint frequency) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alBufferData for source: %d, format: %d, size: %d, frequency: %d", buffer, format, bufferSize, frequency);
|
||||
ALuint* pBufferData = (ALuint*) env->GetDirectBufferAddress(bufferData); |
||||
alBufferData((ALuint)buffer, (ALenum)format, pBufferData, (ALsizei)bufferSize, (ALsizei)frequency); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourcePlay |
||||
(JNIEnv *, jclass, jint source) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourcePlay for source: %d", source);
|
||||
alSourcePlay((ALuint)source); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourcePause |
||||
(JNIEnv *, jclass, jint source) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourcePause for source: %d", source);
|
||||
alSourcePause((ALuint)source); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourcef |
||||
(JNIEnv *, jclass, jint source, jint param, jfloat value) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourcef for source: %d, param: %d, value: %f", source, param, value);
|
||||
alSourcef((ALuint)source, (ALenum)param, (ALfloat)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSource3f |
||||
(JNIEnv *, jclass, jint source, jint param, jfloat value1, jfloat value2, jfloat value3) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSource3f for source: %d, param: %d, value1: %f, value2: %f, value3: %f", source, param, value1, value2, value3);
|
||||
alSource3f((ALuint)source, (ALenum)param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3); |
||||
} |
||||
|
||||
JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGetSourcei |
||||
(JNIEnv *, jclass, jint source, jint param) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGetSourcei for source: %d, param: %d", source, param);
|
||||
ALint result; |
||||
alGetSourcei((ALuint)source, (ALenum)param, &result); |
||||
return (jint)result; |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourceUnqueueBuffers |
||||
(JNIEnv* env, jclass, jint source, jint numBuffers, jobject buffers) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourceUnqueueBuffers for source: %d, numBuffers: %d", source, numBuffers);
|
||||
ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffers); |
||||
|
||||
// for (ALuint i=0; i<numBuffers; i++) {
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourceUnqueueBuffers, checking buffer[%d]: %d", i, *(pBuffers+i));
|
||||
// ALboolean isBuffer = alIsBuffer(*(pBuffers+i));
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "buffer check result: %d", isBuffer);
|
||||
// }
|
||||
alSourceUnqueueBuffers((ALuint)source, (ALsizei)numBuffers, pBuffers); |
||||
// for (ALuint i=0; i<numBuffers; i++) {
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourceUnqueueBuffers[%d]: %d", i, *(pBuffers+i));
|
||||
// }
|
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourceQueueBuffers |
||||
(JNIEnv* env, jclass, jint source, jint numBuffers, jobject buffers) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourceQueueBuffers for source: %d, numBuffers: %d", source, numBuffers);
|
||||
ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffers); |
||||
alSourceQueueBuffers((ALuint)source, (ALsizei)numBuffers, pBuffers); |
||||
// for (ALuint i=0; i<numBuffers; i++) {
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourceQueueBuffers[%d]: %d", i, *(pBuffers+i));
|
||||
// }
|
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alListener |
||||
(JNIEnv* env, jclass, jint param, jobject bufferData) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alListener for param: %d", param);
|
||||
ALfloat* pBufferData = (ALfloat*) env->GetDirectBufferAddress(bufferData); |
||||
alListenerfv((ALenum)param, pBufferData); |
||||
// getError();
|
||||
// for (int i=0; i<4; i++) {
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alListener[%d]: %f", i, *(pBufferData+(i*sizeof(ALfloat))));
|
||||
// }
|
||||
|
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alListenerf |
||||
(JNIEnv *, jclass, jint param, jfloat value) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alListenerf for param: %d, value: %f", param, value);
|
||||
alListenerf((ALenum)param, (ALfloat)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alListener3f |
||||
(JNIEnv *, jclass, jint param, jfloat value1, jfloat value2, jfloat value3) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alListener3f for param: %d, value1: %f, value2: %f, value3: %f", param, value1, value2, value3);
|
||||
alListener3f((ALenum)param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3); |
||||
} |
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alcIsExtensionPresent |
||||
(JNIEnv* env, jclass, jstring extension) |
||||
{ |
||||
|
||||
ALCdevice *device; |
||||
ALCcontext *ctx; |
||||
ALboolean result; |
||||
// char buf[128];
|
||||
const char* strExtension; |
||||
jsize strLength = env->GetStringUTFLength(extension); |
||||
|
||||
ctx = alcGetCurrentContext(); |
||||
if(ctx != NULL) { |
||||
device = alcGetContextsDevice(ctx); |
||||
|
||||
if (device != NULL) { |
||||
strExtension = env->GetStringUTFChars(extension, NULL); |
||||
if (strExtension == NULL) { |
||||
return JNI_FALSE; /* OutOfMemoryError already thrown */ |
||||
} |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcIsExtensionPresent for param: %s with size: %d", strExtension, strLength);
|
||||
|
||||
result = alcIsExtensionPresent(device, strExtension); |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcIsExtensionPresent found: %d", result);
|
||||
|
||||
env->ReleaseStringUTFChars(extension, strExtension); |
||||
|
||||
return (jboolean)result; |
||||
} else { |
||||
__android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "device is null in alcIsExtensionPresent"); |
||||
} |
||||
|
||||
} else { |
||||
__android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "current context is null in alcIsExtensionPresent"); |
||||
} |
||||
|
||||
return JNI_FALSE; |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alcGetInteger |
||||
(JNIEnv* env, jclass, jint param, jobject buffer, jint bufferSize) |
||||
{ |
||||
ALCdevice *device; |
||||
ALCcontext *ctx; |
||||
|
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcGetInteger for param: %d", param);
|
||||
ALCint* pBuffers = (ALCint*) env->GetDirectBufferAddress(buffer); |
||||
|
||||
ctx = alcGetCurrentContext(); |
||||
if(ctx != NULL) { |
||||
device = alcGetContextsDevice(ctx); |
||||
|
||||
if (device != NULL) { |
||||
alcGetIntegerv(device, (ALCenum)param, (ALCsizei)bufferSize, pBuffers); |
||||
} else { |
||||
__android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "device is null in alcGetInteger"); |
||||
} |
||||
|
||||
} else { |
||||
__android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "current context is null in alcGetInteger"); |
||||
} |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGenAuxiliaryEffectSlots |
||||
(JNIEnv* env, jclass, jint numSlots, jobject buffer) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGenAuxiliaryEffectSlots for numSlots: %d", numSlots);
|
||||
ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); |
||||
alGenAuxiliaryEffectSlots((ALsizei)numSlots, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGenEffects |
||||
(JNIEnv* env, jclass, jint numEffects, jobject buffer) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGenEffects for numEffects: %d", numEffects);
|
||||
ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); |
||||
alGenEffects((ALsizei)numEffects, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alEffecti |
||||
(JNIEnv *, jclass, jint effect, jint param, jint value) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alEffecti for effect: %d, param: %d, value: %d", effect, param, value);
|
||||
alEffecti((ALuint)effect, (ALenum)param, (ALint)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alAuxiliaryEffectSloti |
||||
(JNIEnv *, jclass, jint effectSlot, jint param, jint value) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alAuxiliaryEffectSloti for effect: %d, param: %d, value: %d", effectSlot, param, value);
|
||||
alAuxiliaryEffectSloti((ALuint)effectSlot, (ALenum)param, (ALint)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDeleteEffects |
||||
(JNIEnv* env, jclass, jint numEffects, jobject buffer) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteEffects for numEffects: %d", numEffects);
|
||||
ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); |
||||
alDeleteEffects((ALsizei)numEffects, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDeleteAuxiliaryEffectSlots |
||||
(JNIEnv* env, jclass, jint numEffectSlots, jobject buffer) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteAuxiliaryEffectSlots for numEffectSlots: %d", numEffectSlots);
|
||||
ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); |
||||
alDeleteAuxiliaryEffectSlots((ALsizei)numEffectSlots, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGenFilters |
||||
(JNIEnv* env, jclass, jint numFilters, jobject buffer) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGenFilters for numFilters: %d", numFilters);
|
||||
ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); |
||||
alGenFilters((ALsizei)numFilters, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alFilteri |
||||
(JNIEnv *, jclass, jint filter, jint param, jint value) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alFilteri for filter: %d, param: %d, value: %d", filter, param, value);
|
||||
alFilteri((ALuint)filter, (ALenum)param, (ALint)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alFilterf |
||||
(JNIEnv *, jclass, jint filter, jint param, jfloat value) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alFilterf for filter: %d, param: %d, value: %f", filter, param, value);
|
||||
alFilterf((ALuint)filter, (ALenum)param, (ALfloat)value); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSource3i |
||||
(JNIEnv *, jclass, jint source, jint param, jint value1, jint value2, jint value3) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSource3i for source: %d, param: %d, value1: %d, value2: %d, value3: %d", source, param, value1, value2, value3);
|
||||
alSource3i((ALuint)source, (ALenum)param, (ALint)value1, (ALint)value2, (ALint)value3); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDeleteFilters |
||||
(JNIEnv* env, jclass, jint numFilters, jobject buffer) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteFilters for numFilters: %d", numFilters);
|
||||
ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); |
||||
alDeleteFilters((ALsizei)numFilters, pBuffers); |
||||
} |
||||
|
||||
JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alEffectf |
||||
(JNIEnv *, jclass, jint effect, jint param, jfloat value) |
||||
{ |
||||
// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alEffectf for effect: %d, param: %d, value: %d", effect, param, value);
|
||||
alEffectf((ALuint)effect, (ALenum)param, (ALfloat)value); |
||||
} |
||||
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
@ -0,0 +1,15 @@ |
||||
#ifndef JME_UTIL_H |
||||
#define JME_UTIL_H |
||||
|
||||
#include <stddef.h> |
||||
#include <stdio.h> |
||||
|
||||
#ifndef NDEBUG |
||||
#include <android/log.h> |
||||
#define LOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, \ |
||||
"OpenALSoft", fmt, ##__VA_ARGS__); |
||||
#else |
||||
#define LOGI(fmt, ...) |
||||
#endif |
||||
|
||||
#endif |
@ -0,0 +1,53 @@ |
||||
package com.jme3.audio.android; |
||||
|
||||
import com.jme3.audio.openal.AL; |
||||
import java.nio.ByteBuffer; |
||||
import java.nio.FloatBuffer; |
||||
import java.nio.IntBuffer; |
||||
|
||||
public final class AndroidAL implements AL { |
||||
|
||||
public AndroidAL() { |
||||
} |
||||
|
||||
public native String alGetString(int parameter); |
||||
|
||||
public native int alGenSources(); |
||||
|
||||
public native int alGetError(); |
||||
|
||||
public native void alDeleteSources(int numSources, IntBuffer sources); |
||||
|
||||
public native void alGenBuffers(int numBuffers, IntBuffer buffers); |
||||
|
||||
public native void alDeleteBuffers(int numBuffers, IntBuffer buffers); |
||||
|
||||
public native void alSourceStop(int source); |
||||
|
||||
public native void alSourcei(int source, int param, int value); |
||||
|
||||
public native void alBufferData(int buffer, int format, ByteBuffer data, int size, int frequency); |
||||
|
||||
public native void alSourcePlay(int source); |
||||
|
||||
public native void alSourcePause(int source); |
||||
|
||||
public native void alSourcef(int source, int param, float value); |
||||
|
||||
public native void alSource3f(int source, int param, float value1, float value2, float value3); |
||||
|
||||
public native int alGetSourcei(int source, int param); |
||||
|
||||
public native void alSourceUnqueueBuffers(int source, int numBuffers, IntBuffer buffers); |
||||
|
||||
public native void alSourceQueueBuffers(int source, int numBuffers, IntBuffer buffers); |
||||
|
||||
public native void alListener(int param, FloatBuffer data); |
||||
|
||||
public native void alListenerf(int param, float value); |
||||
|
||||
public native void alListener3f(int param, float value1, float value2, float value3); |
||||
|
||||
public native void alSource3i(int source, int param, int value1, int value2, int value3); |
||||
|
||||
} |
@ -0,0 +1,30 @@ |
||||
package com.jme3.audio.android; |
||||
|
||||
import com.jme3.audio.openal.ALC; |
||||
import java.nio.IntBuffer; |
||||
|
||||
public final class AndroidALC implements ALC { |
||||
|
||||
static { |
||||
System.loadLibrary("openalsoftjme"); |
||||
} |
||||
|
||||
public AndroidALC() { |
||||
} |
||||
|
||||
public native void createALC(); |
||||
|
||||
public native void destroyALC(); |
||||
|
||||
public native boolean isCreated(); |
||||
|
||||
public native String alcGetString(int parameter); |
||||
|
||||
public native boolean alcIsExtensionPresent(String extension); |
||||
|
||||
public native void alcGetInteger(int param, IntBuffer buffer, int size); |
||||
|
||||
public native void alcDevicePauseSOFT(); |
||||
|
||||
public native void alcDeviceResumeSOFT(); |
||||
} |
@ -1,24 +0,0 @@ |
||||
package com.jme3.audio.android; |
||||
|
||||
import com.jme3.audio.AudioRenderer; |
||||
|
||||
/** |
||||
* Android specific AudioRenderer interface that supports pausing and resuming |
||||
* audio files when the app is minimized or placed in the background |
||||
* |
||||
* @author iwgeric |
||||
*/ |
||||
public interface AndroidAudioRenderer extends AudioRenderer { |
||||
|
||||
/** |
||||
* Pauses all Playing audio. To be used when the app is placed in the |
||||
* background. |
||||
*/ |
||||
public void pauseAll(); |
||||
|
||||
/** |
||||
* Resumes all Paused audio. To be used when the app is brought back to |
||||
* the foreground. |
||||
*/ |
||||
public void resumeAll(); |
||||
} |
@ -0,0 +1,32 @@ |
||||
package com.jme3.audio.android; |
||||
|
||||
import com.jme3.audio.openal.EFX; |
||||
import java.nio.IntBuffer; |
||||
|
||||
public class AndroidEFX implements EFX { |
||||
|
||||
public AndroidEFX() { |
||||
} |
||||
|
||||
public native void alGenAuxiliaryEffectSlots(int numSlots, IntBuffer buffers); |
||||
|
||||
public native void alGenEffects(int numEffects, IntBuffer buffers); |
||||
|
||||
public native void alEffecti(int effect, int param, int value); |
||||
|
||||
public native void alAuxiliaryEffectSloti(int effectSlot, int param, int value); |
||||
|
||||
public native void alDeleteEffects(int numEffects, IntBuffer buffers); |
||||
|
||||
public native void alDeleteAuxiliaryEffectSlots(int numEffectSlots, IntBuffer buffers); |
||||
|
||||
public native void alGenFilters(int numFilters, IntBuffer buffers); |
||||
|
||||
public native void alFilteri(int filter, int param, int value); |
||||
|
||||
public native void alFilterf(int filter, int param, float value); |
||||
|
||||
public native void alDeleteFilters(int numFilters, IntBuffer buffers); |
||||
|
||||
public native void alEffectf(int effect, int param, float value); |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,296 @@ |
||||
package com.jme3.audio.openal; |
||||
|
||||
import java.nio.ByteBuffer; |
||||
import java.nio.FloatBuffer; |
||||
import java.nio.IntBuffer; |
||||
|
||||
/** |
||||
* @author iwgeric |
||||
*/ |
||||
public interface AL { |
||||
|
||||
/** |
||||
* Boolean False. |
||||
*/ |
||||
static final int AL_FALSE = 0; |
||||
|
||||
/** |
||||
* Boolean True. |
||||
*/ |
||||
static final int AL_TRUE = 1; |
||||
|
||||
/* "no distance model" or "no buffer" */ |
||||
static final int AL_NONE = 0; |
||||
|
||||
/** |
||||
* Indicate Source has relative coordinates. |
||||
*/ |
||||
static final int AL_SOURCE_RELATIVE = 0x202; |
||||
|
||||
/** |
||||
* Directional source, inner cone angle, in degrees. Range: [0-360] Default: |
||||
* 360 |
||||
*/ |
||||
static final int AL_CONE_INNER_ANGLE = 0x1001; |
||||
|
||||
/** |
||||
* Directional source, outer cone angle, in degrees. Range: [0-360] Default: |
||||
* 360 |
||||
*/ |
||||
static final int AL_CONE_OUTER_ANGLE = 0x1002; |
||||
|
||||
/** |
||||
* Specify the pitch to be applied at source. Range: [0.5-2.0] Default: 1.0 |
||||
*/ |
||||
static final int AL_PITCH = 0x1003; |
||||
|
||||
/** |
||||
* Specify the current location in three dimensional space. OpenAL, like |
||||
* OpenGL, uses a right handed coordinate system, where in a frontal default |
||||
* view X (thumb) points right, Y points up (index finger), and Z points |
||||
* towards the viewer/camera (middle finger). To switch from a left handed |
||||
* coordinate system, flip the sign on the Z coordinate. Listener position |
||||
* is always in the world coordinate system. |
||||
*/ |
||||
static final int AL_POSITION = 0x1004; |
||||
|
||||
/** |
||||
* Specify the current direction. |
||||
*/ |
||||
static final int AL_DIRECTION = 0x1005; |
||||
|
||||
/** |
||||
* Specify the current velocity in three dimensional space. |
||||
*/ |
||||
static final int AL_VELOCITY = 0x1006; |
||||
|
||||
/** |
||||
* Indicate whether source is looping. Type: ALboolean? Range: [AL_TRUE, |
||||
* AL_FALSE] Default: FALSE. |
||||
*/ |
||||
static final int AL_LOOPING = 0x1007; |
||||
|
||||
/** |
||||
* Indicate the buffer to provide sound samples. Type: ALuint. Range: any |
||||
* valid Buffer id. |
||||
*/ |
||||
static final int AL_BUFFER = 0x1009; |
||||
|
||||
/** |
||||
* Indicate the gain (volume amplification) applied. Type: ALfloat. Range: |
||||
* ]0.0- ] A value of 1.0 means un-attenuated/unchanged. Each division by 2 |
||||
* equals an attenuation of -6dB. Each multiplicaton with 2 equals an |
||||
* amplification of +6dB. A value of 0.0 is meaningless with respect to a |
||||
* logarithmic scale; it is interpreted as zero volume - the channel is |
||||
* effectively disabled. |
||||
*/ |
||||
static final int AL_GAIN = 0x100A; |
||||
|
||||
/* |
||||
* Indicate minimum source attenuation |
||||
* Type: ALfloat |
||||
* Range: [0.0 - 1.0] |
||||
* |
||||
* Logarthmic |
||||
*/ |
||||
static final int AL_MIN_GAIN = 0x100D; |
||||
|
||||
/** |
||||
* Indicate maximum source attenuation Type: ALfloat Range: [0.0 - 1.0] |
||||
* |
||||
* Logarthmic |
||||
*/ |
||||
static final int AL_MAX_GAIN = 0x100E; |
||||
|
||||
/** |
||||
* Indicate listener orientation. |
||||
* |
||||
* at/up |
||||
*/ |
||||
static final int AL_ORIENTATION = 0x100F; |
||||
|
||||
/** |
||||
* Source state information. |
||||
*/ |
||||
static final int AL_SOURCE_STATE = 0x1010; |
||||
static final int AL_INITIAL = 0x1011; |
||||
static final int AL_PLAYING = 0x1012; |
||||
static final int AL_PAUSED = 0x1013; |
||||
static final int AL_STOPPED = 0x1014; |
||||
|
||||
/** |
||||
* Buffer Queue params |
||||
*/ |
||||
static final int AL_BUFFERS_QUEUED = 0x1015; |
||||
static final int AL_BUFFERS_PROCESSED = 0x1016; |
||||
|
||||
/** |
||||
* Source buffer position information |
||||
*/ |
||||
static final int AL_SEC_OFFSET = 0x1024; |
||||
static final int AL_SAMPLE_OFFSET = 0x1025; |
||||
static final int AL_BYTE_OFFSET = 0x1026; |
||||
|
||||
/* |
||||
* Source type (Static, Streaming or undetermined) |
||||
* Source is Static if a Buffer has been attached using AL_BUFFER |
||||
* Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers |
||||
* Source is undetermined when it has the NULL buffer attached |
||||
*/ |
||||
static final int AL_SOURCE_TYPE = 0x1027; |
||||
static final int AL_STATIC = 0x1028; |
||||
static final int AL_STREAMING = 0x1029; |
||||
static final int AL_UNDETERMINED = 0x1030; |
||||
|
||||
/** |
||||
* Sound samples: format specifier. |
||||
*/ |
||||
static final int AL_FORMAT_MONO8 = 0x1100; |
||||
static final int AL_FORMAT_MONO16 = 0x1101; |
||||
static final int AL_FORMAT_STEREO8 = 0x1102; |
||||
static final int AL_FORMAT_STEREO16 = 0x1103; |
||||
|
||||
/** |
||||
* source specific reference distance Type: ALfloat Range: 0.0 - +inf |
||||
* |
||||
* At 0.0, no distance attenuation occurs. Default is 1.0. |
||||
*/ |
||||
static final int AL_REFERENCE_DISTANCE = 0x1020; |
||||
|
||||
/** |
||||
* source specific rolloff factor Type: ALfloat Range: 0.0 - +inf |
||||
* |
||||
*/ |
||||
static final int AL_ROLLOFF_FACTOR = 0x1021; |
||||
|
||||
/** |
||||
* Directional source, outer cone gain. |
||||
* |
||||
* Default: 0.0 Range: [0.0 - 1.0] Logarithmic |
||||
*/ |
||||
static final int AL_CONE_OUTER_GAIN = 0x1022; |
||||
|
||||
/** |
||||
* Indicate distance above which sources are not attenuated using the |
||||
* inverse clamped distance model. |
||||
* |
||||
* Default: +inf Type: ALfloat Range: 0.0 - +inf |
||||
*/ |
||||
static final int AL_MAX_DISTANCE = 0x1023; |
||||
|
||||
/** |
||||
* Sound samples: frequency, in units of Hertz [Hz]. This is the number of |
||||
* samples per second. Half of the sample frequency marks the maximum |
||||
* significant frequency component. |
||||
*/ |
||||
static final int AL_FREQUENCY = 0x2001; |
||||
static final int AL_BITS = 0x2002; |
||||
static final int AL_CHANNELS = 0x2003; |
||||
static final int AL_SIZE = 0x2004; |
||||
|
||||
/** |
||||
* Buffer state. |
||||
* |
||||
* Not supported for public use (yet). |
||||
*/ |
||||
static final int AL_UNUSED = 0x2010; |
||||
static final int AL_PENDING = 0x2011; |
||||
static final int AL_PROCESSED = 0x2012; |
||||
|
||||
/** |
||||
* Errors: No Error. |
||||
*/ |
||||
static final int AL_NO_ERROR = 0; |
||||
|
||||
/** |
||||
* Invalid Name paramater passed to AL call. |
||||
*/ |
||||
static final int AL_INVALID_NAME = 0xA001; |
||||
|
||||
/** |
||||
* Invalid parameter passed to AL call. |
||||
*/ |
||||
static final int AL_INVALID_ENUM = 0xA002; |
||||
|
||||
/** |
||||
* Invalid enum parameter value. |
||||
*/ |
||||
static final int AL_INVALID_VALUE = 0xA003; |
||||
|
||||
/** |
||||
* Illegal call. |
||||
*/ |
||||
static final int AL_INVALID_OPERATION = 0xA004; |
||||
|
||||
/** |
||||
* No mojo. |
||||
*/ |
||||
static final int AL_OUT_OF_MEMORY = 0xA005; |
||||
|
||||
/** |
||||
* Context strings: Vendor Name. |
||||
*/ |
||||
static final int AL_VENDOR = 0xB001; |
||||
static final int AL_VERSION = 0xB002; |
||||
static final int AL_RENDERER = 0xB003; |
||||
static final int AL_EXTENSIONS = 0xB004; |
||||
|
||||
/** |
||||
* Global tweakage. |
||||
*/ |
||||
/** |
||||
* Doppler scale. Default 1.0 |
||||
*/ |
||||
static final int AL_DOPPLER_FACTOR = 0xC000; |
||||
|
||||
/** |
||||
* Tweaks speed of propagation. |
||||
*/ |
||||
static final int AL_DOPPLER_VELOCITY = 0xC001; |
||||
|
||||
/** |
||||
* Speed of Sound in units per second |
||||
*/ |
||||
static final int AL_SPEED_OF_SOUND = 0xC003; |
||||
|
||||
/** |
||||
* Distance models |
||||
* |
||||
* used in conjunction with DistanceModel |
||||
* |
||||
* implicit: NONE, which disances distance attenuation. |
||||
*/ |
||||
static final int AL_DISTANCE_MODEL = 0xD000; |
||||
static final int AL_INVERSE_DISTANCE = 0xD001; |
||||
static final int AL_INVERSE_DISTANCE_CLAMPED = 0xD002; |
||||
static final int AL_LINEAR_DISTANCE = 0xD003; |
||||
static final int AL_LINEAR_DISTANCE_CLAMPED = 0xD004; |
||||
static final int AL_EXPONENT_DISTANCE = 0xD005; |
||||
static final int AL_EXPONENT_DISTANCE_CLAMPED = 0xD006; |
||||
//
|
||||
///* Listener parameter value ranges and defaults. */
|
||||
//#define AL_MIN_METERS_PER_UNIT FLT_MIN
|
||||
//#define AL_MAX_METERS_PER_UNIT FLT_MAX
|
||||
//#define AL_DEFAULT_METERS_PER_UNIT (1.0f)
|
||||
|
||||
public String alGetString(int parameter); |
||||
public int alGenSources(); |
||||
public int alGetError(); |
||||
public void alDeleteSources(int numSources, IntBuffer sources); |
||||
public void alGenBuffers(int numBuffers, IntBuffer buffers); |
||||
public void alDeleteBuffers(int numBuffers, IntBuffer buffers); |
||||
public void alSourceStop(int source); |
||||
public void alSourcei(int source, int param, int value); |
||||
public void alBufferData(int buffer, int format, ByteBuffer data, int size, int frequency); |
||||
public void alSourcePlay(int source); |
||||
public void alSourcePause(int source); |
||||
public void alSourcef(int source, int param, float value); |
||||
public void alSource3f(int source, int param, float value1, float value2, float value3); |
||||
public int alGetSourcei(int source, int param); |
||||
public void alSourceUnqueueBuffers(int source, int numBuffers, IntBuffer buffers); |
||||
public void alSourceQueueBuffers(int source, int numBuffers, IntBuffer buffers); |
||||
public void alListener(int param, FloatBuffer data); |
||||
public void alListenerf(int param, float value); |
||||
public void alListener3f(int param, float value1, float value2, float value3); |
||||
public void alSource3i(int source, int param, int value1, int value2, int value3); |
||||
} |
@ -0,0 +1,73 @@ |
||||
package com.jme3.audio.openal; |
||||
|
||||
import java.nio.IntBuffer; |
||||
|
||||
public interface ALC { |
||||
|
||||
/** |
||||
* No error |
||||
*/ |
||||
static final int ALC_NO_ERROR = 0; |
||||
|
||||
/** |
||||
* No device |
||||
*/ |
||||
static final int ALC_INVALID_DEVICE = 0xA001; |
||||
|
||||
/** |
||||
* invalid context ID |
||||
*/ |
||||
static final int ALC_INVALID_CONTEXT = 0xA002; |
||||
|
||||
/** |
||||
* bad enum |
||||
*/ |
||||
static final int ALC_INVALID_ENUM = 0xA003; |
||||
|
||||
/** |
||||
* bad value |
||||
*/ |
||||
static final int ALC_INVALID_VALUE = 0xA004; |
||||
|
||||
/** |
||||
* Out of memory. |
||||
*/ |
||||
static final int ALC_OUT_OF_MEMORY = 0xA005; |
||||
|
||||
/** |
||||
* The Specifier string for default device |
||||
*/ |
||||
static final int ALC_DEFAULT_DEVICE_SPECIFIER = 0x1004; |
||||
static final int ALC_DEVICE_SPECIFIER = 0x1005; |
||||
static final int ALC_EXTENSIONS = 0x1006; |
||||
|
||||
static final int ALC_MAJOR_VERSION = 0x1000; |
||||
static final int ALC_MINOR_VERSION = 0x1001; |
||||
|
||||
static final int ALC_ATTRIBUTES_SIZE = 0x1002; |
||||
static final int ALC_ALL_ATTRIBUTES = 0x1003; |
||||
|
||||
/** |
||||
* Capture extension |
||||
*/ |
||||
static final int ALC_EXT_CAPTURE = 1; |
||||
static final int ALC_CAPTURE_DEVICE_SPECIFIER = 0x310; |
||||
static final int ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER = 0x311; |
||||
static final int ALC_CAPTURE_SAMPLES = 0x312; |
||||
|
||||
/** |
||||
* ALC_ENUMERATE_ALL_EXT enums |
||||
*/ |
||||
static final int ALC_ENUMERATE_ALL_EXT = 1; |
||||
static final int ALC_DEFAULT_ALL_DEVICES_SPECIFIER = 0x1012; |
||||
static final int ALC_ALL_DEVICES_SPECIFIER = 0x1013; |
||||
|
||||
public void createALC(); |
||||
public void destroyALC(); |
||||
public boolean isCreated(); |
||||
public String alcGetString(int parameter); |
||||
public boolean alcIsExtensionPresent(String extension); |
||||
public void alcGetInteger(int param, IntBuffer buffer, int size); |
||||
public void alcDevicePauseSOFT(); |
||||
public void alcDeviceResumeSOFT(); |
||||
} |
@ -0,0 +1,43 @@ |
||||
package com.jme3.audio.openal; |
||||
|
||||
import static com.jme3.audio.openal.AL.*; |
||||
|
||||
public final class ALUtil { |
||||
|
||||
private ALUtil() { |
||||
} |
||||
|
||||
public static String getALErrorMessage(int errorCode) { |
||||
String errorText; |
||||
switch (errorCode) { |
||||
case AL_NO_ERROR: |
||||
errorText = "No Error"; |
||||
break; |
||||
case AL_INVALID_NAME: |
||||
errorText = "Invalid Name"; |
||||
break; |
||||
case AL_INVALID_ENUM: |
||||
errorText = "Invalid Enum"; |
||||
break; |
||||
case AL_INVALID_VALUE: |
||||
errorText = "Invalid Value"; |
||||
break; |
||||
case AL_INVALID_OPERATION: |
||||
errorText = "Invalid Operation"; |
||||
break; |
||||
case AL_OUT_OF_MEMORY: |
||||
errorText = "Out of Memory"; |
||||
break; |
||||
default: |
||||
errorText = "Unknown Error Code: " + String.valueOf(errorCode); |
||||
} |
||||
return errorText; |
||||
} |
||||
|
||||
public static void checkALError(AL al) { |
||||
int err = al.alGetError(); |
||||
if (err != AL_NO_ERROR) { |
||||
throw new RuntimeException("OpenAL Error: " + getALErrorMessage(err)); |
||||
} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,107 @@ |
||||
package com.jme3.audio.lwjgl; |
||||
|
||||
import com.jme3.audio.openal.AL; |
||||
import java.nio.ByteBuffer; |
||||
import java.nio.FloatBuffer; |
||||
import java.nio.IntBuffer; |
||||
import org.lwjgl.openal.AL10; |
||||
import org.lwjgl.openal.AL11; |
||||
|
||||
public final class LwjglAL implements AL { |
||||
|
||||
public LwjglAL() { |
||||
} |
||||
|
||||
public String alGetString(int parameter) { |
||||
return AL10.alGetString(parameter); |
||||
} |
||||
|
||||
public int alGenSources() { |
||||
return AL10.alGenSources(); |
||||
} |
||||
|
||||
public int alGetError() { |
||||
return AL10.alGetError(); |
||||
} |
||||
|
||||
public void alDeleteSources(int numSources, IntBuffer sources) { |
||||
if (sources.position() != 0) throw new AssertionError(); |
||||
if (sources.limit() != numSources) throw new AssertionError(); |
||||
AL10.alDeleteSources(sources); |
||||
} |
||||
|
||||
public void alGenBuffers(int numBuffers, IntBuffer buffers) { |
||||
if (buffers.position() != 0) throw new AssertionError(); |
||||
if (buffers.limit() != numBuffers) throw new AssertionError(); |
||||
AL10.alGenBuffers(buffers); |
||||
} |
||||
|
||||
public void alDeleteBuffers(int numBuffers, IntBuffer buffers) { |
||||
if (buffers.position() != 0) throw new AssertionError(); |
||||
if (buffers.limit() != numBuffers) throw new AssertionError(); |
||||
AL10.alDeleteBuffers(buffers); |
||||
} |
||||
|
||||
public void alSourceStop(int source) { |
||||
AL10.alSourceStop(source); |
||||
} |
||||
|
||||
public void alSourcei(int source, int param, int value) { |
||||
AL10.alSourcei(source, param, value); |
||||
} |
||||
|
||||
public void alBufferData(int buffer, int format, ByteBuffer data, int size, int frequency) { |
||||
if (data.position() != 0) throw new AssertionError(); |
||||
if (data.limit() != size) throw new AssertionError(); |
||||
AL10.alBufferData(buffer, format, data, frequency); |
||||
} |
||||
|
||||
public void alSourcePlay(int source) { |
||||
AL10.alSourcePlay(source); |
||||
} |
||||
|
||||
public void alSourcePause(int source) { |
||||
AL10.alSourcePause(source); |
||||
} |
||||
|
||||
public void alSourcef(int source, int param, float value) { |
||||
AL10.alSourcef(source, param, value); |
||||
} |
||||
|
||||
public void alSource3f(int source, int param, float value1, float value2, float value3) { |
||||
AL10.alSource3f(source, param, value1, value2, value3); |
||||
} |
||||
|
||||
public int alGetSourcei(int source, int param) { |
||||
return AL10.alGetSourcei(source, param); |
||||
} |
||||
|
||||
public void alSourceUnqueueBuffers(int source, int numBuffers, IntBuffer buffers) { |
||||
if (buffers.position() != 0) throw new AssertionError(); |
||||
if (buffers.limit() != numBuffers) throw new AssertionError(); |
||||
AL10.alSourceUnqueueBuffers(source, buffers); |
||||
} |
||||
|
||||
public void alSourceQueueBuffers(int source, int numBuffers, IntBuffer buffers) { |
||||
if (buffers.position() != 0) throw new AssertionError(); |
||||
if (buffers.limit() != numBuffers) throw new AssertionError(); |
||||
AL10.alSourceQueueBuffers(source, buffers); |
||||
} |
||||
|
||||
public void alListener(int param, FloatBuffer data) { |
||||
AL10.alListener(param, data); |
||||
} |
||||
|
||||
public void alListenerf(int param, float value) { |
||||
AL10.alListenerf(param, value); |
||||
} |
||||
|
||||
public void alListener3f(int param, float value1, float value2, float value3) { |
||||
AL10.alListener3f(param, value1, value2, value3); |
||||
} |
||||
|
||||
public void alSource3i(int source, int param, int value1, int value2, int value3) { |
||||
AL11.alSource3i(source, param, value1, value2, value3); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,50 @@ |
||||
package com.jme3.audio.lwjgl; |
||||
|
||||
import com.jme3.audio.openal.ALC; |
||||
import java.nio.IntBuffer; |
||||
import org.lwjgl.LWJGLException; |
||||
import org.lwjgl.openal.AL; |
||||
import org.lwjgl.openal.ALC10; |
||||
import org.lwjgl.openal.ALCcontext; |
||||
import org.lwjgl.openal.ALCdevice; |
||||
|
||||
public class LwjglALC implements ALC { |
||||
|
||||
public void createALC() { |
||||
try { |
||||
AL.create(); |
||||
} catch (LWJGLException ex) { |
||||
throw new RuntimeException(ex); |
||||
} |
||||
} |
||||
|
||||
public void destroyALC() { |
||||
AL.destroy(); |
||||
} |
||||
|
||||
public boolean isCreated() { |
||||
return AL.isCreated(); |
||||
} |
||||
|
||||
public String alcGetString(int parameter) { |
||||
ALCcontext context = ALC10.alcGetCurrentContext(); |
||||
ALCdevice device = ALC10.alcGetContextsDevice(context); |
||||
return ALC10.alcGetString(device, parameter); |
||||
} |
||||
|
||||
public boolean alcIsExtensionPresent(String extension) { |
||||
ALCcontext context = ALC10.alcGetCurrentContext(); |
||||
ALCdevice device = ALC10.alcGetContextsDevice(context); |
||||
return ALC10.alcIsExtensionPresent(device, extension); |
||||
} |
||||
|
||||
public void alcGetInteger(int param, IntBuffer buffer, int size) { |
||||
if (buffer.position() != 0) throw new AssertionError(); |
||||
if (buffer.limit() != size) throw new AssertionError(); |
||||
|
||||
ALCcontext context = ALC10.alcGetCurrentContext(); |
||||
ALCdevice device = ALC10.alcGetContextsDevice(context); |
||||
ALC10.alcGetInteger(device, param, buffer); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,65 @@ |
||||
package com.jme3.audio.lwjgl; |
||||
|
||||
import com.jme3.audio.openal.EFX; |
||||
import java.nio.IntBuffer; |
||||
import org.lwjgl.openal.EFX10; |
||||
|
||||
public class LwjglEFX implements EFX { |
||||
|
||||
public void alGenAuxiliaryEffectSlots(int numSlots, IntBuffer buffers) { |
||||
if (buffers.position() != 0) throw new AssertionError(); |
||||
if (buffers.limit() != numSlots) throw new AssertionError(); |
||||
EFX10.alGenAuxiliaryEffectSlots(buffers); |
||||
} |
||||
|
||||
public void alGenEffects(int numEffects, IntBuffer buffers) { |
||||
if (buffers.position() != 0) throw new AssertionError(); |
||||
if (buffers.limit() != numEffects) throw new AssertionError(); |
||||
EFX10.alGenEffects(buffers); |
||||
} |
||||
|
||||
public void alEffecti(int effect, int param, int value) { |
||||
EFX10.alEffecti(effect, param, value); |
||||
} |
||||
|
||||
public void alAuxiliaryEffectSloti(int effectSlot, int param, int value) { |
||||
EFX10.alAuxiliaryEffectSloti(effectSlot, param, value); |
||||
} |
||||
|
||||
public void alDeleteEffects(int numEffects, IntBuffer buffers) { |
||||
if (buffers.position() != 0) throw new AssertionError(); |
||||
if (buffers.limit() != numEffects) throw new AssertionError(); |
||||
EFX10.alDeleteEffects(buffers); |
||||
} |
||||
|
||||
public void alDeleteAuxiliaryEffectSlots(int numEffectSlots, IntBuffer buffers) { |
||||
if (buffers.position() != 0) throw new AssertionError(); |
||||
if (buffers.limit() != numEffectSlots) throw new AssertionError(); |
||||
EFX10.alDeleteAuxiliaryEffectSlots(buffers); |
||||
} |
||||
|
||||
public void alGenFilters(int numFilters, IntBuffer buffers) { |
||||
if (buffers.position() != 0) throw new AssertionError(); |
||||
if (buffers.limit() != numFilters) throw new AssertionError(); |
||||
EFX10.alGenFilters(buffers); |
||||
} |
||||
|
||||
public void alFilteri(int filter, int param, int value) { |
||||
EFX10.alFilteri(filter, param, value); |
||||
} |
||||
|
||||
public void alFilterf(int filter, int param, float value) { |
||||
EFX10.alFilterf(filter, param, value); |
||||
} |
||||
|
||||
public void alDeleteFilters(int numFilters, IntBuffer buffers) { |
||||
if (buffers.position() != 0) throw new AssertionError(); |
||||
if (buffers.limit() != numFilters) throw new AssertionError(); |
||||
EFX10.alDeleteFilters(buffers); |
||||
} |
||||
|
||||
public void alEffectf(int effect, int param, float value) { |
||||
EFX10.alEffectf(effect, param, value); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue